/* =====================================================================
   DESIGN SYSTEM — JETONS (TOKENS)
   Palette Pro Dark par defaut (Nuit Profonde / Violet #8b5cf6),
   avec support complet des themes alternatifs (Classique Pro Or #d9a441,
   Cyber Noir, et Mode Clair) et accents dynamiques mixables.
   ===================================================================== */

:root {
  /* ---------- Theme par defaut (Midnight / Nuit Violette) ---------- */
  --ink-950: #070d18;
  --ink-900: #0b1120;   /* Fond principal body */
  --ink-800: #0f172a;   /* Fond section & header */
  --ink-700: #1e293b;   /* Fond de carte */
  --ink-600: #26354d;   /* Surface haute au survol */
  --ink-500: #334155;   /* Bordures */

  --bg-body: #0b1120;
  --bg-card: rgba(30, 41, 59, 0.72);
  --bg-card-hover: rgba(38, 53, 77, 0.85);
  --bg-glass: rgba(11, 17, 32, 0.88);

  /* ---------- Textes ---------- */
  --text-100: #f8fafc;
  --text-200: #cbd5e1;
  --text-300: #94a3b8;
  --text-muted: #94a3b8;

  /* ---------- Accent par defaut : Violet Electrique ---------- */
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  /* Version claire de l'accent (icones, lueurs) : elle EXISTE pour
     chaque accent ci-dessous. Sans elle, tous les var(--primary-bright,
     #c084fc) retombaient sur du violet clair quel que soit le theme. */
  --primary-bright: #a78bfa;
  --primary-glow: rgba(139, 92, 246, 0.45);
  --primary-soft: rgba(139, 92, 246, 0.12);
  --primary-line: rgba(139, 92, 246, 0.35);

  --secondary: #3b82f6;
  --secondary-dark: #2563eb;
  --secondary-glow: rgba(59, 130, 246, 0.4);
  --secondary-soft: rgba(59, 130, 246, 0.12);

  --accent: var(--primary);
  --accent-strong: var(--primary-dark);
  --accent-soft: var(--primary-soft);
  --accent-line: var(--primary-line);

  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  --gradient-hover: linear-gradient(135deg, #9d75f8 0%, #4f91f8 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);

  /* Bordures */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-glow: rgba(139, 92, 246, 0.45);
  --surface: rgba(255, 255, 255, 0.03);
  /* Fond un peu plus marque : remplace les anciens rgba(30,41,59,.6)
     codees en dur, qui restaient gris quel que soit le theme. */
  --surface-strong: rgba(255, 255, 255, 0.07);

  /* Etats */
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #3b82f6;
  --info-soft: rgba(59, 130, 246, 0.14);

  /* Typographie */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;
  --fs-3xl: 3.25rem;

  --lh-tight: 1.15;
  --lh-snug: 1.35;
  --lh-body: 1.65;
  --measure: 68ch;

  /* Grille & Espacements */
  --grid-cols: 4;
  --grid-gutter: 1.25rem;
  --grid-margin: 1.25rem;
  --grid-max: 75rem;
  --space: 0.5rem;
  --sp-1: calc(var(--space) * 1);
  --sp-2: calc(var(--space) * 2);
  --sp-3: calc(var(--space) * 3);
  --sp-4: calc(var(--space) * 4);
  --sp-5: calc(var(--space) * 5);
  --sp-6: calc(var(--space) * 6);
  --sp-8: calc(var(--space) * 8);
  --sp-10: calc(var(--space) * 10);
  --sp-12: calc(var(--space) * 12);
  --sp-16: calc(var(--space) * 16);

  /* Rayons & Ombres */
  --radius-sm: 8px;
  /* rayon intermediaire : utilise par .stat et .profile-highlight-item.
     Il manquait : ces elements se retrouvaient a angles CARRES. */
  --radius-md: 10px;
  --radius: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Hauteur de l'en-tete collee (sticky). Partaggee par le header ET
     par la barre de recherche, qui doit se coller JUSTE EN DESSOUS
     et non par-dessus (meme top: 0 = chevauchement garanti). */
  --header-h: 4.25rem;

  --shadow-1: 0 4px 15px -2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 15px 35px -5px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 10px 30px -5px rgba(139, 92, 246, 0.35);

  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 400ms;
  --ease-in: cubic-bezier(0, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.4, 0, 1, 1);
  --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* =====================================================================
   THEMES DE FOND ALTERNATIFS (Classes / Attributs data-theme sur html)
   ===================================================================== */

/* 1. Theme Classique Pro (L'ancienne version : Bleu Nuit Profond & Or) */
html[data-theme="classic-dark"] {
  --ink-950: #070f15;
  --ink-900: #0e181f;
  --ink-800: #12232e;
  --ink-700: #1a2f3d;
  --ink-600: #233e50;
  --ink-500: #30546c;

  --bg-body: #0e181f;
  --bg-card: rgba(18, 35, 46, 0.85);
  --bg-card-hover: rgba(26, 47, 61, 0.95);
  --bg-glass: rgba(14, 24, 31, 0.92);

  --text-100: #f4f8fb;
  --text-200: #c2d6e3;
  --text-300: #8ba5b5;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
}

/* Par defaut dans le theme Classique, l'accent est l'or d'origine sauf si modifie */
html[data-theme="classic-dark"]:not([data-accent]) {
  --primary: #d9a441;
  --primary-dark: #b8862b;
  --primary-glow: rgba(217, 164, 65, 0.45);
  --primary-soft: rgba(217, 164, 65, 0.14);
  --primary-line: rgba(217, 164, 65, 0.35);
  --secondary: #e6b85c;
  --gradient: linear-gradient(135deg, #d9a441 0%, #f59e0b 100%);
  --border-glow: rgba(217, 164, 65, 0.45);
}

/* 2. Theme Noir Cyber */
html[data-theme="cyber-black"] {
  --ink-950: #020408;
  --ink-900: #050810;
  --ink-800: #0a0f1d;
  --ink-700: #101728;
  --ink-600: #182238;
  --ink-500: #253350;

  --bg-body: #050810;
  --bg-card: rgba(16, 23, 40, 0.85);
  --bg-card-hover: rgba(24, 34, 56, 0.95);
  --bg-glass: rgba(5, 8, 16, 0.92);
}

/* 3. Theme Clair Pro (Harmonie orangée & solaire) */
html[data-theme="light-mode"] {
  --ink-950: #ffffff;
  --ink-900: #faf7f2;
  --ink-800: #f4ede3;
  --ink-700: #ffffff;
  --ink-600: #f8f4ee;
  --ink-500: #e2d7c7;

  --bg-body: #faf7f2;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --bg-glass: rgba(250, 247, 242, 0.94);

  --text-100: #0f172a;
  --text-200: #334155;
  --text-300: #64748b;
  --text-muted: #64748b;

  --border: rgba(180, 83, 9, 0.12);
  --border-strong: rgba(180, 83, 9, 0.22);
  --surface: rgba(217, 119, 6, 0.04);
  --surface-strong: rgba(217, 119, 6, 0.08);

  --shadow-1: 0 4px 15px -2px rgba(180, 83, 9, 0.08);
  --shadow-2: 0 15px 35px -5px rgba(180, 83, 9, 0.12);
}

/* =====================================================================
   COULEURS D'ACCENT MIXABLES (Attributs data-accent sur html)
   ===================================================================== */

/* Violet Electrique (defaut) */
html[data-accent="purple"] {
  --primary: #8b5cf6;
  --primary-dark: #7c3aed;
  --primary-bright: #a78bfa;
  --primary-glow: rgba(139, 92, 246, 0.45);
  --primary-soft: rgba(139, 92, 246, 0.14);
  --primary-line: rgba(139, 92, 246, 0.35);
  --secondary: #3b82f6;
  --gradient: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  --gradient-hover: linear-gradient(135deg, #9d75f8 0%, #4f91f8 100%);
  --border-glow: rgba(139, 92, 246, 0.45);
}

/* Or & Ambre Orangé Prestige */
html[data-accent="gold"] {
  --primary: #d97706;
  --primary-dark: #b45309;
  --primary-bright: #fbbf24;
  --primary-glow: rgba(217, 119, 6, 0.45);
  --primary-soft: rgba(245, 158, 11, 0.16);
  --primary-line: rgba(217, 119, 6, 0.38);
  --secondary: #ea580c;
  --gradient: linear-gradient(135deg, #d97706 0%, #ea580c 100%);
  --gradient-hover: linear-gradient(135deg, #e88a0c 0%, #f2620f 100%);
  --border-glow: rgba(217, 119, 6, 0.45);
}

/* Bleu Azur Tech */
html[data-accent="blue"] {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-bright: #60a5fa;
  --primary-glow: rgba(59, 130, 246, 0.45);
  --primary-soft: rgba(59, 130, 246, 0.14);
  --primary-line: rgba(59, 130, 246, 0.35);
  --secondary: #06b6d4;
  --gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 100%);
  --gradient-hover: linear-gradient(135deg, #4f91f8 0%, #0ec3e0 100%);
  --border-glow: rgba(59, 130, 246, 0.45);
}

/* Emeraude */
html[data-accent="emerald"] {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-bright: #34d399;
  --primary-glow: rgba(16, 185, 129, 0.45);
  --primary-soft: rgba(16, 185, 129, 0.14);
  --primary-line: rgba(16, 185, 129, 0.35);
  --secondary: #14b8a6;
  --gradient: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
  --gradient-hover: linear-gradient(135deg, #1ac488 0%, #1cc2b0 100%);
  --border-glow: rgba(16, 185, 129, 0.45);
}

/* Rose Neon */
html[data-accent="pink"] {
  --primary: #ec4899;
  --primary-dark: #db2777;
  --primary-bright: #f472b6;
  --primary-glow: rgba(236, 72, 153, 0.45);
  --primary-soft: rgba(236, 72, 153, 0.14);
  --primary-line: rgba(236, 72, 153, 0.35);
  --secondary: #8b5cf6;
  --gradient: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%);
  --gradient-hover: linear-gradient(135deg, #ef5aa3 0%, #9670f7 100%);
  --border-glow: rgba(236, 72, 153, 0.45);
}

/* Cyan Futuriste */
html[data-accent="cyan"] {
  --primary: #06b6d4;
  --primary-dark: #0891b2;
  --primary-bright: #22d3ee;
  --primary-glow: rgba(6, 182, 212, 0.45);
  --primary-soft: rgba(6, 182, 212, 0.14);
  --primary-line: rgba(6, 182, 212, 0.35);
  --secondary: #3b82f6;
  --gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-hover: linear-gradient(135deg, #0ec3e0 0%, #4f91f8 100%);
  --border-glow: rgba(6, 182, 212, 0.45);
}

/* Responsive Grille */
@media (min-width: 48em) {
  :root {
    --grid-cols: 8;
    --grid-gutter: 1.75rem;
    --grid-margin: 1.75rem;
  }
}

@media (min-width: 62em) {
  :root {
    --grid-cols: 12;
    --grid-gutter: 2rem;
    --grid-margin: 2rem;
  }
}

@media (min-width: 75em) {
  :root {
    --grid-margin: 3.5rem;
  }
}
/* =====================================================================
   STYLES GLOBAUX (bouton palette)
   Le style agit sur TOUT le site d'un coup : police, arrondis,
   densite des bordures, vitesse des animations. La COULEUR reste
   independante : c'est l'accent qui la porte, pas le style.

   On ne redefinit que des jetons : aucun composant n'a besoin d'etre
   touche, donc ajouter un style ne casse jamais la mise en page.
   ===================================================================== */

/* 1. SOUPLE — police geometrique, angles arrondis, animations vives. */
html[data-style="soft"] {
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 28px;
  --dur-fast: 180ms;
  --dur-base: 320ms;
  --dur-slow: 520ms;
  --ease-spring: cubic-bezier(0.34, 1.4, 0.5, 1);
}

/* 2. EDITORIAL — police a chasse, angles nets, mouvements discrets. */
html[data-style="editorial"] {
  --font-sans: 'Georgia', 'Iowan Old Style', 'Times New Roman', Times, serif;
  --radius-sm: 2px;
  --radius: 3px;
  --radius-lg: 4px;
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 300ms;
  --ease-spring: cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. TECHNIQUE — police monospacee, angles moyens, sans animation. */
html[data-style="technical"] {
  --font-sans: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Consolas,
    'Liberation Mono', monospace;
  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 8px;
  --dur-fast: 0ms;
  --dur-base: 0ms;
  --dur-slow: 0ms;
}

/* Le style technique neutralise les animations : on coupe aussi les
   transitions qui ne passent pas par un jeton, sinon le site bouge
   encore alors que le style promet le contraire. */
html[data-style="technical"] *,
html[data-style="technical"] *::before,
html[data-style="technical"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

/* =====================================================================
   MODE CLAIR — lisibilite du back-office

   Probleme : les tons de gris utilises en mode sombre deviennent
  Almost blancs sur fond clair. On remonte la hierarchie des textes
   ET on renforce les bordures, sinon tout devient un aplat gris.
   ===================================================================== */

html[data-theme="light-mode"] {
  /* Textes : on assombrit franchement le troisieme niveau. */
  --text-100: #0b1220;
  --text-200: #1e293b;
  --text-300: #475569;
  --text-muted: #475569;

  /* Fonds : le gris tres clair est reservé aux surfaces, pas au texte. */
  --surface: rgba(15, 23, 42, 0.045);
  --surface-strong: rgba(15, 23, 42, 0.09);

  /* Bordures nettement plus presentes : c'est ce qui fait le
     decalage entre les cartes sur fond clair. */
  --border: rgba(15, 23, 42, 0.14);
  --border-strong: rgba(15, 23, 42, 0.26);
}

/* ---------- Le back-office en mode clair ---------- */

html[data-theme="light-mode"] .admin-body,
html[data-theme="light-mode"] body {
  background: var(--bg-body);
  color: var(--text-200);
}

html[data-theme="light-mode"] .admin-side {
  background: var(--bg-card);
  border-right-color: var(--border-strong);
}

html[data-theme="light-mode"] .admin-link {
  color: var(--text-200);
}

html[data-theme="light-mode"] .admin-link:hover,
html[data-theme="light-mode"] .admin-link[aria-current="page"] {
  background: var(--primary-soft);
  color: var(--text-100);
}

html[data-theme="light-mode"] .card,
html[data-theme="light-mode"] .card-ultimate,
html[data-theme="light-mode"] .bulletins-card,
html[data-theme="light-mode"] .profile-card,
html[data-theme="light-mode"] .timeline-card,
html[data-theme="light-mode"] .admin-section,
html[data-theme="light-mode"] .stat-tile,
html[data-theme="light-mode"] .security-box,
html[data-theme="light-mode"] .table-wrap {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-100);
}

html[data-theme="light-mode"] .section-title,
html[data-theme="light-mode"] .card-title,
html[data-theme="light-mode"] .timeline-card h4,
html[data-theme="light-mode"] .timeline-card h3 {
  color: var(--text-100) !important;
}

html[data-theme="light-mode"] .section-lede,
html[data-theme="light-mode"] .bulletins-lede,
html[data-theme="light-mode"] .card-text,
html[data-theme="light-mode"] .card-desc {
  color: var(--text-200) !important;
}

/* Les textes de tableau et elements secondaires en mode clair */
html[data-theme="light-mode"] .table th {
  color: var(--text-100);
  background: var(--surface-strong);
}

html[data-theme="light-mode"] .table td {
  color: var(--text-100) !important;
  border-color: var(--border);
}

html[data-theme="light-mode"] .table td .muted {
  color: var(--text-300) !important;
}

html[data-theme="light-mode"] .muted,
html[data-theme="light-mode"] .admin-label,
html[data-theme="light-mode"] .stat-tile-label {
  color: var(--text-300);
}

html[data-theme="light-mode"] .notice {
  border-width: 1px;
}

html[data-theme="light-mode"] .notice-warning {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: #78350f;
}

html[data-theme="light-mode"] .notice-error {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: #7f1d1d;
}

html[data-theme="light-mode"] .notice-warning strong,
html[data-theme="light-mode"] .notice-warning a,
html[data-theme="light-mode"] .notice-error strong,
html[data-theme="light-mode"] .notice-error a {
  color: inherit;
  font-weight: 700;
}

html[data-theme="light-mode"] .input,
html[data-theme="light-mode"] .textarea,
html[data-theme="light-mode"] .select {
  background: #ffffff;
  border-color: var(--border-strong);
  color: var(--text-100);
}

html[data-theme="light-mode"] .input::placeholder,
html[data-theme="light-mode"] .textarea::placeholder {
  color: #64748b;
}

html[data-theme="light-mode"] .badge {
  border-color: var(--border-strong);
  color: var(--text-200);
}

/* ---------- Mode clair : pastilles et alertes lisibles ----------
   Les textes pales (#a7f3d0, #bfdbfe...) sont dessines pour le sombre :
   sur fond clair, ils deviennent des textes FONCES satures. Meme fond,
   meme bordure : seule l'encre change. */
html[data-theme="light-mode"] .notice-success {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: #065f46;
}

html[data-theme="light-mode"] .notice-info {
  background: var(--info-soft);
  border-color: var(--info);
  color: #1e40af;
}

html[data-theme="light-mode"] .badge-accent { color: var(--primary-dark); }
html[data-theme="light-mode"] .badge-tech,
html[data-theme="light-mode"] .badge-info { color: #1d4ed8; }
html[data-theme="light-mode"] .badge-ok { color: #047857; }
html[data-theme="light-mode"] .badge-warn { color: #92400e; }
html[data-theme="light-mode"] .badge-danger { color: #b91c1c; }

html[data-theme="light-mode"] .notice-success strong,
html[data-theme="light-mode"] .notice-success a,
html[data-theme="light-mode"] .notice-info strong,
html[data-theme="light-mode"] .notice-info a {
  color: inherit;
  font-weight: 700;
}
