/* === Base Reset & Variables === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-200: #bae6fd;
  --sky-300: #7dd3fc;
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-700: #0369a1;
  --sky-800: #075985;
  --sky-900: #0c4a6e;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --white: #ffffff;
  --amber-400: #fbbf24;
  --green-400: #4ade80;
  --green-500: #22c55e;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html {
  height: 100%;
  font-family: var(--font);
  background: var(--slate-900);
  -webkit-font-smoothing: antialiased;
}

body {
  height: 100%;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--slate-900);
  color: var(--slate-800);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* === Landing Page === */
.landing {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, var(--sky-900) 0%, var(--slate-900) 50%, var(--sky-800) 100%);
  overflow: hidden;
  z-index: 1;
}

.landing::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(14, 165, 233, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(56, 189, 248, 0.1) 0%, transparent 50%);
  animation: bgShift 20s ease-in-out infinite;
}

@keyframes bgShift {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-5%, 3%); }
}

.landing-overlay {
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='1'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* Animated clouds */
.landing-clouds {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.cloud-layer {
  position: absolute;
  width: 120%;
  bottom: 0;
  left: -10%;
  opacity: 0.7;
}

.cloud-layer-1 {
  animation: cloudDrift1 60s linear infinite;
}

.cloud-layer-2 {
  bottom: 5%;
  animation: cloudDrift2 45s linear infinite;
  transform: scaleX(-1);
  opacity: 0.4;
}

@keyframes cloudDrift1 {
  0% { transform: translateX(0); }
  100% { transform: translateX(-10%); }
}

@keyframes cloudDrift2 {
  0% { transform: scaleX(-1) translateX(0); }
  100% { transform: scaleX(-1) translateX(-15%); }
}

/* Hero plane illustration */
.landing-hero-img {
  position: absolute;
  top: 5%;
  right: 0;
  width: 55%;
  max-width: 500px;
  opacity: 0.25;
  pointer-events: none;
  animation: planeFloat 8s ease-in-out infinite;
}

.landing-hero-img img {
  width: 100%;
  height: auto;
}

@keyframes planeFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(0.5deg); }
}

/* Course cards */
.course-cards {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.course-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  min-width: 110px;
}

.course-card:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateY(-2px);
}

.course-icon {
  width: 36px;
  height: 36px;
  color: var(--sky-400);
}

.course-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--white);
}

.course-price {
  font-size: 0.7rem;
  color: var(--sky-300);
  opacity: 0.8;
}

.landing-content {
  position: relative;
  text-align: center;
  padding: 2rem;
  max-width: 520px;
  animation: fadeInUp 0.8s ease-out;
  z-index: 2;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.landing-logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.plane-icon {
  width: 40px;
  height: 40px;
  color: var(--sky-400);
}

.landing h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.landing-subtitle {
  font-size: 1.1rem;
  color: var(--sky-300);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.landing-desc {
  font-size: 0.95rem;
  color: var(--slate-300);
  line-height: 1.6;
  margin-bottom: 2rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 2rem;
  background: var(--sky-500);
  color: var(--white);
  border: none;
  border-radius: var(--radius-xl);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(14, 165, 233, 0.4);
}

.btn-primary:hover {
  background: var(--sky-600);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.landing-features {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
  flex-wrap: wrap;
}

.feature {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--slate-400);
  font-size: 0.85rem;
}

.feature svg {
  color: var(--sky-400);
  flex-shrink: 0;
}

/* === Chat View === */
.chat-view {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--slate-50);
  animation: slideInRight 0.4s ease-out;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

.hidden { display: none !important; }

/* === Chat Header === */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--slate-600);
  transition: background 0.15s;
}

.btn-icon:hover {
  background: var(--slate-100);
}

.header-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--sky-500), var(--sky-700));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.plane-icon-sm {
  width: 20px;
  height: 20px;
  color: var(--white);
}

.header-info h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--slate-800);
  line-height: 1.2;
}

.header-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  background: var(--green-500);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.status-text {
  font-size: 0.75rem;
  color: var(--green-500);
  font-weight: 500;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-badge, .phase-badge {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-lg);
  font-size: 0.75rem;
  font-weight: 600;
}

.score-badge {
  background: var(--sky-100);
  color: var(--sky-700);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.score-label {
  font-weight: 500;
  opacity: 0.7;
}

.phase-badge {
  background: var(--slate-100);
  color: var(--slate-600);
}

/* === Progress Bar === */
.progress-container {
  height: 3px;
  background: var(--slate-200);
  flex-shrink: 0;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--sky-400), var(--sky-600));
  transition: width 0.6s ease;
  border-radius: 0 3px 3px 0;
}

/* === Messages === */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.message {
  display: flex;
  gap: 0.5rem;
  max-width: 85%;
  animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message--bot {
  align-self: flex-start;
}

.message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  align-self: flex-end;
}

.message--bot .message-avatar {
  background: linear-gradient(135deg, var(--sky-500), var(--sky-700));
  color: var(--white);
}

.message--user .message-avatar {
  background: var(--slate-600);
  color: var(--white);
}

.message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.9375rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message--bot .message-bubble {
  background: var(--white);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow-sm);
}

.message--user .message-bubble {
  background: var(--sky-600);
  color: var(--white);
  border-bottom-right-radius: 6px;
  box-shadow: var(--shadow-sm);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 1rem 1.25rem;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--slate-400);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* === Input Area === */
.chat-input-container {
  padding: 0.75rem 1rem;
  background: var(--white);
  border-top: 1px solid var(--slate-200);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  align-items: flex-end;
}

.input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--slate-50);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-xl);
  padding: 0.25rem 0.25rem 0.25rem 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--sky-400);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

#messageInput {
  flex: 1;
  border: none;
  background: none;
  font-size: 0.9375rem;
  font-family: var(--font);
  color: var(--slate-800);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 0.5rem 0;
}

#messageInput::placeholder {
  color: var(--slate-400);
}

.btn-send {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sky-500);
  color: var(--white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-send:hover:not(:disabled) {
  background: var(--sky-600);
}

.btn-send:disabled {
  background: var(--slate-300);
  cursor: not-allowed;
}

.input-hint {
  font-size: 0.7rem;
  color: var(--slate-400);
  text-align: center;
  margin-top: 0.4rem;
}

/* === Scrollbar === */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 3px;
}

/* === Responsive === */
@media (min-width: 640px) {
  .landing h1 { font-size: 2.5rem; }
  .landing-desc { font-size: 1rem; }
  .message { max-width: 70%; }
}

@media (min-width: 768px) {
  /* Desktop: center chat in a phone-like container */
  .chat-view {
    max-width: 480px;
    max-height: 90vh;
    margin: 5vh auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--slate-200);
    overflow: hidden;
  }

  .chat-header {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
      linear-gradient(135deg, var(--sky-900) 0%, var(--slate-900) 50%, var(--sky-800) 100%);
  }

  .landing {
    inset: 0;
  }
}

@media (max-width: 480px) {
  .landing-hero-img {
    top: 2%;
    width: 70%;
    opacity: 0.15;
  }

  .course-cards {
    gap: 0.5rem;
  }

  .course-card {
    padding: 0.75rem 0.75rem;
    min-width: 90px;
  }
}

@media (max-width: 380px) {
  .landing-features { gap: 1rem; }
  .landing h1 { font-size: 1.5rem; }
  .header-right { display: none; }
  .course-icon { width: 28px; height: 28px; }
  .course-name { font-size: 0.7rem; }
  .course-price { font-size: 0.65rem; }
}

/* === Safe Areas (iPhone notch etc.) === */
@supports (padding-top: env(safe-area-inset-top)) {
  .chat-header {
    padding-top: calc(0.75rem + env(safe-area-inset-top));
  }
  .chat-input-container {
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
  }
}

/* === Pre-Chat Contact Modal === */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: white;
  border-radius: 1.25rem;
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.modal-avatar {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--sky-500), var(--sky-700));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modal-avatar svg {
  width: 24px;
  height: 24px;
  color: white;
  stroke: white;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 0.1rem;
}

.modal-header p {
  font-size: 0.85rem;
  color: var(--slate-500);
}

.modal-intro {
  font-size: 0.9rem;
  color: var(--slate-600);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-group {
  margin-bottom: 0.85rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 0.35rem;
}

.form-group label .required {
  color: #ef4444;
}

.form-group input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--slate-200);
  border-radius: 0.6rem;
  font-size: 0.95rem;
  color: var(--slate-800);
  background: var(--slate-50);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  font-family: inherit;
}

.form-group input:focus {
  border-color: var(--sky-500);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
  background: white;
}

.form-group input.input-error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.field-error {
  display: block;
  font-size: 0.78rem;
  color: #ef4444;
  margin-top: 0.3rem;
  min-height: 1rem;
}

.modal-privacy {
  font-size: 0.75rem;
  color: var(--slate-400);
  margin-bottom: 1rem;
  line-height: 1.4;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

@media (max-width: 480px) {
  .modal { padding: 1.5rem; }
  .form-row { grid-template-columns: 1fr; }
}
