/* ==========================================================================
   Assistant Juridique DCE — Demathieu Bard
   Charte graphique demathieu-bard.fr (thème 2025) :
     bleu nuit #111b40 · bleu roi #20388e · bleu-gris #68739c
     orange signature #ed6b27 (déclinaisons #f77632 / #f9935d)
     fond #f8f8f8 · gris #6b6b6b / #b3b3b3 · police Poppins (locale).
   Niveaux de risque (sémantique conservée) :
     ELEVE #d64541 · MOYEN #ed6b27 · FAIBLE #27ae60.
   AUCUNE ressource externe : Poppins est embarquée dans /static/fonts/.
   ========================================================================== */

/* --- Police Poppins (fichiers locaux, aucun CDN) -------------------------- */
@font-face {
  font-family: "Poppins";
  src: url("fonts/poppins-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("fonts/poppins-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("fonts/poppins-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* --- Jetons de la charte --------------------------------------------------- */
:root {
  /* couleurs extraites du site demathieu-bard.fr */
  --bleu-nuit: #111b40;
  --bleu-roi: #20388e;
  --bleu-gris: #68739c;
  --orange: #ed6b27;
  --orange-vif: #f77632;
  --orange-clair: #f9935d;
  --orange-fonce: #d55a1b;   /* survol des CTA */
  --fond: #f8f8f8;
  --gris: #6b6b6b;
  --gris-clair: #b3b3b3;
  --blanc: #ffffff;
  --texte: #1d2333;

  /* niveaux de risque (sémantique inchangée) */
  --rouge: #d64541;
  --vert: #27ae60;

  /* dérivés d'interface */
  --gris-bordure: #e2e4ea;
  --fond-bleu-doux: #eef1f9;
  --fond-orange-doux: #fdf0e7;
  --fond-vert-doux: #e8f4ec;
  --fond-rouge-doux: #fbecea;
  --vert-fonce: #1d6b40;
  --rouge-fonce: #93312d;
  --orange-texte: #9a4b14;
  --surlignage: #ffe9a8;
  --ombre-carte: 0 1px 3px rgba(17, 27, 64, 0.08);

  /* alias rétro-compatibles (anciens noms de variables) */
  --bleu-nuit-clair: var(--bleu-roi);
  --gris-fond: var(--fond);
  --gris-texte: var(--gris);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: "Poppins", system-ui, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.55;
}

/* --- Accessibilité : focus visibles ---------------------------------------- */
a:focus-visible, button:focus-visible, summary:focus-visible,
.bouton:focus-visible, .bouton-lien:focus-visible, .onglet:focus-visible {
  outline: 3px solid var(--orange-vif);
  outline-offset: 2px;
  border-radius: 3px;
}

/* --- Bandeau (bleu nuit + mot-marque typographique) ------------------------ */
.bandeau { background: var(--bleu-nuit); color: var(--blanc); }
.bandeau-interieur {
  max-width: 1240px; margin: 0 auto; padding: 0.65rem 1.2rem;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem;
}
.marque {
  display: flex; align-items: center; gap: 0.65rem;
  color: var(--blanc); text-decoration: none;
}
.marque-carre {
  flex: none; width: 0.8rem; height: 0.8rem;
  background: var(--orange); border-radius: 1px;
}
.marque-texte { display: flex; flex-direction: column; line-height: 1.25; }
.marque-nom {
  font-weight: 700; letter-spacing: 0.14em; font-size: 1.02rem;
  color: var(--blanc); white-space: nowrap;
}
.marque-sous {
  font-size: 0.72rem; font-weight: 400; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--bleu-gris);
}
/* anciens éléments de marque (rétro-compatibilité) */
.logo {
  background: var(--blanc); color: var(--bleu-nuit);
  font-weight: 700; padding: 0.15rem 0.45rem; border-radius: 4px; letter-spacing: 1px;
}
.titre-app { font-size: 1.05rem; font-weight: 600; }
.tiret { opacity: 0.5; }

.nav-principale { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.nav-principale a {
  color: var(--blanc); text-decoration: none; font-size: 0.93rem;
  opacity: 0.85; padding: 0.15rem 0;
}
.nav-principale a:hover { opacity: 1; text-decoration: underline; text-underline-offset: 5px; }
.nav-principale a.nav-active {
  opacity: 1; font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--orange);
  text-decoration-thickness: 2px; text-underline-offset: 6px;
}
.nav-principale .lien-admin {
  border: 1px solid var(--bleu-gris); border-radius: 5px; padding: 0.15rem 0.55rem;
}
.nav-principale .lien-admin:hover { border-color: var(--orange); text-decoration: none; }
.form-en-ligne { display: inline; margin: 0; }
.bouton-lien {
  background: none; border: none; color: var(--blanc); opacity: 0.85; cursor: pointer;
  font-size: 0.93rem; padding: 0; font-family: inherit;
}
.bouton-lien:hover { opacity: 1; text-decoration: underline; }

/* --- Structure ------------------------------------------------------------- */
.contenu { max-width: 1240px; margin: 1.3rem auto 2.5rem; padding: 0 1.2rem; }
.pied {
  border-top: 3px solid var(--orange); color: var(--gris);
  font-size: 0.8rem; text-align: center; padding: 0.9rem; background: var(--blanc);
}
.pied-marque { color: var(--bleu-nuit); font-weight: 600; }
.pied-note { color: var(--gris-clair); }
h2 { color: var(--bleu-nuit); font-weight: 700; margin: 0.3rem 0 0.6rem; }
h3 { color: var(--bleu-nuit); font-weight: 600; margin-top: 0; }
h4 { color: var(--bleu-roi); font-weight: 600; margin-bottom: 0.4rem; }
a { color: var(--bleu-roi); }
.texte-doux { color: var(--gris); font-size: 0.88rem; }
.fil-ariane { color: var(--gris); font-size: 0.85rem; margin: 0 0 0.2rem; }
.fil-ariane a { color: var(--gris); }
.lien-fort { color: var(--bleu-roi); font-weight: 600; text-decoration: none; }
.lien-fort:hover { text-decoration: underline; color: var(--orange-fonce); }
.obligatoire { color: var(--rouge); }

.entete-page {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.grille-deux { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .grille-deux { grid-template-columns: 1fr; } }

/* --- Cartes / messages ------------------------------------------------------ */
.carte {
  background: var(--blanc); border: 1px solid var(--gris-bordure);
  border-radius: 8px; box-shadow: var(--ombre-carte);
  padding: 1.1rem 1.3rem; margin-bottom: 1.1rem;
}
.carte-connexion {
  max-width: 420px; margin: 4rem auto;
  border-top: 4px solid var(--orange);
  box-shadow: 0 10px 30px rgba(17, 27, 64, 0.35);
}
.carte-formulaire { max-width: 860px; }
.etat-vide { text-align: center; color: var(--gris); padding: 2.2rem; }

/* pages de connexion : carte centrée sur fond bleu nuit */
body.page-connexion { background: var(--bleu-nuit); }
body.page-connexion .pied {
  background: transparent; border-top-color: rgba(255, 255, 255, 0.12);
  color: var(--bleu-gris);
}
body.page-connexion .pied-marque { color: var(--blanc); }
body.page-connexion .pied-note { color: var(--bleu-gris); }
.marque-connexion {
  display: flex; align-items: center; gap: 0.55rem;
  color: var(--bleu-nuit); font-weight: 700; letter-spacing: 0.14em;
  font-size: 1.05rem; margin-bottom: 1rem;
}

.zone-messages { max-width: 1240px; margin: 0.6rem auto 0; padding: 0 1.2rem; }
.flash {
  background: var(--fond-vert-doux); border: 1px solid var(--vert); color: var(--vert-fonce);
  border-radius: 6px; padding: 0.5rem 0.9rem; margin-bottom: 0.6rem; font-size: 0.92rem;
}
.flash-erreur { background: var(--fond-rouge-doux); border-color: var(--rouge); color: var(--rouge-fonce); }
.flash-avertissement { background: var(--fond-orange-doux); border-color: var(--orange); color: var(--orange-texte); }

/* --- Formulaires ------------------------------------------------------------ */
label { display: block; margin: 0.8rem 0 0.25rem; font-weight: 600; color: var(--bleu-nuit); }
input[type="text"], input[type="email"], input[type="password"],
select, textarea {
  width: 100%; padding: 0.45rem 0.6rem; border: 1px solid var(--gris-bordure);
  border-radius: 6px; font: inherit; background: var(--blanc); color: var(--texte);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--orange); outline-offset: -1px;
  border-color: var(--orange);
}
textarea { resize: vertical; }
input[type="file"] { margin: 0.2rem 0; }
.filtre-case { font-weight: 400; display: inline-flex; align-items: center; gap: 0.35rem; }

/* --- Boutons : primaire orange, secondaire contour bleu roi ------------------ */
.bouton {
  display: inline-block; background: var(--blanc); color: var(--bleu-roi);
  border: 1px solid var(--bleu-roi); border-radius: 6px; cursor: pointer;
  padding: 0.45rem 1rem; font: inherit; font-weight: 600; text-decoration: none;
}
.bouton:hover { background: var(--fond-bleu-doux); }
.bouton-principal { background: var(--orange); border-color: var(--orange); color: var(--blanc); }
.bouton-principal:hover { background: var(--orange-fonce); border-color: var(--orange-fonce); }
.bouton-grand { padding: 0.7rem 1.4rem; }
.bouton[disabled], button[disabled] { opacity: 0.45; cursor: not-allowed; }
.barre-actions { display: flex; gap: 0.6rem; margin-top: 1rem; align-items: center; flex-wrap: wrap; }

/* --- Tableaux ---------------------------------------------------------------- */
.table-liste { width: 100%; border-collapse: collapse; background: var(--blanc); }
.table-liste th, .table-liste td {
  text-align: left; padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--gris-bordure);
  vertical-align: top;
}
.table-liste thead th {
  background: var(--bleu-nuit); color: var(--blanc); font-size: 0.82rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.table-liste tbody tr:hover { background: var(--fond); }
.ligne-inactive { opacity: 0.55; }
.table-fiche th { text-align: left; color: var(--gris); font-weight: 600; padding: 0.3rem 0.8rem 0.3rem 0; white-space: nowrap; }
.table-fiche td { padding: 0.3rem 1.2rem 0.3rem 0; }
.col-note, .col-oui-non { width: 8rem; white-space: nowrap; }
.commentaire-dossier { background: var(--fond); border-left: 3px solid var(--orange); padding: 0.4rem 0.7rem; }

/* --- Badges ------------------------------------------------------------------- */
.badge {
  display: inline-block; border-radius: 10px; padding: 0.05rem 0.6rem;
  font-size: 0.8rem; font-weight: 700; color: var(--blanc); white-space: nowrap;
}
/* niveaux de risque : sémantique INCHANGÉE */
.niveau-ELEVE, .note-1 { background: var(--rouge); }
.niveau-MOYEN, .note-2 { background: var(--orange); }
.niveau-FAIBLE, .note-3 { background: var(--vert); }
.badge-hors-kb { background: var(--bleu-gris); }
.badge-ok { background: var(--vert); }
.badge-attention { background: var(--orange); }
.badge-actif { background: var(--bleu-roi); }
.badge-inactif { background: var(--gris); }
.statut-en_attente { background: var(--gris); }
.statut-en_cours { background: var(--orange); }
.statut-terminee { background: var(--vert); }
.statut-echec { background: var(--rouge); }

/* --- Suivi d'analyse ------------------------------------------------------------ */
.etapes {
  display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none;
  padding: 0; margin: 0.8rem 0;
}
.etapes li {
  border: 1px solid var(--gris-bordure); border-radius: 12px;
  padding: 0.15rem 0.7rem; font-size: 0.83rem; color: var(--gris); background: var(--fond);
}
.etapes li.etape-active {
  border-color: var(--orange); color: var(--orange-fonce);
  font-weight: 700; background: var(--fond-orange-doux);
}
.etapes li.etape-faite { border-color: var(--vert); color: var(--vert); background: var(--fond-vert-doux); }
.barre-progression {
  height: 12px; background: var(--fond); border: 1px solid var(--gris-bordure);
  border-radius: 6px; overflow: hidden;
}
.barre-progression-remplie {
  height: 100%; width: 0; background: var(--orange); transition: width 0.6s ease;
}

/* --- Bandeau résultats + jauge ---------------------------------------------------- */
.bandeau-resultats { display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap; }
.bloc-titre-resultats { flex: 1 1 320px; }
.jauge-bloc { min-width: 190px; }
.jauge {
  height: 14px; background: var(--fond); border: 1px solid var(--gris-bordure);
  border-radius: 7px; overflow: hidden;
}
/* jauge en dégradé vert → orange → rouge : le dégradé couvre TOUTE la piste
   (background-size = 100 % / note), la largeur du remplissage le révèle. */
.jauge-remplie {
  height: 100%;
  --note: 100;
  background-color: var(--orange);
  background-image: linear-gradient(90deg, var(--vert) 0%, var(--orange) 55%, var(--rouge) 100%);
  background-size: calc(10000% / var(--note)) 100%;
  background-repeat: no-repeat;
}
/* replis unis si le dégradé n'est pas applicable (anciennes classes conservées) */
.jauge-eleve { background-color: var(--rouge); }
.jauge-moyen { background-color: var(--orange); }
.jauge-faible { background-color: var(--vert); }
.jauge-legende { margin-top: 0.25rem; display: flex; gap: 0.5rem; align-items: baseline; }
.compteurs-niveaux { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.barre-exports { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.barre-exports .bouton { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.pastille-note {
  min-width: 74px; text-align: center; border-radius: 8px; color: var(--blanc);
  font-size: 1.5rem; font-weight: 700; padding: 0.5rem 0.6rem; align-self: flex-start;
}
.pastille-note small { font-size: 0.8rem; font-weight: 400; }
.fond-eleve { background: var(--rouge); }
.fond-moyen { background: var(--orange); }
.fond-faible { background: var(--vert); }
.entete-fiche { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.table-fiche-lignes { margin-bottom: 1.2rem; }

/* --- Onglets --------------------------------------------------------------------- */
.onglets { display: flex; gap: 0.3rem; margin: 0.4rem 0 0.9rem; border-bottom: 2px solid var(--gris-bordure); }
.onglet {
  background: none; border: none; border-bottom: 3px solid transparent;
  font: inherit; font-weight: 600; color: var(--gris);
  padding: 0.5rem 1rem; cursor: pointer; margin-bottom: -2px;
}
.onglet:hover { color: var(--bleu-nuit); }
.onglet.actif { color: var(--bleu-nuit); border-bottom-color: var(--orange); }

/* --- Grille des alertes ------------------------------------------------------------ */
.filtres {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  padding-bottom: 0.7rem; border-bottom: 1px solid var(--gris-bordure); margin-bottom: 0.7rem;
}
.filtres label { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; font-weight: 600; }
.filtres select { width: auto; min-width: 9rem; }
.alerte {
  border: 1px solid var(--gris-bordure); border-radius: 8px;
  margin-bottom: 0.55rem; background: var(--blanc); box-shadow: var(--ombre-carte);
}
.alerte summary {
  display: flex; gap: 0.7rem; align-items: center; cursor: pointer;
  padding: 0.55rem 0.8rem; list-style: none; flex-wrap: wrap;
}
.alerte summary::-webkit-details-marker { display: none; }
.alerte summary .chevron { color: var(--gris-clair); transition: transform 0.15s; }
.alerte[open] summary .chevron { transform: rotate(90deg); color: var(--orange); }
.alerte-theme { font-weight: 700; color: var(--bleu-nuit); flex: 1 1 200px; }
.alerte-source { color: var(--gris); font-size: 0.85rem; }
.alerte-corps { padding: 0.2rem 1rem 0.9rem; border-top: 1px solid var(--fond); }
.alerte-corps dt {
  font-weight: 700; color: var(--bleu-roi); margin-top: 0.6rem;
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.3px;
}
.alerte-corps dd { margin: 0.15rem 0 0; overflow-wrap: anywhere; }
.alerte-citation {
  background: var(--fond); border-left: 3px solid var(--orange);
  padding: 0.45rem 0.7rem; font-style: italic; white-space: pre-wrap;
}
/* Champs longs (motif/citation/recommandation) : bascule « Voir plus /
   Réduire » — le texte COMPLET reste toujours accessible dans la page,
   jamais de troncature silencieuse (retour test n°1). */
.bouton-voir-plus {
  background: none; border: none; padding: 0; cursor: pointer;
  font: inherit; font-style: normal; font-size: 0.85rem; font-weight: 600;
  color: var(--bleu-roi); text-decoration: underline;
  text-underline-offset: 3px; white-space: nowrap;
}
.bouton-voir-plus:hover { color: var(--orange-fonce); }
/* commentaires longs de la fiche type (rendu serveur) : repli au mot pour ne
   jamais écraser la mise en page, texte toujours entier */
.table-fiche-lignes td { overflow-wrap: anywhere; }
.alerte-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; flex-wrap: wrap; align-items: center; }
.bouton-feedback { font-size: 0.85rem; padding: 0.25rem 0.7rem; }
.bouton-feedback.choisi { background: var(--bleu-nuit); border-color: var(--bleu-nuit); color: var(--blanc); }
.feedback-etat { font-size: 0.85rem; color: var(--vert); font-weight: 600; }

/* --- Panneau visionneuse de passage -------------------------------------------------- */
.panneau-passage {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 92vw);
  background: var(--blanc); border-left: 3px solid var(--bleu-nuit);
  box-shadow: -6px 0 18px rgba(17, 27, 64, 0.28);
  padding: 1rem 1.2rem; overflow-y: auto; z-index: 50;
}
.panneau-entete { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.4rem; }
.panneau-entete strong { color: var(--bleu-nuit); }
.panneau-entete .bouton-lien { color: var(--bleu-roi); opacity: 1; }
.passage-texte {
  white-space: pre-wrap; font-size: 0.92rem; line-height: 1.55;
  border: 1px solid var(--gris-bordure); border-radius: 6px;
  padding: 0.8rem; background: var(--fond); max-height: 62vh; overflow-y: auto;
}
.passage-texte mark {
  background: var(--surlignage); border-radius: 2px; padding: 0.05rem 0.1rem;
  box-shadow: 0 0 0 2px var(--surlignage);
}
.texte-synthese { white-space: pre-wrap; }
.liste-avertissements li { color: var(--orange-texte); }

/* --- Mode révision des résultats (lot 3a) ---------------------------------
   Charte : bleu roi pour la révision (badge/bandeau), orange pour les
   actions, rouge réservé aux niveaux de risque et à la suppression. */
.bandeau-revision {
  background: var(--fond-bleu-doux); border: 1px solid var(--bleu-roi);
  border-left: 4px solid var(--bleu-roi); border-radius: 8px;
  padding: 0.6rem 0.9rem; margin-bottom: 1rem; font-size: 0.92rem;
  display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap;
}
.bandeau-revision a { color: var(--bleu-roi); font-weight: 600; }
.bandeau-original {
  background: var(--fond); border-color: var(--gris-clair);
  border-left-color: var(--gris);
}
.badge-revise { background: var(--bleu-roi); }
.badge-original { background: var(--gris); }
.badge-ajout-humain { background: var(--bleu-nuit); }
.bouton-annuler-revision { margin-left: auto; font-size: 0.85rem; padding: 0.25rem 0.7rem; }
.note-exports-revises { align-self: center; }

.bouton-reviser.actif {
  background: var(--orange); border-color: var(--orange); color: var(--blanc);
}
.bouton-reviser.actif:hover { background: var(--orange-fonce); border-color: var(--orange-fonce); }

.revision-edition {
  margin-top: 0.9rem; padding: 0.8rem 0.9rem;
  background: var(--fond-bleu-doux); border: 1px dashed var(--bleu-gris);
  border-radius: 8px;
}
.revision-titre {
  margin: 0 0 0.3rem; font-weight: 700; color: var(--bleu-roi);
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.3px;
}
.revision-champs label { margin: 0.5rem 0 0.2rem; }
.revision-champs select { width: auto; min-width: 10rem; background: var(--blanc); }
.revision-champs textarea { background: var(--blanc); }
.bouton-supprimer { color: var(--rouge-fonce); border-color: var(--rouge); }
.bouton-supprimer:hover { background: var(--fond-rouge-doux); }
.revision-etat { font-size: 0.85rem; font-weight: 600; color: var(--vert-fonce); }
.revision-etat.erreur { color: var(--rouge-fonce); }

.formulaire-ajout-alerte { border-top: 4px solid var(--bleu-roi); }
.grille-ajout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem;
}
@media (max-width: 800px) { .grille-ajout { grid-template-columns: 1fr; } }
