/* ============================================================================
   FaYu · Design System
   ============================================================================
   Source de vérité visuelle pour les nouvelles pages /app/student/ et
   /app/admin/. À importer EN PREMIER avant tout autre CSS.
   ============================================================================
*/

/* ──────────────────────────────────────────────────────────────────────────
   1. RESET & BASE
   ────────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; }
img { max-width: 100%; height: auto; display: block; }

/* ──────────────────────────────────────────────────────────────────────────
   2. TOKENS · Tokens partagés (typo, spacing, radius, transitions)
   ────────────────────────────────────────────────────────────────────────── */
:root {
  /* Typo */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-cn:   "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-serif: "Playfair Display", Georgia, serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, Consolas, monospace;

  /* Spacing scale (4 px base) */
  --s-1:  4px;
  --s-2:  8px;
  --s-3:  12px;
  --s-4:  16px;
  --s-5:  20px;
  --s-6:  24px;
  --s-8:  32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 999px;

  /* Transitions */
  --t-fast:   120ms ease;
  --t-normal: 200ms ease;
  --t-slow:   400ms ease;

  /* Z-index */
  --z-nav:    100;
  --z-modal:  1000;
  --z-toast:  2000;
}

/* ──────────────────────────────────────────────────────────────────────────
   3. PALETTE · « STUDENT » (Apple/Linear premium + touches Duolingo)
   ────────────────────────────────────────────────────────────────────────── */
body.theme-student {
  /* Surfaces */
  --bg:           #fafaf7;        /* fond très subtil chaud */
  --surface:      #ffffff;
  --surface-alt:  #f5f5f1;        /* cartes secondaires */
  --border:       #e7e5e0;
  --border-strong:#cfcdc6;

  /* Texte */
  --ink:          #1a1a17;        /* presque noir, légèrement chaud */
  --ink-mid:      #4a4945;
  --ink-soft:     #807d76;
  --ink-faint:    #b0ada5;

  /* Accents identité française */
  --bleu-france:  #002654;
  --bleu-clair:   #2b6cb0;
  --rouge-france: #ef4135;
  --or:           #c9a14a;

  /* Accents identité chinoise (mascotte Hanfu) */
  --rouge-hanfu:  #b91c1c;
  --rouge-soft:   #fef2f2;
  --or-doux:      #fef9e7;

  /* Accents Duolingo (gamification, sparingly) */
  --xp-green:     #58cc02;        /* le vert vif XP */
  --xp-green-d:   #4aa101;
  --streak-flame: #ff9600;        /* flamme du streak */
  --gem-blue:     #1cb0f6;        /* énergie / gems */
  --heart-red:    #ff4b4b;

  /* États sémantiques */
  --success:      #16a34a;
  --success-bg:   #dcfce7;
  --warning:      #ca8a04;
  --warning-bg:   #fef3c7;
  --danger:       #dc2626;
  --danger-bg:    #fee2e2;
  --info:         #2563eb;
  --info-bg:      #dbeafe;

  /* Ombres (Apple-like : très subtiles) */
  --shadow-sm:   0 1px 2px rgba(20, 20, 20, .06);
  --shadow-md:   0 4px 12px rgba(20, 20, 20, .07), 0 1px 3px rgba(20, 20, 20, .05);
  --shadow-lg:   0 12px 28px rgba(20, 20, 20, .10), 0 4px 10px rgba(20, 20, 20, .06);
  --shadow-xl:   0 24px 56px rgba(20, 20, 20, .14), 0 8px 20px rgba(20, 20, 20, .08);
  --shadow-focus: 0 0 0 3px rgba(43, 108, 176, .22);
}

/* ──────────────────────────────────────────────────────────────────────────
   4. PALETTE · « ADMIN » (Cyberpunk hacker terminal)
   ────────────────────────────────────────────────────────────────────────── */
body.theme-admin {
  /* Surfaces — noir bleuté profond */
  --bg:            #07090f;        /* presque noir, hint de bleu */
  --bg-deep:       #04060a;        /* encore plus sombre */
  --surface:       #0f1218;        /* cartes / panneaux */
  --surface-alt:   #161a23;
  --border:        #1f2533;
  --border-strong: #2d3548;

  /* Texte */
  --ink:           #d0d4dc;        /* gris clair, pas blanc pur */
  --ink-mid:       #8a92a6;
  --ink-soft:      #5b6478;
  --ink-faint:     #3a4055;

  /* Accents néon */
  --neon-green:    #00ff88;        /* vert terminal — couleur primaire */
  --neon-green-d:  #00cc6f;
  --neon-magenta:  #ff006e;        /* hot pink — accent secondaire */
  --neon-cyan:     #00d4ff;        /* info / data */
  --neon-amber:    #ffaa00;        /* warning */
  --neon-red:      #ff3860;        /* erreur / urgence */
  --neon-purple:   #b537f2;        /* highlight */

  /* États sémantiques (versions néon) */
  --success:       var(--neon-green);
  --success-bg:    rgba(0, 255, 136, .08);
  --warning:       var(--neon-amber);
  --warning-bg:    rgba(255, 170, 0, .08);
  --danger:        var(--neon-red);
  --danger-bg:     rgba(255, 56, 96, .08);
  --info:          var(--neon-cyan);
  --info-bg:       rgba(0, 212, 255, .08);

  /* Glow effects (signature cyberpunk) */
  --glow-green:    0 0 12px rgba(0, 255, 136, .35), 0 0 24px rgba(0, 255, 136, .15);
  --glow-magenta:  0 0 12px rgba(255, 0, 110, .35), 0 0 24px rgba(255, 0, 110, .15);
  --glow-cyan:     0 0 12px rgba(0, 212, 255, .35), 0 0 24px rgba(0, 212, 255, .15);

  /* Ombres (plus dramatiques) */
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, .5);
  --shadow-md:    0 4px 12px rgba(0, 0, 0, .6);
  --shadow-lg:    0 12px 28px rgba(0, 0, 0, .7);
  --shadow-focus: 0 0 0 2px var(--neon-green);

  /* Scanlines optionnelles (overlay subtil) */
  --scanline: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0) 0,
    rgba(255, 255, 255, 0) 2px,
    rgba(255, 255, 255, .015) 2px,
    rgba(255, 255, 255, .015) 4px
  );
}

/* ──────────────────────────────────────────────────────────────────────────
   5. TYPOGRAPHIE · Échelle modulaire
   ────────────────────────────────────────────────────────────────────────── */
.t-display { font-family: var(--font-serif); font-size: clamp(2.2rem, 4vw, 3.2rem); font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.t-h1      { font-family: var(--font-serif); font-size: clamp(1.8rem, 3vw, 2.4rem); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.t-h2      { font-family: var(--font-serif); font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.t-h3      { font-family: var(--font-sans); font-size: 1.2rem; font-weight: 700; line-height: 1.4; }
.t-body    { font-family: var(--font-sans); font-size: 1rem; font-weight: 400; line-height: 1.6; }
.t-small   { font-family: var(--font-sans); font-size: .88rem; font-weight: 400; line-height: 1.5; color: var(--ink-mid); }
.t-mono    { font-family: var(--font-mono); font-size: .92rem; }
.t-eyebrow { font-family: var(--font-sans); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); }

/* ──────────────────────────────────────────────────────────────────────────
   6. BUTTONS · Boutons unifiés
   ────────────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 10px 18px;
  border-radius: var(--r-full);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Student theme — boutons */
.theme-student .btn-primary {
  background: var(--bleu-france);
  color: white;
}
.theme-student .btn-primary:hover { background: #001b3d; transform: translateY(-1px); }

.theme-student .btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}
.theme-student .btn-secondary:hover { background: var(--surface-alt); }

.theme-student .btn-accent {
  background: var(--xp-green);
  color: white;
  box-shadow: 0 4px 0 0 var(--xp-green-d);
  font-weight: 800;
}
.theme-student .btn-accent:hover { transform: translateY(-1px); box-shadow: 0 6px 0 0 var(--xp-green-d); }
.theme-student .btn-accent:active { transform: translateY(2px); box-shadow: 0 1px 0 0 var(--xp-green-d); }

.theme-student .btn-ghost {
  background: transparent;
  color: var(--ink-mid);
}
.theme-student .btn-ghost:hover { color: var(--ink); background: var(--surface-alt); }

.theme-student .btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(220, 38, 38, .3);
}
.theme-student .btn-danger:hover { background: var(--danger); color: white; }

/* Admin theme — boutons cyberpunk */
.theme-admin .btn-primary {
  background: var(--neon-green);
  color: #000;
  font-weight: 700;
}
.theme-admin .btn-primary:hover { box-shadow: var(--glow-green); }

.theme-admin .btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
}
.theme-admin .btn-secondary:hover { border-color: var(--neon-green); color: var(--neon-green); }

.theme-admin .btn-ghost {
  background: transparent;
  color: var(--ink-mid);
  border-radius: var(--r-sm);
}
.theme-admin .btn-ghost:hover { color: var(--neon-green); }

.theme-admin .btn-danger {
  background: rgba(255, 56, 96, .12);
  color: var(--neon-red);
  border: 1px solid rgba(255, 56, 96, .4);
  border-radius: var(--r-sm);
}
.theme-admin .btn-danger:hover { background: var(--neon-red); color: white; }

/* ──────────────────────────────────────────────────────────────────────────
   7. CARDS · Cartes
   ────────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  box-shadow: var(--shadow-md);
}
.card-hover:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); transition: all var(--t-normal); }

.theme-admin .card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

/* Terminal panel (admin) */
.theme-admin .terminal-panel {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--s-5);
  font-family: var(--font-mono);
  position: relative;
  overflow: hidden;
}
.theme-admin .terminal-panel::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--scanline);
  pointer-events: none;
  opacity: .6;
}
.theme-admin .terminal-panel > * { position: relative; z-index: 1; }

/* ──────────────────────────────────────────────────────────────────────────
   8. INPUTS · Champs de formulaire
   ────────────────────────────────────────────────────────────────────────── */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:focus, .textarea:focus, .select:focus {
  outline: none;
  border-color: var(--bleu-france);
  box-shadow: var(--shadow-focus);
}

.theme-admin .input, .theme-admin .textarea, .theme-admin .select {
  background: var(--bg-deep);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-mono);
}
.theme-admin .input:focus, .theme-admin .textarea:focus, .theme-admin .select:focus {
  border-color: var(--neon-green);
  box-shadow: var(--glow-green);
}

/* ──────────────────────────────────────────────────────────────────────────
   9. XP & BADGES · Composants gamification (student)
   ────────────────────────────────────────────────────────────────────────── */
.xp-bar {
  height: 12px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--xp-green), var(--xp-green-d));
  border-radius: inherit;
  transition: width 800ms cubic-bezier(.16, 1, .3, 1);
}
.xp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: linear-gradient(135deg, var(--xp-green), var(--xp-green-d));
  color: white;
  border-radius: var(--r-full);
  font-weight: 800;
  font-size: .85rem;
  box-shadow: 0 2px 0 0 var(--xp-green-d);
}
.xp-pill::before { content: "✦"; }

.streak-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: linear-gradient(135deg, var(--streak-flame), #ff7300);
  color: white;
  border-radius: var(--r-full);
  font-weight: 800;
  font-size: .85rem;
}
.streak-pill::before { content: "🔥"; }

/* Badge custom (image custom dessinée par la prof) */
.badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 80px;
}
.badge-img {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 3px solid var(--or);
  box-shadow: var(--shadow-sm);
  object-fit: cover;
}
.badge.locked .badge-img { filter: grayscale(1) opacity(.3); }
.badge-label { font-size: .72rem; color: var(--ink-mid); text-align: center; }

/* ──────────────────────────────────────────────────────────────────────────
   10. ADMIN SPECIFIC · Composants terminal/data
   ────────────────────────────────────────────────────────────────────────── */
.theme-admin .stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
}
.theme-admin .stat-card::after {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent, var(--neon-green));
  opacity: .8;
}
.theme-admin .stat-card .stat-label {
  font-family: var(--font-mono);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--ink-soft);
  margin-bottom: var(--s-2);
}
.theme-admin .stat-card .stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--neon-green);
  line-height: 1;
}
.theme-admin .stat-card.alert .stat-value { color: var(--neon-red); }
.theme-admin .stat-card.warning .stat-value { color: var(--neon-amber); }
.theme-admin .stat-card.info .stat-value { color: var(--neon-cyan); }

/* Tag / pill cyber */
.theme-admin .tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  border-radius: 2px;
  background: rgba(0, 255, 136, .1);
  color: var(--neon-green);
  border: 1px solid rgba(0, 255, 136, .3);
}
.theme-admin .tag.warn   { background: rgba(255, 170, 0, .1);  color: var(--neon-amber); border-color: rgba(255, 170, 0, .3); }
.theme-admin .tag.danger { background: rgba(255, 56, 96, .1);  color: var(--neon-red);   border-color: rgba(255, 56, 96, .3); }
.theme-admin .tag.info   { background: rgba(0, 212, 255, .1);  color: var(--neon-cyan);  border-color: rgba(0, 212, 255, .3); }
.theme-admin .tag.muted  { background: rgba(255, 255, 255, .04); color: var(--ink-soft); border-color: var(--border); }

/* Curseur clignotant (admin) */
.theme-admin .cursor-blink::after {
  content: "▮";
  color: var(--neon-green);
  animation: cursor-blink 1s steps(2) infinite;
}
@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Glow text effet néon */
.theme-admin .glow-green   { color: var(--neon-green);   text-shadow: 0 0 8px rgba(0, 255, 136, .6); }
.theme-admin .glow-magenta { color: var(--neon-magenta); text-shadow: 0 0 8px rgba(255, 0, 110, .6); }
.theme-admin .glow-cyan    { color: var(--neon-cyan);    text-shadow: 0 0 8px rgba(0, 212, 255, .6); }

/* ──────────────────────────────────────────────────────────────────────────
   11. UTILITIES · Quelques classes utilitaires sobres
   ────────────────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }
.gap-6 { gap: var(--s-6); }

.mt-1 { margin-top: var(--s-1); } .mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); } .mt-8 { margin-top: var(--s-8); }
.mb-1 { margin-bottom: var(--s-1); } .mb-2 { margin-bottom: var(--s-2); } .mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); } .mb-8 { margin-bottom: var(--s-8); }

.text-center { text-align: center; }
.text-soft { color: var(--ink-soft); }
.text-mid { color: var(--ink-mid); }

.muted { opacity: .7; }
.hidden { display: none !important; }
.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;
}

/* ──────────────────────────────────────────────────────────────────────────
   12. ANIMATIONS RÉUTILISABLES
   ────────────────────────────────────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop-in {
  0%   { opacity: 0; transform: scale(.92); }
  60%  { opacity: 1; transform: scale(1.04); }
  100% { transform: scale(1); }
}
.anim-fade-in { animation: fade-in .35s ease both; }
.anim-pop-in  { animation: pop-in .45s cubic-bezier(.16, 1, .3, 1) both; }

/* Respecte « reduced motion » */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
