/* Mode sombre central (tous les métiers) : palette et retouches manuelles.
 * Activé par <html data-color="dark"> (bouton ◐ de la barre du haut ; clair par défaut), posé par
 * color-scheme.js pour les comptes connectés seulement. Les couleurs « en dur » des feuilles de l'application
 * sont converties dans dark.css (généré par scripts/generate-dark-css.mjs).
 * Un métier peut ajuster ses accents avec html[data-metier="…"][data-color="dark"] dans sa propre feuille. */
html[data-color="dark"] {
  color-scheme: dark;
  --dk-bg: #0f1320;
  --dk-surface: #151a29;
  --dk-surface-2: #1b2133;
  --dk-ink: #eef1f8;
  --dk-muted: #a3abbe;
  --dk-line: #2a3146;
  --opus-tk-bg: #0f1320;
  --opus-tk-bg-soft: #121726;
  --opus-tk-surface: #1b2133;
  --opus-tk-line-soft: #232a3c;
  --opus-tk-line: #2a3146;
  --opus-tk-line-strong: #343c53;
  --opus-tk-subtle: #7d869a;
  --opus-tk-muted: #a3abbe;
  --opus-tk-muted-strong: #b4bccd;
  --opus-tk-ink-2: #c9d0de;
  --opus-tk-ink-3: #d8deea;
  --opus-tk-ink: #eef1f8;
  --opus-tk-slate-900: #eef1f8;
  /* Violet OPUS : plus lumineux pour rester lisible sur fond sombre */
  --opus-tk-violet-50: #1a1633;
  --opus-tk-violet-soft: #1f1a3d;
  --opus-tk-violet-100: #282050;
  --opus-tk-violet-200: #372b6b;
  --opus-tk-violet: #8b6cff;
  --opus-tk-violet-dark: #b9a6ff;
  --opus-tk-coral-soft: #3a1f1c;
  --opus-tk-coral-200: #5c2e28;
  --opus-tk-coral-dark: #ff9a8b;
  --opus-tk-mint-soft: #0f2e24;
  --opus-tk-mint-200: #1b4a3a;
  --opus-tk-mint-dark: #5fd3a6;
  --opus-tk-amber-soft: #33240f;
  --opus-tk-amber-200: #5a3d15;
  --opus-tk-amber-dark: #fbbf6a;
  --opus-tk-red-soft: #3a1a1a;
  --opus-tk-red-200: #5c2626;
  --opus-tk-red-dark: #ff8a80;
  --opus-tk-blue-soft: #12233a;
  --opus-tk-shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --opus-tk-shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}
html[data-color="dark"] body {
  background: var(--dk-bg);
  color: var(--dk-ink);
}
html[data-color="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
  background-color: var(--dk-surface-2);
  color: var(--dk-ink);
  border-color: var(--dk-line);
}
html[data-color="dark"] ::placeholder {
  color: #7d869a;
}
/* Styles écrits directement dans les éléments : seulement les fonds neutres (blanc, gris clair) et les
 * textes foncés neutres. Les encadrés colorés (avertissements…) restent clairs avec leur texte : lisibles. */
html[data-color="dark"] :is([style*="background:#fff;" i], [style*="background: #fff;" i], [style*="background-color:#fff;" i], [style*="background-color: #fff;" i], [style*="background:#ffffff;" i], [style*="background: #ffffff;" i], [style*="background-color:#ffffff;" i], [style*="background-color: #ffffff;" i], [style*="background:white;" i], [style*="background: white;" i], [style*="background-color:white;" i], [style*="background-color: white;" i], [style*="background:#fafafa;" i], [style*="background: #fafafa;" i], [style*="background:#f9f9f9;" i], [style*="background: #f9f9f9;" i], [style*="background:#f8f9fa;" i], [style*="background: #f8f9fa;" i], [style*="background:#f5f5f5;" i], [style*="background: #f5f5f5;" i], [style*="background:#f9fafb;" i], [style*="background: #f9fafb;" i], [style*="background:#f3f4f6;" i], [style*="background: #f3f4f6;" i], [style*="background:#f0f0f0;" i], [style*="background: #f0f0f0;" i], [style*="background:#eee;" i], [style*="background: #eee;" i], [style$="background:#fff" i], [style$="background: #fff" i], [style$="background:white" i], [style$="background: white" i], [style$="background:#ffffff" i], [style$="background: #ffffff" i]) {
  background: var(--dk-surface-2) !important;
}
html[data-color="dark"] :is([style*="color:#111" i], [style*="color: #111" i], [style*="color:#222" i], [style*="color: #222" i], [style*="color:#333" i], [style*="color: #333" i], [style*="color:#182033" i], [style*="color: #182033" i], [style*="color:#000" i], [style*="color: #000" i]):not([style*="background"]) {
  color: var(--dk-ink) !important;
}
/* Logo du haut éclairci */
html[data-color="dark"] .topbar .logo-word-bold,
html[data-color="dark"] .topbar .logo-word-light {
  color: var(--dk-ink);
}
/* Bandeau d'accueil plus profond (texte blanc bien lisible) */
html[data-color="dark"] body.opus-ui-v2 #dash .opus-v2-dashboard-hero {
  background:
    radial-gradient(circle at 12% 0%, rgba(139, 108, 255, .35), transparent 16rem),
    radial-gradient(circle at 88% 90%, rgba(255, 107, 87, .22), transparent 18rem),
    linear-gradient(120deg, #2a1d6b 0%, #3b2a8f 50%, #4a2a7a 100%);
  box-shadow: 0 22px 50px rgba(0, 0, 0, .45);
}
/* Contrat : reste une feuille blanche lisible (aperçu identique au PDF) */
html[data-color="dark"] :is(#orderMissionContractScroll, .opus-contract-document-host, .opus-contract-document) {
  background: #ffffff !important;
  color: #182033 !important;
  color-scheme: light;
}
html[data-color="dark"] .opus-contract-document :is(p, li, td, th, span, strong, em, h1, h2, h3, h4, div) {
  color: inherit;
}
html[data-color="dark"] .opus-contract-document :is(h1, h2, h3) {
  color: #1a2b4a !important;
}
/* Bandeau cookies : fond très sombre (le jeton slate-900 sert de couleur de texte en mode sombre) */
html[data-color="dark"] .cookie-banner {
  background: #0a0e18;
}

/* Bouton ◐ de la barre du haut (comptes connectés) */
.color-scheme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--opus-tk-line);
  background: var(--opus-tk-bg-soft);
  color: var(--opus-tk-ink);
  font-size: 16px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  margin-left: 8px;
  flex: 0 0 auto;
  touch-action: manipulation;
}
html.has-color-scheme-toggle .topbar-left {
  display: flex;
  align-items: center;
}
.topbar .color-scheme-toggle {
  /* Sans marge intérieure : le style général des boutons l'élargissait à 50 px et il mordait sur « OPUS Santé » (02/11/2026). */
  padding: 0 !important;
  background: var(--opus-tk-bg-soft) !important;
  color: var(--opus-tk-ink) !important;
  box-shadow: none !important;
}
@media (max-width: 400px) {
  .topbar .color-scheme-toggle {
    width: 32px;
    height: 32px;
    margin-left: 4px;
    font-size: 14px;
  }
}
