/* ===== English A1 — Design System ===== */
:root {
  --indigo: #6366F1;
  --indigo-dark: #4F46E5;
  --indigo-shadow: #3730A3;
  --indigo-light: #EEF2FF;

  --emerald: #10B981;
  --emerald-dark: #059669;
  --emerald-light: #D1FAE5;

  --rose: #F43F5E;
  --rose-dark: #BE123C;
  --rose-light: #FFE4E6;

  --amber: #F59E0B;
  --amber-dark: #D97706;
  --amber-light: #FEF3C7;

  --violet: #8B5CF6;
  --violet-dark: #6D28D9;
  --violet-light: #EDE9FE;

  --sky: #0EA5E9;
  --sky-dark: #0284C7;
  --sky-light: #E0F2FE;

  --orange: #F97316;
  --orange-dark: #EA580C;
  --orange-light: #FFEDD5;

  --teal: #14B8A6;
  --teal-dark: #0F766E;
  --teal-light: #CCFBF1;

  --bg: #F1F5F9;
  --surface: #FFFFFF;
  --text: #0F172A;
  --muted: #64748B;
  --faint: #94A3B8;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  --font: "Nunito", system-ui, -apple-system, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 28px;

  --shadow-sm: 0 1px 3px rgba(15,23,42,0.07), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.09), 0 2px 4px rgba(15,23,42,0.05);
  --shadow-lg: 0 10px 28px rgba(15,23,42,0.12), 0 4px 8px rgba(15,23,42,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;       /* altura real en móvil (descuenta la barra del navegador) */
  overflow: hidden;
}

/* ── App Shell ──────────────────────────────────── */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;           /* móvil: usa la altura visible real */
  overflow: hidden;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 50;
}

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 210px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 0;
  flex-shrink: 0;
  /* Permite hacer scroll cuando hay muchos ítems (sino los últimos quedaban
     fuera de alcance). */
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,.18) transparent;
  transition: width 0.2s ease, transform 0.25s ease;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,.18); border-radius: 4px;
  border: 2px solid transparent; background-clip: content-box;
}
.sidebar.collapsed { width: 68px; }

/* ── Mobile hamburger button (oculto en desktop) ─── */
.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 18px;
  color: var(--indigo);
  align-items: center;
  justify-content: center;
}

/* ── Backdrop oscuro detrás del sidebar abierto en móvil ─── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 99;
}

/* ─────────────────────────────────────────────────
   Responsive: tablet (≤1024px) → sidebar siempre
   en modo "iconos" (sin importar preferencia de
   usuario), ocultamos el botón de toggle.
   ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar:not(.mobile-open) {
    width: 68px !important;
  }
  .sidebar:not(.mobile-open) .nav-label,
  .sidebar:not(.mobile-open) .nav-section-label {
    display: none;
  }
  .sidebar:not(.mobile-open) .nav-item,
  .sidebar:not(.mobile-open) .sidebar-toggle {
    padding: 11px 0;
    justify-content: center;
    gap: 0;
  }
  .sidebar:not(.mobile-open) .nav-icon,
  .sidebar:not(.mobile-open) .sidebar-toggle-icon {
    width: auto;
  }
  .sidebar:not(.mobile-open) .sidebar-toggle {
    display: none;
  }
}

/* ─────────────────────────────────────────────────
   Responsive: móvil (≤640px) → sidebar oculto,
   se abre como overlay deslizando desde la izquierda.
   Aparece el botón de hamburguesa en el header.
   ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  .mobile-menu-btn {
    display: inline-flex;
    margin-right: 8px;
  }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 240px !important;
    z-index: 100;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.2);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.mobile-open .nav-label,
  .sidebar.mobile-open .nav-section-label {
    display: block;
  }
  .sidebar.mobile-open .nav-item,
  .sidebar.mobile-open .sidebar-toggle {
    padding: 11px 20px;
    justify-content: flex-start;
    gap: 12px;
  }
  .sidebar.mobile-open .sidebar-toggle {
    display: flex;
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .main-content {
    /* pequeño respiro inferior (el footer ya se ve gracias al dvh) */
    padding: 20px 24px 28px !important;
  }
  .app-header {
    padding: 10px 16px !important;
    height: 58px;
  }
  .logo {
    font-size: 15px !important;
  }
  /* En móvil solo se ve la mascota (Grumpy); se oculta el texto de la marca. */
  .brand-name {
    display: none;
  }
  /* Lección: compactar barra superior, cuerpo y footer; permitir wrap */
  .lesson-topbar {
    padding: 12px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .lesson-body {
    padding: 24px 24px;
  }
  .feedback-footer {
    padding: 14px 16px;
    gap: 10px;
    flex-wrap: wrap;
  }
  /* Botón avanzar (CONTINUAR/TERMINAR) a ancho completo en móvil */
  .feedback-footer .btn-lg {
    width: 100% !important;
    padding: 14px 16px !important;
  }
}

/* ─────────────────────────────────────────────────
   Móviles muy pequeños (≤ 480px): compactar header,
   pills y paddings para evitar desbordes horizontales.
   ───────────────────────────────────────────────── */
@media (max-width: 480px) {
  .app-header {
    padding: 8px 12px !important;
    gap: 6px;
  }
  /* Píldoras + avatar + Salir: misma altura (32px) para un header uniforme */
  .app-header .stat-pill {
    height: 32px;
    padding: 0 9px !important;
    font-size: 12.5px !important;
    gap: 4px;
  }
  .header-avatar {
    width: 32px !important;
    height: 32px !important;
    font-size: 14px !important;
  }
  .logout-btn {
    height: 32px;
    padding: 0 9px !important;
    font-size: 12px !important;
  }
  .logo {
    font-size: 14px !important;
    gap: 6px !important;
  }
  .main-content {
    padding: 16px 24px 28px !important;
  }
  .lesson-body {
    padding: 20px 24px;
  }
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* ── Logo ───────────────────────────────────────── */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
  color: var(--indigo);
  letter-spacing: -0.3px;
}

/* ── Stat Pills ─────────────────────────────────── */
.stat-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;                 /* misma altura que el avatar → header uniforme */
  padding: 0 14px;
  border-radius: var(--r-md);
  font-weight: 800;
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;          /* evita que "10 XP" salte a 2 líneas */
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
}

/* Avatar y botón Salir del header — misma altura que las píldoras (uniforme). */
.header-avatar { width: 36px; height: 36px; box-sizing: border-box; flex-shrink: 0; }
.logout-btn {
  display: inline-flex;
  align-items: center;
  height: 36px;
  box-sizing: border-box;
}

/* ── Sidebar Nav ────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 20px;
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  color: var(--muted);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  transition: all 0.12s ease;
  position: relative;
  border-radius: 0;
}
.nav-item:hover { color: var(--text); background: var(--bg); }
.nav-item.active {
  color: var(--indigo);
  background: var(--indigo-light);
  font-weight: 800;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--indigo);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  font-size: 18px;
  width: 28px;
  display: inline-flex;
  justify-content: center;
  flex-shrink: 0;
}
.nav-label { white-space: nowrap; overflow: hidden; font-size: 13px; }

.nav-section-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-toggle {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  width: 100%;
  text-align: left;
  transition: all 0.12s ease;
}
.sidebar-toggle:hover { color: var(--text); background: var(--bg); }
.sidebar-toggle-icon {
  font-size: 18px;
  width: 28px;
  display: inline-flex;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 900;
  color: var(--indigo);
}

/* Collapsed state — hide text, keep icons centered */
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section-label {
  display: none;
}
.sidebar.collapsed .nav-item,
.sidebar.collapsed .sidebar-toggle {
  padding: 11px 0;
  justify-content: center;
  gap: 0;
}
.sidebar.collapsed .nav-icon,
.sidebar.collapsed .sidebar-toggle-icon {
  width: auto;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.12s ease;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  user-select: none;
}
.btn-lg { padding: 14px 28px; font-size: 15px; border-radius: var(--r-lg); width: 100%; }

.btn-primary {
  background: var(--indigo);
  color: white;
  box-shadow: 0 4px 0 var(--indigo-shadow);
}
.btn-primary:hover { background: var(--indigo-dark); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--indigo-shadow); }

.btn-success {
  background: var(--emerald);
  color: white;
  box-shadow: 0 4px 0 var(--emerald-dark);
}
.btn-success:hover { filter: brightness(1.06); }
.btn-success:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--emerald-dark); }

.btn-danger {
  background: var(--rose);
  color: white;
  box-shadow: 0 4px 0 var(--rose-dark);
}
.btn-danger:hover { filter: brightness(1.06); }
.btn-danger:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--rose-dark); }

.btn-ghost {
  background: white;
  color: var(--muted);
  border: 2px solid var(--border);
  box-shadow: 0 2px 0 var(--border-strong);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-ghost:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--border-strong); }

.btn-violet {
  background: var(--violet);
  color: white;
  box-shadow: 0 4px 0 var(--violet-dark);
}
.btn-violet:hover { filter: brightness(1.06); }
.btn-violet:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--violet-dark); }

.btn:disabled {
  background: var(--border) !important;
  color: var(--faint) !important;
  cursor: not-allowed !important;
  box-shadow: 0 2px 0 var(--border-strong) !important;
  transform: none !important;
}

/* ── Choice Cards ───────────────────────────────── */
.choice-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.12s ease;
  font-weight: 700;
  font-size: 15px;
  user-select: none;
  text-align: left;
}
.choice-card:hover { border-color: var(--indigo); background: var(--indigo-light); }
.choice-card.selected { border-color: var(--indigo); background: var(--indigo-light); color: var(--indigo-dark); }
.choice-card.correct { border-color: var(--emerald); background: var(--emerald-light); color: var(--emerald-dark); }
.choice-card.wrong { border-color: var(--rose); background: var(--rose-light); color: var(--rose-dark); }

/* ── Progress Bar ───────────────────────────────── */
.progress-bar {
  height: 10px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--indigo);
  border-radius: 999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.progress-fill::after {
  content: '';
  position: absolute;
  top: 2px; left: 6px; right: 6px; height: 3px;
  background: rgba(255,255,255,0.35);
  border-radius: 999px;
}

/* ── Unit Cards (Home) ──────────────────────────── */
.unit-card {
  background: var(--surface);
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.unit-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.unit-card-header {
  padding: 20px 22px 18px;
  color: white;
}

.unit-card-body { padding: 18px 22px 20px; }

/* Lesson row inside unit card */
.lesson-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
}
.lesson-row:last-child { border-bottom: none; }

/* ── Lesson Screen ──────────────────────────────── */
.lesson-layout {
  height: 100vh;
  height: 100dvh;           /* fija la altura para que el cuerpo scrollee y el footer quede visible */
  background: white;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lesson-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
}

.lesson-body {
  flex: 1;
  min-height: 0;            /* permite que el área de ejercicios scrollee dentro de la lección */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
}

.exercise-wrap {
  width: 100%;
  max-width: 640px;
}

.lesson-footer {
  border-top: 1px solid var(--border);
  padding: 16px 32px;
}

/* ── Speaker button ─────────────────────────────── */
.speaker-btn {
  width: 56px;
  height: 56px;
  border-radius: var(--r-lg);
  background: var(--sky);
  border: none;
  box-shadow: 0 4px 0 var(--sky-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: filter 0.1s;
}
.speaker-btn:hover { filter: brightness(1.08); }
.speaker-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--sky-dark); }

/* ── Flashcard ──────────────────────────────────── */
.flashcard-container {
  perspective: 1000px;
  max-width: 420px;
  margin: 0 auto;
}
.flashcard {
  width: 100%;
  aspect-ratio: 3/2;
  transform-style: preserve-3d;
  transition: transform 0.5s;
  cursor: pointer;
  position: relative;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--r-xl);
  display: flex;
  flex-direction: column;
  padding: 28px;
}
.flashcard-back {
  transform: rotateY(180deg);
  background: white;
  border: 3px solid var(--indigo);
  box-shadow: 0 6px 0 var(--indigo-light);
}

/* ── Chat (Tutor) ───────────────────────────────── */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-input-row {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
}
.chat-input {
  flex: 1;
  padding: 11px 16px;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.12s;
}
.chat-input:focus { border-color: var(--indigo); }

/* ── Feedback Footer (Lesson) ───────────────────── */
.feedback-footer {
  padding: 18px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ── Animations ─────────────────────────────────── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.shake { animation: shake 0.4s; }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fade-up 0.28s ease-out; }

@keyframes bounce-in {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.bounce-in { animation: bounce-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
.breathe { animation: breathe 3s ease-in-out infinite; }

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── reCAPTCHA v3 ───────────────────────────────────
   Ocultamos el badge flotante (choca con el botón de soporte).
   PERMITIDO por Google siempre que el aviso de reCAPTCHA esté visible
   en el formulario de login (ya lo está: "Protegido por reCAPTCHA…").
   ─────────────────────────────────────────────────── */
.grecaptcha-badge {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}
