/* ============================================================================
   tokens.css — source unique des couleurs (audit design 01.09.2026)

   Remplace le bloc `:root{--bg:#0e1116;…}` qui était recopié à l'identique dans
   11 templates depuis la refonte sombre du 11.07.2026. Toute évolution de
   palette se fait désormais ICI, une seule fois.

   Chargement : TOUJOURS après theme.css.
       <link rel="stylesheet" href="/static/theme.css">
       <link rel="stylesheet" href="/static/tokens.css">
   theme.css garde ses composants (pastilles, toasts, boutons, skeletons,
   empty-state) mais ses couleurs sont réalimentées ici — sans cela ses valeurs
   claires d'origine (#dcfce7, #eceff1, #e5e7eb…) se posaient sur le fond sombre.

   Le sombre est le thème par défaut. Le clair reste disponible via
   <html data-theme="light"> (utilisé par les pages imprimables et le portail
   client, qui garde son propre parti pris dans client.css).
   ========================================================================= */

:root {
  /* --- Palette applicative (ex-bloc dupliqué) ----------------------------- */
  --bg:          #0e1116;
  --panel:       #161b22;
  --panel-2:     #1c232d;
  --panel-3:     #232b36;
  --line:        #2a323d;
  --text:        #e6edf3;
  --muted:       #8b949e;   /* texte secondaire — contraste 6,4:1 sur --panel */
  --muted-2:     #7d8590;   /* était #6e7681 = 3,4:1 sur --panel, sous le seuil AA,
                               alors qu'il portait 31 libellés de texte courant.
                               Relevé à 4,65:1 sur --panel, 5,1:1 sur --bg. */
  --accent:      #38BDF8;
  --accent-2:    #818CF8;
  --accent-soft: rgba(56,189,248,0.12);
  --green:       #3fb950;
  --red:         #f85149;
  --c-danger-fort: #da3633;   /* bouton « Je termine le tour » (briefing v2) */
  --yellow:      #d29922;
  --blue:        #58a6ff;

  /* Encre à poser SUR un aplat --accent (blanc = 1,9:1, illisible au soleil) */
  --on-accent:   #0e1116;

  /* Accent de marque du groupe — orange Innov-Concept, commun à innov-facture.
     Réservé à l'identité (logo, action principale d'authentification) ; le cyan
     reste l'accent applicatif de rapport-cff. */
  --marque:      #EC4F0F;
  --on-marque:   #231b0d;

  /* --- Réalimentation des tokens de theme.css ----------------------------- */
  --c-bg:            var(--bg);
  --c-surface:       var(--panel);
  --c-surface-2:     var(--panel-2);
  --c-border:        var(--line);
  --c-text:          var(--text);
  --c-text-muted:    var(--muted);
  --c-text-soft:     var(--muted-2);
  --c-primary:       var(--accent);
  --c-primary-dark:  #0ea5e9;
  --c-primary-light: var(--accent-soft);
  --c-focus:         var(--accent);

  --c-success:      var(--green);
  --c-success-bg:   rgba(63,185,80,0.15);
  --c-success-text: var(--green);
  --c-warn:         var(--yellow);
  --c-warn-bg:      rgba(210,153,34,0.15);
  --c-warn-text:    var(--yellow);
  --c-danger:       var(--red);
  --c-danger-bg:    rgba(248,81,73,0.15);
  --c-danger-text:  var(--red);
  --c-info:         var(--blue);
  --c-info-bg:      rgba(88,166,255,0.15);
  --c-info-text:    var(--blue);

  --c-dispo:      #f0b429;
  --c-dispo-bg:   rgba(240,180,41,0.15);
  --c-dispo-text: #f0b429;
}

/* --- Thème clair (impression, portail client) ------------------------------ */
:root[data-theme="light"] {
  --bg:          #f0f2f5;
  --panel:       #ffffff;
  --panel-2:     #fafafa;
  --panel-3:     #f3f4f6;
  --line:        #e5e7eb;
  --text:        #1a1a1a;
  --muted:       #5f6773;   /* 4,39:1 sur --panel-3 auparavant */
  --muted-2:     #9ca3af;
  --accent:      #4F46E5;
  --accent-2:    #6366f1;
  --accent-soft: rgba(79,70,229,0.10);
  --green:       #15803d;   /* #16a34a donnait 3,3:1 avec du blanc (.btn-success) */
  --red:         #dc2626;
  --c-danger-fort: #dc2626;
  --yellow:      #ea580c;
  --blue:        #2563eb;
  --on-accent:   #ffffff;

  --c-primary-dark:  #4338CA;
  --c-success-bg:   #dcfce7;
  --c-success-text: #166534;
  --c-warn-bg:      #ffedd5;
  --c-warn-text:    #9a3412;
  --c-danger-bg:    #fee2e2;
  --c-danger-text:  #991b1b;
  --c-info-bg:      #dbeafe;
  --c-info-text:    #1e40af;
  --c-dispo:      #b45309;
  --c-dispo-bg:   #fef3c7;
  --c-dispo-text: #92400e;
}

/* --- Correctifs transverses issus de l'audit ------------------------------- */

/* .pill-neutral, .btn-secondary et .skel portaient des couleurs claires en dur dans
   theme.css (#eceff1, #e5e7eb) : elles y consomment désormais les tokens ci-dessus. */

/* Contrôles natifs : sans accent-color, cases à cocher et boutons radio restent
   blancs et tranchent sur le fond sombre. */
input[type="checkbox"], input[type="radio"], progress, input[type="range"] {
  accent-color: var(--accent);
}

/* Anneau de focus : seuls 4 templates sur 22 en définissaient un ; ailleurs
   l'anneau par défaut du navigateur est invisible sur #0e1116. */
:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Mouvement réduit — aucun template ne le respectait. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Tableaux admin : 6 templates n'avaient aucune media query, leurs tableaux
   débordaient hors de l'écran sur mobile. */
@media (max-width: 760px) {
  .table-wrap, .tbl-wrap, .tbl-scroll, .scroll {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .table-wrap table, .tbl-wrap table, .tbl-scroll table, .scroll table { min-width: 620px; }
}
