@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
  /*
    R4/AC4.3 : branding GesPilot par défaut. Toutes les utilitaires `accent` de
    Tailwind lisent cette variable ; une entreprise qui a choisi sa couleur la
    redéfinit dans le <head> du layout (BrandingHelper#brand_style_tag), et
    c'est la SEULE chose qui change. Composantes RGB séparées par des espaces
    pour que les modificateurs d'opacité (bg-accent/10) restent valides.
  */
  /*
    Proposition « confort visuel » (call du 02/10/2026). Toutes les couleurs de
    Tailwind lisent ces variables. Le bloc `:root` reproduit À L'IDENTIQUE le
    rendu validé (gris Tailwind, navy, accent #2E7CF6) : sans attribut
    `data-theme` sur <html>, rien ne change, PDF compris. Les trois thèmes
    proposés redéfinissent les variables ; contrastes WCAG AA vérifiés par
    script (doc/memory/decisions.md, 05/10/2026). Le sélecteur s'applique à
    n'importe quel élément : la page Apparence s'en sert pour poser les quatre
    thèmes côte à côte.

    L'accent est déclaré à part, sous `:where(...)` (spécificité nulle) : la
    couleur de marque d'une entreprise, posée par BrandingHelper sur `:root`,
    l'emporte donc toujours, quel que soit le thème (AC4.1, AC4.3).
  */
  :root,
  [data-theme="defaut"] {
    --gray-50: 249 250 251;
    --gray-100: 243 244 246;
    --gray-200: 229 231 235;
    --gray-300: 209 213 219;
    --gray-400: 156 163 175;
    --gray-500: 107 114 128;
    --gray-600: 75 85 99;
    --gray-700: 55 65 81;
    --gray-800: 31 41 55;
    --gray-900: 17 24 39;
    --gray-950: 3 7 18;
    --color-white: 255 255 255;
    --color-card: 255 255 255;
    --color-surface: 247 249 251;
    --color-primary: 13 27 42;
    --color-primary-bg: 13 27 42;
    --color-secondary: 91 94 166;
    --color-success: 6 214 160;
    --color-warning: 255 179 71;
    --color-danger: 255 107 107;
    --color-info: 78 205 196;
    --color-success-text: 6 214 160;
    --color-warning-text: 255 179 71;
    --color-danger-text: 255 107 107;
    --color-info-text: 78 205 196;
    --accent-text-mix: 0%;
  }
  [data-theme="doux"] {
    --gray-50: 246 244 240;
    --gray-100: 238 235 229;
    --gray-200: 226 222 214;
    --gray-300: 205 199 188;
    --gray-400: 115 107 96;
    --gray-500: 104 96 85;
    --gray-600: 84 77 68;
    --gray-700: 65 59 52;
    --gray-800: 46 42 37;
    --gray-900: 32 29 25;
    --gray-950: 20 18 15;
    --color-white: 255 255 255;
    --color-card: 252 251 248;
    --color-surface: 241 238 232;
    --color-primary: 40 50 61;
    --color-primary-bg: 38 48 58;
    --color-secondary: 94 97 144;
    --color-success: 42 125 92;
    --color-warning: 183 121 31;
    --color-danger: 185 72 63;
    --color-info: 47 127 136;
    --color-success-text: 39 111 82;
    --color-warning-text: 138 90 20;
    --color-danger-text: 168 66 58;
    --color-info-text: 42 111 119;
    --accent-text-mix: 0%;
  }
  [data-theme="sombre"] {
    --gray-50: 35 42 51;
    --gray-100: 42 50 60;
    --gray-200: 52 61 72;
    --gray-300: 68 78 90;
    --gray-400: 152 163 176;
    --gray-500: 167 176 188;
    --gray-600: 188 196 206;
    --gray-700: 206 213 221;
    --gray-800: 222 227 233;
    --gray-900: 235 238 242;
    --gray-950: 245 247 249;
    --color-white: 255 255 255;
    --color-card: 28 34 41;
    --color-surface: 21 26 32;
    --color-primary: 228 233 239;
    --color-primary-bg: 16 21 27;
    --color-secondary: 163 166 224;
    --color-success: 28 127 91;
    --color-warning: 176 116 24;
    --color-danger: 194 75 69;
    --color-info: 37 128 138;
    --color-success-text: 95 205 163;
    --color-warning-text: 239 186 98;
    --color-danger-text: 242 145 139;
    --color-info-text: 111 200 209;
    --accent-text-mix: 45%;
  }
  [data-theme="net"] {
    --gray-50: 244 246 248;
    --gray-100: 235 238 242;
    --gray-200: 216 221 227;
    --gray-300: 194 201 209;
    --gray-400: 95 104 117;
    --gray-500: 83 92 105;
    --gray-600: 67 75 87;
    --gray-700: 51 58 68;
    --gray-800: 31 37 45;
    --gray-900: 20 25 32;
    --gray-950: 10 13 17;
    --color-white: 255 255 255;
    --color-card: 253 253 254;
    --color-surface: 236 239 243;
    --color-primary: 20 32 48;
    --color-primary-bg: 26 39 54;
    --color-secondary: 79 82 154;
    --color-success: 24 128 90;
    --color-warning: 178 110 0;
    --color-danger: 192 54 44;
    --color-info: 19 122 133;
    --color-success-text: 23 115 79;
    --color-warning-text: 135 84 0;
    --color-danger-text: 176 48 42;
    --color-info-text: 15 106 115;
    --accent-text-mix: 0%;
  }
  :where(:root, [data-theme="defaut"]) { --color-accent: 46 124 246; }
  :where([data-theme="doux"]) { --color-accent: 58 104 176; }
  :where([data-theme="sombre"]) { --color-accent: 59 108 208; }
  :where([data-theme="net"]) { --color-accent: 35 96 196; }
}

@layer base {
  /* Thème sombre : contrôles natifs (date, select, barres de défilement) en
     sombre, et champs sans fond explicite posés sur la couleur des cartes. */
  [data-theme="sombre"] {
    color-scheme: dark;
  }
  /* `:where` : spécificité nulle, une utilitaire posée sur le champ gagne. */
  :where([data-theme="sombre"]) :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea) {
    background-color: rgb(var(--color-card));
  }
}

/*
  Thèmes proposés : plancher de taille pour les micro-textes. 170 libellés de
  l'application sont en 9, 10 ou 11 px (en-têtes de section de la barre
  latérale, pastilles, mentions) ; on les remonte d'un cran sans toucher aux
  vues. Le thème actuel n'est pas concerné.
*/
[data-theme="doux"] .text-\[9px\], [data-theme="doux"] .text-\[10px\],
[data-theme="sombre"] .text-\[9px\], [data-theme="sombre"] .text-\[10px\],
[data-theme="net"] .text-\[9px\], [data-theme="net"] .text-\[10px\] {
  font-size: 11px;
}
[data-theme="doux"] .text-\[11px\],
[data-theme="sombre"] .text-\[11px\],
[data-theme="net"] .text-\[11px\] {
  font-size: 12px;
}

/*

@layer components {
  .btn-primary {
    @apply py-2 px-4 bg-blue-200;
  }
}

*/

/*
  Thème sombre : dans la barre latérale (et tout bloc `bg-primary`), les voiles
  blancs translucides (élément actif, pastille d'initiales) restent blancs. Ailleurs
  `bg-white` désigne la carte, devenue foncée.
*/
[data-theme="sombre"] .bg-primary .bg-white\/5 { background-color: rgb(255 255 255 / .05); }
[data-theme="sombre"] .bg-primary .bg-white\/10 { background-color: rgb(255 255 255 / .1); }
[data-theme="sombre"] .bg-primary .bg-white\/15 { background-color: rgb(255 255 255 / .15); }
[data-theme="sombre"] .bg-primary .hover\:bg-white\/5:hover { background-color: rgb(255 255 255 / .05); }
[data-theme="sombre"] .bg-primary .hover\:bg-white\/20:hover { background-color: rgb(255 255 255 / .2); }
