/* GED Active Répartition — feuille de style unique (aucun CDN, aucune chaîne de compilation). */
:root {
  --bleu-nuit: #1e3a5f;
  --accent: #2f6fb0;
  --accent-clair: #e3edf8;
  --fond: #f5f7fa;
  --surface: #ffffff;
  --texte: #1f2933;
  --texte-discret: #5f6b7a;
  --bordure: #d5dce4;
  --alerte: #b42318;
  --alerte-fond: #fdecea;
  --succes: #1d7a46;
  --succes-fond: #e6f4ec;
  --avertissement: #9a6700;
  --avertissement-fond: #fff4d6;
  --preprod: #b45309;          /* texte blanc : 5,0:1 (WCAG AA) */
  --rayon: 6px;
  --espace: 1rem;
  --police: "Segoe UI", "DejaVu Sans", "Liberation Sans", Arial, sans-serif;

  /* États : une couleur par état, la même partout (badges, listes, fiches). */
  --etat-BROUILLON: #6b7280;
  --etat-EN_VERIFICATION: #2f6fb0;
  --etat-EN_APPROBATION: #7c3aed;
  --etat-APPROUVE: #0e7490;
  --etat-EN_VIGUEUR: #1d7a46;
  --etat-A_REVISER: #b45309;
  --etat-PERIME: #7f1d1d;
  --etat-ABROGE: #86198f;      /* fuchsia : teinte franchement distincte de Périmé (rouge), texte blanc 8,2:1 */
  --etat-DETRUIT: #111827;
  --etat-ABANDONNE: #4b5563;   /* texte blanc : 7,6:1 ; bordure tiretée (≠ Brouillon) */
}

/* Leçon d’un autre outil : toute classe qui pose un display doit laisser gagner [hidden]. */
[hidden] { display: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: var(--police); color: var(--texte); background: var(--fond); line-height: 1.45; }
body.modale-ouverte { overflow: hidden; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; color: var(--bleu-nuit); margin: 0 0 var(--espace); }
h2 { font-size: 1.2rem; color: var(--bleu-nuit); }
.discret { color: var(--texte-discret); font-size: .9rem; }

/* Lien d’évitement : masqué visuellement, visible au focus clavier. */
.evitement { position: absolute; left: -9999px; top: 0; z-index: 200; background: #fff; color: var(--bleu-nuit);
  padding: .6rem 1rem; border: 3px solid #f2b705; font-weight: 700; }
.evitement:focus { left: .5rem; top: .5rem; }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.barre :focus-visible { outline-color: #fff; }
.contenu:focus { outline: none; }

.bandeau-preprod { background: var(--preprod); color: #fff; text-align: center; font-weight: 700; padding: .35rem; letter-spacing: .03em; }

.barre { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  background: var(--bleu-nuit); color: #fff; padding: .6rem var(--espace); }
.barre a { color: #fff; text-decoration: none; }
.barre-titre { font-weight: 700; font-size: 1.1rem; }
.barre-utilisateur { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.compteur { display: inline-block; min-width: 1.4rem; padding: 0 .35rem; border-radius: 999px; background: var(--alerte);
  color: #fff; font-size: .8rem; text-align: center; }
.en-ligne { display: inline; margin: 0; }

.navigation { display: flex; flex-wrap: wrap; gap: .25rem; background: var(--surface); border-bottom: 1px solid var(--bordure);
  padding: .35rem var(--espace); }
.navigation a { padding: .4rem .7rem; border-radius: var(--rayon); text-decoration: none; color: var(--bleu-nuit); }
.navigation a:hover { background: var(--accent-clair); }
.navigation a[aria-current="page"] { background: var(--accent); color: #fff; }

.contenu { max-width: 1280px; margin: 0 auto; padding: var(--espace); }
.pied { text-align: center; color: var(--texte-discret); font-size: .8rem; padding: 1.5rem var(--espace); }

.carte { background: var(--surface); border: 1px solid var(--bordure); border-radius: var(--rayon); padding: var(--espace);
  margin-bottom: var(--espace); }
.carte-erreur h1 { color: var(--alerte); }

.messages:empty { display: none; }
.message { padding: .6rem .8rem; border-radius: var(--rayon); margin: 0 0 .5rem; border: 1px solid var(--bordure); background: var(--surface); }
.message-success { background: var(--succes-fond); border-color: var(--succes); }
.message-error { background: var(--alerte-fond); border-color: var(--alerte); }
.message-warning { background: var(--avertissement-fond); border-color: var(--avertissement); }

/* Boutons */
.bouton { display: inline-block; padding: .5rem .9rem; border-radius: var(--rayon); border: 1px solid var(--accent);
  background: var(--accent); color: #fff; font: inherit; cursor: pointer; text-decoration: none; }
.bouton:hover { filter: brightness(1.08); }
.bouton-secondaire { background: var(--surface); color: var(--accent); }
.bouton-danger { background: var(--alerte); border-color: var(--alerte); }
.bouton-discret { background: transparent; border-color: rgba(255, 255, 255, .5); color: #fff; padding: .25rem .6rem; }
.bouton[disabled], .bouton[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* Formulaires : erreur sous le champ */
.champ { margin-bottom: .9rem; }
.champ label { display: block; font-weight: 600; margin-bottom: .25rem; }
.champ input[type="text"], .champ input[type="password"], .champ input[type="date"], .champ input[type="email"],
.champ input[type="search"], .champ input[type="number"], .champ select, .champ textarea {
  width: 100%; max-width: 40rem; padding: .5rem; border: 1px solid var(--bordure); border-radius: var(--rayon); font: inherit; background: #fff; }
.champ .aide { color: var(--texte-discret); font-size: .85rem; }
.champ .erreur, .erreurs-formulaire { color: var(--alerte); font-size: .9rem; margin: .25rem 0 0; }
.champ-en-erreur input, .champ-en-erreur select, .champ-en-erreur textarea { border-color: var(--alerte); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: var(--espace); }

/* Tableaux */
.tableau { width: 100%; border-collapse: collapse; background: var(--surface); }
.tableau th, .tableau td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--bordure); vertical-align: top; }
.tableau th { background: var(--accent-clair); color: var(--bleu-nuit); font-weight: 600; }
.tableau tr:hover td { background: #fafcff; }
.defilement { overflow-x: auto; }

/* Badges d’état */
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; color: #fff;
  background: var(--texte-discret); white-space: nowrap; }
.etat-BROUILLON { background: var(--etat-BROUILLON); }
.etat-EN_VERIFICATION { background: var(--etat-EN_VERIFICATION); }
.etat-EN_APPROBATION { background: var(--etat-EN_APPROBATION); }
.etat-APPROUVE { background: var(--etat-APPROUVE); }
.etat-EN_VIGUEUR { background: var(--etat-EN_VIGUEUR); }
.etat-A_REVISER { background: var(--etat-A_REVISER); }
.etat-PERIME { background: var(--etat-PERIME); }
.etat-ABROGE { background: var(--etat-ABROGE); }
.etat-DETRUIT { background: var(--etat-DETRUIT); }
.etat-ABANDONNE { background: var(--etat-ABANDONNE); outline: 1px dashed var(--etat-ABANDONNE); outline-offset: 2px; }

/* Fenêtre modale générique (signature, confirmations) */
.modale { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modale-fond { position: absolute; inset: 0; background: rgba(15, 23, 42, .55); }
.modale-boite { position: relative; background: var(--surface); border-radius: var(--rayon); padding: 1.25rem; width: min(36rem, 94vw);
  max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.modale-fermer { position: absolute; top: .4rem; right: .6rem; border: 1px solid var(--bordure); border-radius: var(--rayon);
  background: var(--surface); font-size: 1.5rem; line-height: 1; padding: .1rem .5rem; cursor: pointer; color: var(--texte-discret); }
.signification { background: var(--accent-clair); border-left: 4px solid var(--accent); padding: .6rem .8rem; margin: .8rem 0; }

.htmx-request .indicateur, .indicateur.htmx-request { opacity: 1; }
.indicateur { opacity: 0; transition: opacity .2s; }

@media (max-width: 900px) {
  .contenu { padding: .75rem; }
  .barre-utilisateur { gap: .6rem; }
}
/* Petit écran : la navigation tient sur une ligne qui défile (le lien courant est ramené à l’écran par ged.js). */
@media (max-width: 768px) {
  .navigation { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .navigation a { flex: 0 0 auto; white-space: nowrap; }
}
/* Tablette, écran tactile : cibles d’au moins 44 px (WCAG 2.5.5), écart entre actions voisines. */
@media (pointer: coarse) {
  .bouton, .bouton-petit, .navigation a, .barre a { min-height: 44px; display: inline-flex; align-items: center; }
  .bouton-discret { min-height: 44px; }
  .modale-fermer { min-width: 44px; min-height: 44px; }
  .actions-ligne { display: inline-flex; flex-wrap: wrap; gap: .75rem; }
  .barre-utilisateur { gap: .75rem; }
}
@media print {
  .barre, .navigation, .pied, .actions, .modale, .evitement { display: none !important; }
  body { background: #fff; }
}
