/**
 * IIe English LMS — Design System v52
 * ─────────────────────────────────────────────────────────────────
 * UX-V52-3  Design tokens expandidos
 * UX-V52-4  Componentes mobile-first
 * UX-V52-1  Acessibilidade (focus, reduced motion, contraste)
 * ─────────────────────────────────────────────────────────────────
 *
 * COMO INTEGRAR: Carregar APÓS iie-app.css
 */

/* ══════════════════════════════════════════════════════════════════
   1. DESIGN TOKENS EXPANDIDOS
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Spacing Scale ── */
  --sp-2xs: 2px;
  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;
  --sp-3xl: 48px;
  --sp-4xl: 64px;

  /* ── Typography Scale ── */
  --fs-2xs: .65rem;
  --fs-xs: .75rem;
  --fs-sm: .82rem;
  --fs-base: .92rem;
  --fs-md: 1rem;
  --fs-lg: 1.15rem;
  --fs-xl: 1.35rem;
  --fs-2xl: 1.65rem;
  --fs-3xl: 2.1rem;

  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-relaxed: 1.7;

  /* ── Breakpoints (custom properties for JS access) ── */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  /* ── Transitions ── */
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --dur-fast: .12s;
  --dur-normal: .2s;
  --dur-slow: .35s;

  /* ── Touch Targets ── */
  --touch-min: 44px;

  /* ── Z-index Scale ── */
  --z-base: 1;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-modal-backdrop: 300;
  --z-modal: 400;
  --z-popover: 500;
  --z-toast: 600;
  --z-tooltip: 700;

  /* ── Typography Scale — Extended (v57 additions) ── */
  --fs-label:   .60rem;   /* labels, badges, tiny metadata */
  --fs-caption: .72rem;   /* captions, secondary text */
  --fs-body:    .88rem;   /* standard card/list body text */
  --fs-title:   1.40rem;  /* section titles, card headlines */
  --fs-display: 2.00rem;  /* display headings */
  --fs-hero:    2.40rem;  /* hero / page-level headings */
  --fs-giant:   3.00rem;  /* oversized display numbers, stats */

  /* ── Z-index Scale — Extended (v57 additions) ── */
  /* Complementa a escala base (--z-base → --z-tooltip) */
  --z-panel:         510;  /* side panels, drawers */
  --z-onboarding:    800;  /* onboarding overlays */
  --z-live:          810;  /* live class modal */
  --z-overlay-guide: 820;  /* guided tour overlay */
  --z-alert:         840;  /* alert/error modals */
  --z-dialog:        860;  /* coach report, informational dialogs */
  --z-achievement:   880;  /* achievement/celebration overlays */
  --z-skip:          999;  /* skip links, floating XP, live toasts */

  /* ── Breakpoints — Canonical Set (v57 clarification) ── */
  /* xs: 480px | sm: 600px | md: 768px | lg: 900px | xl: 1024px | 2xl: 1280px */
  --bp-xs:   480px;
  --bp-sm:   600px;
  --bp-md:   768px;
  --bp-lg:   900px;
  --bp-xl:   1024px;
  --bp-2xl:  1280px;
}


/* ══════════════════════════════════════════════════════════════════
   2. TEMA OLED BLACK
   ══════════════════════════════════════════════════════════════════ */

[data-theme="oled"] {
  --bg: #000000;
  --bg2: #0A0A0A;
  --bg3: #1A1A1A;
  --surface: #0D0D0D;
  --surface2: #1A1A1A;
  --surface3: #2A2A2A;
  --border: rgba(255,255,255,.06);
  --border2: rgba(255,255,255,.04);
  --text: rgba(255,255,255,.95);
  --text2: rgba(255,255,255,.5);
  --muted: rgba(255,255,255,.28);
}

/* ══════════════════════════════════════════════════════════════════
   3. TEMA ALTO CONTRASTE
   ══════════════════════════════════════════════════════════════════ */

[data-theme="high-contrast"] {
  --bg: #000000;
  --bg2: #1A1A1A;
  --surface: #000000;
  --surface2: #1A1A1A;
  --border: #FFFFFF;
  --border2: #CCCCCC;
  --text: #FFFFFF;
  --text2: #EEEEEE;
  --muted: #CCCCCC;
  --red: #FF4444;
  --green: #44FF44;
  --amber: #FFFF44;
  --blue: #4444FF;
}

[data-theme="high-contrast"] .sp-back,
[data-theme="high-contrast"] .iie-btn,
[data-theme="high-contrast"] .mod-card {
  border-width: 2px;
}

/* ══════════════════════════════════════════════════════════════════
   4. FONT SIZE PREFERENCES
   ══════════════════════════════════════════════════════════════════ */

[data-font-size="small"]  { font-size: 14px; }
[data-font-size="normal"] { font-size: 16px; }
[data-font-size="large"]  { font-size: 18px; }
[data-font-size="xlarge"] { font-size: 20px; }


/* ══════════════════════════════════════════════════════════════════
   5. ACCESSIBILITY — FOCUS & MOTION
   ══════════════════════════════════════════════════════════════════ */

/* Focus ring visível APENAS com teclado */
.iie-keyboard-nav *:focus {
  outline: 3px solid var(--blue, #3B82F6);
  outline-offset: 2px;
}

/* Sem focus ring com mouse */
*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 3px solid var(--blue, #3B82F6);
  outline-offset: 2px;
}

/* Reduced motion: desabilita animações */
.iie-reduced-motion *,
.iie-reduced-motion *::before,
.iie-reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}

/* Skip link */
.iie-skip-link:focus {
  top: 0 !important;
}


/* ══════════════════════════════════════════════════════════════════
   6. COMPONENT LIBRARY
   ══════════════════════════════════════════════════════════════════ */

/* ── Buttons ── */
.iie-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  min-height: var(--touch-min);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--r-md, 14px);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.iie-btn:hover {
  background: var(--surface2);
  border-color: rgba(0,0,0,.15);
  transform: translateY(-1px);
}

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

.iie-btn-primary {
  background: var(--red, #C41230);
  color: #fff;
  border-color: transparent;
}

.iie-btn-primary:hover {
  background: var(--red2, #A00E28);
  border-color: transparent;
}

.iie-btn-sm {
  min-height: 36px;
  padding: var(--sp-sm) var(--sp-lg);
  font-size: var(--fs-xs);
}

.iie-btn-lg {
  min-height: 52px;
  padding: var(--sp-lg) var(--sp-2xl);
  font-size: var(--fs-md);
}

.iie-btn-icon {
  width: var(--touch-min);
  height: var(--touch-min);
  padding: 0;
  border-radius: var(--r-sm, 10px);
}

/* ── Cards ── */
.iie-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg, 18px);
  padding: var(--sp-xl);
  box-shadow: var(--s1);
  transition: all var(--dur-normal) var(--ease-out);
}

.iie-card:hover {
  box-shadow: var(--s2);
  border-color: rgba(0,0,0,.12);
}

.iie-card-clickable {
  cursor: pointer;
}

.iie-card-clickable:hover {
  transform: translateY(-2px);
}

/* ── Inputs ── */
.iie-input {
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--sp-md) var(--sp-lg);
  border-radius: var(--r-md, 14px);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-base);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.iie-input:focus {
  outline: none;
  border-color: var(--blue, #3B82F6);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.iie-input::placeholder {
  color: var(--muted);
}

/* ── Badges ── */
.iie-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--pill, 999px);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.iie-badge-success { background: rgba(34,197,94,.12); color: var(--green); }
.iie-badge-warning { background: rgba(245,158,11,.12); color: var(--amber); }
.iie-badge-danger  { background: rgba(196,18,48,.12);  color: var(--red); }
.iie-badge-info    { background: rgba(59,130,246,.12);  color: var(--blue); }

/* ── Modal ── */
.iie-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: var(--z-modal-backdrop);
  opacity: 0;
  visibility: hidden;
  transition: all var(--dur-normal);
  backdrop-filter: blur(4px);
}

.iie-modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.iie-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.95);
  z-index: var(--z-modal);
  background: var(--surface);
  border-radius: var(--r-xl, 24px);
  box-shadow: var(--s3);
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: all var(--dur-slow) var(--ease-out);
}

.iie-modal.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* ── Toast ── */
.iie-toast {
  position: fixed;
  bottom: var(--sp-xl);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: var(--z-toast);
  padding: var(--sp-md) var(--sp-xl);
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  box-shadow: var(--s2);
  opacity: 0;
  transition: all var(--dur-normal) var(--ease-out);
  max-width: 90vw;
}

.iie-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ══════════════════════════════════════════════════════════════════
   7. SRS STYLES
   ══════════════════════════════════════════════════════════════════ */

.srs-session {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--sp-xl);
}

.srs-header {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin-bottom: var(--sp-2xl);
}

.srs-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg3);
  border-radius: var(--pill);
  overflow: hidden;
}

.srs-progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: var(--pill);
  transition: width var(--dur-normal);
}

.srs-progress-text {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--text2);
  font-family: var(--mono);
}

.srs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-3xl) var(--sp-2xl);
  text-align: center;
  box-shadow: var(--s2);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-lg);
}

.srs-word {
  font-size: var(--fs-3xl);
  font-weight: var(--fw-extrabold);
  color: var(--text);
  letter-spacing: -.02em;
}

.srs-translation {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--blue);
  margin-top: var(--sp-lg);
  padding-top: var(--sp-lg);
  border-top: 1px solid var(--border);
}

.srs-example {
  font-size: var(--fs-sm);
  color: var(--text2);
  font-style: italic;
  max-width: 400px;
}

.srs-meta {
  display: flex;
  gap: var(--sp-lg);
  margin-top: var(--sp-sm);
  font-size: var(--fs-2xs);
  font-family: var(--mono);
  color: var(--muted);
}

.srs-audio-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--sp-sm);
  border-radius: 50%;
  transition: background var(--dur-fast);
}

.srs-audio-btn:hover {
  background: var(--surface2);
}

.srs-show-btn {
  display: block;
  width: 100%;
  max-width: 400px;
  margin: var(--sp-xl) auto 0;
  min-height: 52px;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  cursor: pointer;
  transition: background var(--dur-fast);
}

.srs-show-btn:hover {
  background: var(--red2);
}

.srs-rating {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-sm);
  margin-top: var(--sp-xl);
}

.srs-rate-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-md) var(--sp-sm);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--dur-fast);
  min-height: var(--touch-min);
}

.srs-rate-btn:hover {
  border-color: var(--blue);
  background: var(--surface2);
  transform: translateY(-2px);
}

.srs-rate-emoji { font-size: 1.3rem; }
.srs-rate-label { font-size: var(--fs-2xs); font-weight: var(--fw-bold); color: var(--text); }
.srs-rate-desc  { font-size: var(--fs-2xs); color: var(--muted); font-family: var(--mono); }

.srs-complete {
  text-align: center;
  padding: var(--sp-3xl) var(--sp-xl);
}

.srs-complete-icon { font-size: 3rem; margin-bottom: var(--sp-lg); }

.srs-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-md);
  margin: var(--sp-2xl) auto;
  max-width: 400px;
}

.srs-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-lg);
}

.srs-stat-value {
  font-size: var(--fs-2xl);
  font-weight: var(--fw-extrabold);
  color: var(--text);
}

.srs-stat-label {
  font-size: var(--fs-2xs);
  color: var(--text2);
  margin-top: 2px;
}

.srs-forecast {
  margin-top: var(--sp-2xl);
}

.srs-forecast-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--sp-sm);
  height: 80px;
  margin-top: var(--sp-md);
}

.srs-forecast-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.srs-forecast-bar {
  width: 28px;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.srs-forecast-label {
  font-size: var(--fs-2xs);
  color: var(--muted);
  font-family: var(--mono);
}

.srs-btn-back {
  margin-top: var(--sp-2xl);
  min-height: var(--touch-min);
  padding: var(--sp-md) var(--sp-2xl);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-weight: var(--fw-bold);
  cursor: pointer;
}


/* ══════════════════════════════════════════════════════════════════
   8. MOBILE-FIRST — BOTTOM NAVIGATION
   ══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .iie-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: var(--sp-sm) 0;
    padding-bottom: max(var(--sp-sm), env(safe-area-inset-bottom));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .iie-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
    padding: var(--sp-xs) var(--sp-sm);
    border: none;
    background: none;
    color: var(--text2);
    font-size: var(--fs-2xs);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: color var(--dur-fast);
    position: relative;
  }

  .iie-bottom-nav-item.active {
    color: var(--red);
  }

  .iie-bottom-nav-item .nav-icon {
    font-size: 1.2rem;
  }

  .iie-bottom-nav-item .nav-badge {
    position: absolute;
    top: 0;
    right: 4px;
    min-width: 16px;
    height: 16px;
    background: var(--red);
    color: #fff;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }

  /* Padding inferior para bottom nav não cobrir conteúdo */
  .sp-page,
  #main {
    padding-bottom: 80px !important;
  }
}

/* ══════════════════════════════════════════════════════════════════
   9. CONNECTION STATUS & PWA
   ══════════════════════════════════════════════════════════════════ */

#iie-connection-status {
  display: none;
  position: fixed;
  top: var(--topbar-h, 56px);
  left: 0;
  right: 0;
  z-index: var(--z-toast);
  padding: var(--sp-sm) var(--sp-lg);
  background: var(--amber);
  color: #000;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-align: center;
}

#iie-install-pwa {
  display: none;
}

/* ══════════════════════════════════════════════════════════════════
   10. SCREEN READER ONLY
   ══════════════════════════════════════════════════════════════════ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ══════════════════════════════════════════════════════════════════
   11. COMPATIBILITY ALIASES — vars usadas no iie-app.css que ainda
       não foram declaradas nos tokens centrais (adicionadas v52.1)
   ══════════════════════════════════════════════════════════════════ */

:root {
  /* ── Typography aliases ── */
  --font: 'Plus Jakarta Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;

  /* ── Border-radius aliases ── */
  --r-xs:  6px;
  --r-sm:  10px;
  --r-md:  14px;
  --r-lg:  18px;
  --r-xl:  24px;
  --pill:  999px;

  /* ── Color aliases ── */
  --red2:   #A00E28;

  /* ── Shadow scale ── */
  --s1: 0 1px 6px rgba(0,0,0,.05), 0 2px 10px rgba(0,0,0,.04);
  --s2: 0 2px 12px rgba(0,0,0,.06), 0 8px 28px rgba(0,0,0,.05);
  --s3: 0 4px 20px rgba(0,0,0,.08), 0 16px 48px rgba(0,0,0,.06);

  /* ── Topbar ── */
  --topbar-h: 56px;

  /* ── Glow (box-shadow accent) ── */
  /* --glow: alias para --glow-red; definido aqui para componentes que
     usam var(--glow) sem fallback */
  --glow: 0 4px 14px rgba(196, 18, 48, .4);

  /* ── Quick-card accent (dashboard cards dv2/nd) ── */
  /* --qc: cor de destaque dos cartões de ação rápida (top-border, badge) */
  --qc: #C41230;
  /* --qb: borda dos cartões de ação rápida */
  --qb: rgba(0, 0, 0, .08);
  /* --qbg: fundo dos cartões de ação rápida */
  --qbg: #f7f8fc;
  /* --qd: fundo alternativo dos cartões nd-quick */
  --qd: var(--surface2);

  /* ── IPC card accent ── */
  /* --ipc-c: borda lateral dos cards de progresso inline */
  --ipc-c: #C41230;

  /* ── dv3 accent color ── */
  --dv3-accent: #C41230;
  /* ── iie-accent (sidebar active indicator) ── */
  --iie-accent: #C41230;

  /* ── Toast duration ── */
  --toast-dur: 4s;
}

/* Dark mode overrides for aliases */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --s1: 0 1px 6px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.2);
    --s2: 0 2px 12px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.3);
    --s3: 0 4px 20px rgba(0,0,0,.45), 0 16px 48px rgba(0,0,0,.35);
  }
}
[data-theme="dark"] {
  --s1: 0 1px 6px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.2);
  --s2: 0 2px 12px rgba(0,0,0,.4), 0 8px 28px rgba(0,0,0,.3);
  --s3: 0 4px 20px rgba(0,0,0,.45), 0 16px 48px rgba(0,0,0,.35);
  --qb: rgba(255, 255, 255, .08);
  --qbg: #1c1c1e;
}
