/* Axantis Contrats — système visuel.
   Univers : le classeur de contrats. Fond « papier » froid, encre bleu-noir,
   et une couleur d'INTERCALAIRE par type de contrat (héritée des éclats du
   logo Axantis), reprise partout : badges, cartes, overlays de l'éditeur.
   Montants et numéros de contrats en mono tabulaire. */

:root {
  --papier: #f6f7f9;
  --carte: #ffffff;
  --encre: #1b2432;
  --encre-2: #55617a;
  --trait: #e3e6ec;
  --accent: #2851e3;            /* bleu encre Axantis — actions */
  --accent-doux: #eef2ff;

  /* Intercalaires par type de contrat */
  --c-hebergement: #2851e3;
  --c-securite: #d64545;
  --c-sauvegarde: #7a4fd1;
  --c-hotline: #1f9d66;
  --c-telephonie: #d99000;
  --c-horsscope: #8a93a6;

  /* Gravités des contrôles */
  --g-bloquant: #c22f28;
  --g-warning: #a86a00;
  --g-info: #4a6478;
  --g-ok: #1f7a4d;

  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
  --rayon: 6px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papier);
  color: var(--encre);
  font: 15px/1.55 system-ui, "Segoe UI", sans-serif;
}

/* ---------- structure ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.2rem;
  background: var(--carte); border-bottom: 1px solid var(--trait);
  padding: 0 1.25rem; height: 52px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .marque {
  font-weight: 750; letter-spacing: .14em; text-transform: uppercase;
  font-size: .95rem; color: var(--encre); text-decoration: none;
}
.topbar .marque span { color: var(--accent); }
.topbar nav { display: flex; gap: .25rem; }
.topbar nav a {
  color: var(--encre-2); text-decoration: none; font-size: .92rem;
  padding: .35rem .7rem; border-radius: var(--rayon);
}
.topbar nav a:hover { background: var(--papier); color: var(--encre); }
.topbar nav a.actif { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.topbar .droite { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
/* Sous-bandeau : second niveau de navigation, collé sous le bandeau principal.
   Mêmes pastilles que le menu du haut, un cran plus petites : on lit tout de suite
   qu'il s'agit du même système, un niveau en dessous. */
.sous-nav {
  display: flex; align-items: center; gap: .3rem;
  background: var(--papier); border-bottom: 1px solid var(--trait);
  padding: 0 1.25rem; height: 46px;
  position: sticky; top: 52px; z-index: 39;
  overflow-x: auto; overflow-y: hidden; white-space: nowrap;
  scrollbar-width: thin;
}
.sous-nav a, .sous-nav span {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .75rem; font-size: .86rem; text-decoration: none;
  color: var(--encre-2); border-radius: var(--rayon);
  border: 1px solid transparent;
}
.sous-nav a:hover { background: var(--carte); border-color: var(--trait); color: var(--encre); }
.sous-nav a.actif {
  background: var(--accent-doux); color: var(--accent); font-weight: 600;
  border-color: #d5defc;
}
.sous-nav .inactif { color: #b3bac6; cursor: not-allowed; }
.sous-nav .contexte {
  font-weight: 700; color: var(--encre); padding-left: .2rem;
  max-width: 22rem; overflow: hidden; text-overflow: ellipsis; display: inline-block;
}
.sous-nav .separateur {
  width: 1px; height: 22px; padding: 0; margin: 0 .45rem; background: var(--trait); border: 0;
}
.sous-nav a.action {
  margin-left: auto; color: var(--accent); background: var(--carte); border-color: var(--trait);
}
.sous-nav a.action ~ a.action { margin-left: 0; }
.sous-nav a.action:hover { border-color: var(--accent); }
/* Fil d'Ariane des pages de profondeur 3 (template, éditeur de mapping) */
.fil-ariane { font-size: .82rem; color: var(--encre-2); margin: 0 0 .4rem; }
.fil-ariane a { color: var(--encre-2); }
.fil-ariane .sep { margin: 0 .35rem; color: #b3bac6; }

.badge-role {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--encre-2); border: 1px solid var(--trait);
  padding: .15rem .5rem; border-radius: 99px;
}

main { max-width: 1160px; margin: 0 auto; padding: 1.6rem 1.25rem 4rem; }
main.large { max-width: 1500px; }

footer {
  max-width: 1160px; margin: 0 auto; padding: 0 1.25rem 1.2rem;
  color: var(--encre-2); font-size: .75rem;
}

h1 { font-size: 1.45rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.8rem 0 .6rem; }
.sous-titre { color: var(--encre-2); margin: 0 0 1.4rem; }

/* Eyebrow : petit surtitre en capitales espacées */
.eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--encre-2); margin: 0 0 .3rem;
}

/* ---------- cartes & tableaux ---------- */
.carte {
  background: var(--carte); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 1.1rem 1.25rem; margin-bottom: 1rem;
}
.carte.contrat { border-left: 4px solid var(--couleur-contrat, var(--accent)); }

table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th {
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--encre-2); font-weight: 600;
  padding: .45rem .6rem; border-bottom: 2px solid var(--trait);
}
td { padding: .5rem .6rem; border-bottom: 1px solid var(--trait); vertical-align: top; }
tr:hover td { background: #fafbfd; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }

.montant { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.numero-contrat { font-family: var(--mono); letter-spacing: .02em; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; font-size: .74rem; font-weight: 600;
  padding: .12rem .55rem; border-radius: 99px; white-space: nowrap;
  color: #fff; background: var(--c-horsscope);
}
.badge.hebergement { background: var(--c-hebergement); }
.badge.securite { background: var(--c-securite); }
.badge.sauvegarde { background: var(--c-sauvegarde); }
.badge.hotline_illimitee, .badge.hotline_carte { background: var(--c-hotline); }
.badge.telephonie { background: var(--c-telephonie); }

.badge-origine {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  padding: .1rem .4rem; border-radius: 3px; font-weight: 600;
}
.badge-origine.fiche { background: #fdf3d8; color: #7a5b00; }
.badge-origine.api, .badge-origine.rne { background: #e3f4ea; color: #1f7a4d; }
.badge-origine.saisie { background: #e8edf9; color: #2851e3; }

.pastille { display: inline-block; width: .62rem; height: .62rem; border-radius: 50%; }

/* ---------- catalogue groupé par contrat cible ---------- */
.groupe-catalogue { margin-bottom: 1.2rem; }
.entete-groupe {
  display: flex; align-items: baseline; gap: .7rem;
  padding: .75rem .9rem .55rem; border-bottom: 1px solid var(--trait);
}
.compte-groupe { color: var(--encre-2); font-size: .8rem; }
.groupe-vide { color: var(--encre-2); font-size: .88rem; margin: 0; padding: .7rem .9rem; }
.confiance-haute { color: var(--g-ok); }
.confiance-basse { color: var(--g-warning); }

/* ---------- contrôles (rapport) ---------- */
.controle {
  display: flex; gap: .7rem; padding: .7rem .9rem; border-radius: var(--rayon);
  border: 1px solid var(--trait); border-left-width: 4px; margin-bottom: .5rem;
  background: var(--carte); font-size: .92rem;
}
.controle .code { font-family: var(--mono); font-size: .72rem; color: var(--encre-2); }
.controle.bloquant { border-left-color: var(--g-bloquant); }
.controle.warning { border-left-color: var(--g-warning); }
.controle.info { border-left-color: var(--g-info); }

/* ---------- formulaires & boutons ---------- */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--encre-2); margin: .7rem 0 .2rem; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: .45rem .6rem; font: inherit; color: var(--encre);
  border: 1px solid var(--trait); border-radius: var(--rayon); background: #fff;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.bouton {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; font: inherit; font-weight: 600; font-size: .92rem;
  padding: .48rem 1rem; border-radius: var(--rayon); cursor: pointer; text-decoration: none;
}
.bouton:hover { filter: brightness(1.08); }
.bouton.secondaire { background: #fff; color: var(--accent); }
.bouton.discret {
  background: none; border-color: transparent; color: var(--encre-2); font-weight: 500;
}
.bouton.discret:hover { color: var(--encre); background: var(--papier); }
.bouton.danger { border-color: var(--g-bloquant); background: #fff; color: var(--g-bloquant); }
.bouton:disabled { opacity: .45; cursor: not-allowed; }

.actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: 1rem; }

/* indicateur htmx */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.spinner {
  width: 1rem; height: 1rem; border: 2px solid var(--trait);
  border-top-color: var(--accent); border-radius: 50%;
  animation: rotation .8s linear infinite; vertical-align: -3px;
}
@keyframes rotation { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------- connexion ---------- */
.ecran-connexion {
  min-height: 100vh; display: grid; place-items: center; background: var(--papier);
}
.ecran-connexion .carte { width: min(400px, 92vw); padding: 2rem; }
.erreur { color: var(--g-bloquant); font-size: .9rem; margin-top: .6rem; }

/* ---------- éditeur de mapping ---------- */
.editeur { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.2rem; align-items: start; }
.editeur .pages { min-width: 0; }
.page-pdf {
  position: relative; background: #fff; border: 1px solid var(--trait);
  border-radius: 3px; box-shadow: 0 1px 4px rgb(27 36 50 / .07); margin-bottom: 1.1rem;
}
.page-pdf img { display: block; width: 100%; height: auto; border-radius: 3px; }
.page-pdf .numero-page {
  position: absolute; top: -0.05rem; left: -2.2rem; font-size: .75rem;
  color: var(--encre-2); font-family: var(--mono);
}

.champ-overlay {
  position: absolute; border: 1.5px solid; border-radius: 2px;
  background: transparent; cursor: pointer; padding: 0;
}
.champ-overlay:hover { box-shadow: 0 0 0 3px rgb(40 81 227 / .25); }
.champ-overlay.non-mappe { border-color: #d64545; background: rgb(214 69 69 / .10); }
.champ-overlay.suggere   { border-color: #d99000; background: rgb(217 144 0 / .12); }
.champ-overlay.valide    { border-color: #1f9d66; background: rgb(31 157 102 / .10); }
.champ-overlay.ignore    { border-color: #b8bfcc; background: rgb(138 147 166 / .08); }
.champ-overlay.selectionne { box-shadow: 0 0 0 3px rgb(40 81 227 / .45); }

.panneau-mapping {
  position: sticky; top: 114px; max-height: calc(100vh - 130px); overflow-y: auto;
  background: var(--carte); border: 1px solid var(--trait);
  border-radius: var(--rayon); padding: 1rem 1.1rem;
}
.panneau-mapping .libelle-contexte {
  font-size: .84rem; color: var(--encre-2); background: var(--papier);
  border-radius: var(--rayon); padding: .5rem .7rem; margin: .5rem 0;
}
.compteur-mapping { font-family: var(--mono); font-size: .9rem; }
.jauge { height: 6px; background: var(--trait); border-radius: 99px; overflow: hidden; margin: .4rem 0 .8rem; }
.jauge > div { height: 100%; background: var(--g-ok); }

.filtres-etats { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.filtres-etats button {
  font: inherit; font-size: .78rem; padding: .2rem .55rem; border-radius: 99px;
  border: 1px solid var(--trait); background: #fff; cursor: pointer; color: var(--encre-2);
}
.filtres-etats button.actif { border-color: var(--accent); color: var(--accent); font-weight: 600; }

/* masquage par filtre (classe posée sur .editeur) */
.editeur.filtre-non-mappe .champ-overlay:not(.non-mappe),
.editeur.filtre-suggere .champ-overlay:not(.suggere),
.editeur.filtre-valide .champ-overlay:not(.valide) { display: none; }

/* ---------- divers ---------- */
.vide {
  text-align: center; color: var(--encre-2); padding: 2.5rem 1rem;
  border: 1.5px dashed var(--trait); border-radius: var(--rayon);
}
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) {
  .grille-2, .editeur { grid-template-columns: 1fr; }
  .panneau-mapping { position: static; max-height: none; }
}
.note { font-size: .84rem; color: var(--encre-2); }
.requis { color: var(--g-bloquant); font-weight: 600; }
.note.alerte-libre { color: var(--g-warning); font-weight: 600; }
.case-a-cocher { display: flex; gap: .5rem; align-items: flex-start; font-weight: normal; }
.case-a-cocher input { width: auto; margin-top: .2rem; }
hr { border: none; border-top: 1px solid var(--trait); margin: 1.2rem 0; }

/* ---------- mode d'emploi (guide) ---------- */
.guide { max-width: 820px; }
.guide h2 {
  margin: 2.2rem 0 .6rem; padding-top: 1.2rem; border-top: 1px solid var(--trait);
  font-size: 1.2rem;
}
.guide h2:first-of-type { border-top: none; padding-top: 0; }
.guide h3 { font-size: 1rem; margin: 1.4rem 0 .4rem; }
.guide p, .guide li { line-height: 1.65; }
.guide ol, .guide ul { padding-left: 1.3rem; }
.guide li { margin: .3rem 0; }
.guide figure {
  margin: 1rem 0 1.4rem; border: 1px solid var(--trait); border-radius: var(--rayon);
  overflow: hidden; background: #fff;
}
.guide figure img { display: block; width: 100%; height: auto; }
.guide figcaption {
  font-size: .82rem; color: var(--encre-2); padding: .5rem .8rem;
  border-top: 1px solid var(--trait); background: var(--papier);
}
.etape {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--accent);
  color: #fff; font-weight: 700; font-size: .9rem; margin-right: .5rem; vertical-align: .1rem;
}
.astuce {
  border: 1px solid var(--trait); border-left: 4px solid var(--accent);
  background: var(--accent-doux); border-radius: var(--rayon);
  padding: .7rem .9rem; margin: 1rem 0; font-size: .92rem;
}
.astuce.attention { border-left-color: var(--g-warning); background: #fdf6e6; }
.astuce > strong:first-child { display: block; margin-bottom: .15rem; }   /* le titre de l'encadré, pas un mot en gras du texte */
.legende-couleurs { display: flex; flex-wrap: wrap; gap: .8rem; margin: .6rem 0; font-size: .88rem; }
.legende-couleurs span { display: inline-flex; align-items: center; gap: .35rem; }
.pastille-c { width: .9rem; height: .9rem; border-radius: 3px; border: 1.5px solid; display: inline-block; }
.onglets-aide { display: flex; gap: .3rem; margin: 0 0 1.4rem; border-bottom: 1px solid var(--trait); }
.onglets-aide a {
  padding: .5rem .9rem; text-decoration: none; color: var(--encre-2);
  border-bottom: 2px solid transparent; font-weight: 600;
}
.onglets-aide a.actif { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- journal d'usage ---------- */
.tuiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .7rem; margin-bottom: .8rem;
}
.tuile {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: .8rem .9rem; display: flex; flex-direction: column; gap: .15rem;
}
.tuile .valeur {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 1.5rem; font-weight: 600; line-height: 1.1;
}
.tuile .libelle { font-size: .78rem; color: var(--encre-2); line-height: 1.3; }
.filtres-evenements { display: flex; gap: .4rem; flex-wrap: wrap; }
.puce {
  font-size: .78rem; padding: .2rem .6rem; border-radius: 99px; text-decoration: none;
  border: 1px solid var(--trait); background: #fff; color: var(--encre-2);
}
.puce.actif { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.puce strong { font-family: var(--mono); }

/* Impression PDF : mise en page A4 propre */
@media print {
  .guide { max-width: none; }
  .guide h2 { break-before: page; }
  .guide h2.pas-de-saut { break-before: auto; }
  .guide figure, .astuce { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* Info-bulle d'un paramètre (Paramétrage → Paramètres) : la puce « ? » affiche son
   explication au survol, ou au focus clavier (tabindex). */
.aide-param {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 1.05rem; height: 1.05rem; margin-left: .3rem; vertical-align: .05rem;
  border-radius: 50%; background: var(--accent-doux); color: var(--accent);
  border: 1px solid var(--accent); font-size: .7rem; font-weight: 700; line-height: 1;
  cursor: help;
}
.aide-param[data-aide]::after {
  content: attr(data-aide);
  position: absolute; left: -.4rem; bottom: calc(100% + .45rem); z-index: 20;
  width: max-content; max-width: min(26rem, 80vw);
  padding: .55rem .7rem; border-radius: var(--rayon);
  background: var(--encre); color: #fff;
  font-size: .82rem; font-weight: 400; line-height: 1.45; text-align: left; white-space: normal;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
  opacity: 0; visibility: hidden; transition: opacity .12s, visibility .12s;
  pointer-events: none;
}
.aide-param[data-aide]:hover::after,
.aide-param[data-aide]:focus::after { opacity: 1; visibility: visible; }
.aide-param:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
