:root {
  --bleu: #0b5cab;
  --bleu-fonce: #084280;
  --lien: #0b5cab;
  --gris: #f4f6f9;
  --bg-carte: #fff;
  --bord: #d9dee5;
  --vert: #1a7f4b;
  --orange: #b8860b;
  --rouge: #b3261e;
  --texte: #1c2330;
  --texte-attenue: #6b7280;
  --qty-btn-bg: #f5f7f9;
  --qty-btn-bord: #d7dce2;
  --help-bg: #eef4fb;
  --help-bord: #cfe0f5;
  --help-texte: #223344;
  --alert-bg: #f7dedc;
  --alert-succes-bg: #e8f5e9;
  --alert-succes-texte: #1b5e20;
  --badge-attente-bg: #fff4d6;
  --badge-preparation-bg: #dbe9fb;
  --badge-validee-bg: #ddf3e6;
  --badge-refusee-bg: #f7dedc;
  --ombre-carte: rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bleu-fonce: #0a6fd6;
    --lien: #6bb0ff;
    --gris: #14181f;
    --bg-carte: #1c222c;
    --bord: #333c4a;
    --vert: #4cc38a;
    --orange: #e0a83e;
    --rouge: #e5695f;
    --texte: #e4e7ec;
    --texte-attenue: #93a0b3;
    --qty-btn-bg: #262d39;
    --qty-btn-bord: #3a4453;
    --help-bg: #1c2938;
    --help-bord: #2b3d52;
    --help-texte: #c7d4e3;
    --alert-bg: #3a2320;
    --alert-succes-bg: #17301c;
    --alert-succes-texte: #7fd996;
    --badge-attente-bg: #3a2f10;
    --badge-preparation-bg: #16283d;
    --badge-validee-bg: #163526;
    --badge-refusee-bg: #3a2320;
    --ombre-carte: rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  margin: 0; color: var(--texte); background: var(--gris);
}
header.top {
  background: var(--bleu); color: #fff; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
header.top a { color: #fff; text-decoration: none; }
header.top .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
header.top .brand-logo-chip { background: #fff; border-radius: 8px; padding: 4px 8px; display: inline-flex; align-items: center; }
header.top .brand-logo { height: 40px; width: auto; display: block; }
header.top .brand-name { font-weight: 600; font-size: 17px; }
@media (max-width: 640px) { header.top .brand-name { display: none; } }
header.top .who { font-size: 13px; opacity: .9; }
header.top form { display: inline; }
.entete-droite { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.entete-actions { display: flex; align-items: center; gap: 8px; }
.selecteur-agence select {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.4); border-radius: 7px;
  color: #fff; font-size: 13px; padding: 4px 8px;
}
.selecteur-agence select option { color: var(--texte); }
.btn-panier {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 4px 10px; font-size: 13px;
}
.btn-panier:hover { background: rgba(255,255,255,.25); }
.btn-icone {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 999px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.4);
  color: #fff; cursor: pointer; font-size: 15px; list-style: none; text-decoration: none;
}
.btn-icone:hover { background: rgba(255,255,255,.25); }
.btn-icone::-webkit-details-marker { display: none; }
.menu-admin { position: relative; }
.menu-admin-liste {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 200px;
  background: var(--bg-carte); border: 1px solid var(--bord); border-radius: 8px;
  box-shadow: 0 4px 16px var(--ombre-carte); padding: 6px; display: flex; flex-direction: column;
}
.menu-admin-liste a {
  color: var(--texte); text-decoration: none; padding: 8px 10px; border-radius: 6px; font-size: 14px;
}
.menu-admin-liste a:hover { background: var(--gris); }
.container { max-width: 960px; margin: 24px auto; padding: 0 20px; }
.card { background: var(--bg-carte); border: 1px solid var(--bord); border-radius: 10px; padding: 22px; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--bord); font-size: 14px; }
th { color: var(--texte-attenue); font-weight: 600; }
.produit-image { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; }

.panier-barre {
  position: sticky; top: 0; z-index: 5; background: var(--bg-carte);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--bord); margin-bottom: 12px;
}
.panier-resume { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.qty-stepper { display: flex; align-items: center; gap: 4px; }
.qty-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--qty-btn-bord);
  background: var(--qty-btn-bg); color: var(--texte); cursor: pointer; font-size: 16px; line-height: 1;
}
.qty-stepper .qty-input { width: 54px; text-align: center; }
input[type=number], input[type=text], input[type=email], input[type=password], input[type=url], textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--bord); border-radius: 7px; font-size: 14px;
  background: var(--bg-carte); color: var(--texte);
}
.btn { display: inline-block; background: var(--bleu); color: #fff; border: 0; padding: 10px 16px;
  border-radius: 7px; cursor: pointer; font-size: 14px; text-decoration: none; }
.btn:hover { background: var(--bleu-fonce); }
.btn.secondaire { background: var(--bg-carte); color: var(--lien); border: 1px solid var(--lien); }
.btn.danger { background: var(--rouge); }
/* Boutons d'action compacts des tableaux d'administration : une icone,
   et le libelle de l'action en infobulle (title) / pour les lecteurs d'ecran. */
.actions-tableau { display: flex; gap: 6px; justify-content: flex-end; }
.actions-tableau form { display: inline-flex; margin: 0; }
.btn-action {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; flex: none;
  border-radius: 7px; background: var(--bg-carte); border: 1px solid var(--bord);
  color: var(--texte-attenue); cursor: pointer; font-family: inherit; font-size: 15px;
  line-height: 1; text-decoration: none;
}
.btn-action:hover { background: var(--gris); color: var(--lien); border-color: var(--lien); }
.btn-action.danger:hover { color: var(--rouge); border-color: var(--rouge); }
/* Infobulle immediate (le title natif du navigateur met ~1s a apparaitre).
   Le libelle est passe de title a data-libelle par le script de partials/foot.ejs. */
.btn-action[data-libelle] { position: relative; }
.btn-action[data-libelle]::after {
  content: attr(data-libelle);
  position: absolute; bottom: calc(100% + 6px); right: 0;
  white-space: nowrap; z-index: 20; pointer-events: none;
  background: var(--texte); color: var(--bg-carte);
  padding: 4px 9px; border-radius: 6px;
  font-family: inherit; font-size: 12px; font-weight: 500;
  box-shadow: 0 2px 8px var(--ombre-carte);
  opacity: 0; transition: opacity .1s ease-out;
}
.btn-action[data-libelle]:hover::after,
.btn-action[data-libelle]:focus-visible::after { opacity: 1; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.en_attente { background: var(--badge-attente-bg); color: var(--orange); }
.badge.en_preparation { background: var(--badge-preparation-bg); color: var(--lien); }
.badge.validee { background: var(--badge-validee-bg); color: var(--vert); }
.badge.refusee { background: var(--badge-refusee-bg); color: var(--rouge); }
.badge.erreur { background: var(--badge-refusee-bg); color: var(--rouge); }
/* Badges "d'intention", reutilisables partout : succes (c'est fait), info (en
   cours, rien a faire), attente (une action humaine est attendue), echec
   (perdu ou annule), neutre (on ne sait pas). Les classes ci-dessus, elles,
   nomment un statut de demande precis - d'ou ce jeu separe, qui sert au suivi
   des commandes Bureau Vallee (voir src/bv/suivi.js). */
.badge.succes { background: var(--badge-validee-bg); color: var(--vert); }
.badge.info { background: var(--badge-preparation-bg); color: var(--lien); }
.badge.attente { background: var(--badge-attente-bg); color: var(--orange); }
.badge.echec { background: var(--badge-refusee-bg); color: var(--rouge); }
.badge.neutre { background: var(--bord); color: var(--texte-attenue); }
.muted { color: var(--texte-attenue); font-size: 13px; }
/* Compteur d'elements en attente (ex. demandes d'ajout produit) affiche sur
   l'icone du menu admin et sur l'entree correspondante. */
.pastille {
  display: inline-block; min-width: 17px; padding: 0 5px; border-radius: 999px;
  background: var(--orange); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 17px; text-align: center; vertical-align: middle;
}
.menu-admin > summary .pastille { position: absolute; top: -4px; right: -4px; }
.liste-agences { max-height: 220px; overflow-y: auto; border: 1px solid var(--bord); border-radius: 7px; padding: 10px; }
.case-agence { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 400; margin-bottom: 6px; }
.case-agence input { width: auto; }
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.login-wrap { max-width: 380px; margin: 70px auto; }
.alert { background: var(--alert-bg); color: var(--rouge); padding: 10px 12px; border-radius: 7px; margin-bottom: 14px; font-size: 14px; }
.alert.alert-succes { background: var(--alert-succes-bg); color: var(--alert-succes-texte); }
.journal li { font-size: 13px; color: var(--texte-attenue); margin-bottom: 4px; }
.qty-input { max-width: 90px; }
.total { font-weight: 700; }
.help { background: var(--help-bg); border: 1px solid var(--help-bord); padding: 10px 12px; border-radius: 7px; font-size: 13px; color: var(--help-texte); margin-bottom: 14px; }
/* Deux declinaisons de l'encadre, pour distinguer d'un coup d'oeil un simple
   complement d'information (bleu) d'un avertissement (orange). Le neutre
   ci-dessus reste la valeur par defaut. */
.help.info { background: var(--badge-preparation-bg); border-color: var(--lien); }
.help.attention { background: var(--badge-attente-bg); border-color: var(--orange); }
/* Un encadre ecrit dans l'editeur contient des paragraphes : sans cela, ils
   ajouteraient une marge en haut et en bas du cadre. */
.help > p:first-child { margin-top: 0; }
.help > p:last-child { margin-bottom: 0; }
.contexte-bar { background: var(--bleu-fonce); color: #fff; font-size: 13px; }
.contexte-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; flex-wrap: wrap; }
.contexte-inner a { color: #fff; text-decoration: underline; white-space: nowrap; }
.impersonation-bar { background: var(--orange); color: #fff; font-size: 13px; }
.impersonation-bar .btn { background: #fff; color: var(--orange); font-weight: 600; }
.impersonation-bar .btn:hover { background: #fff; opacity: .9; }

.catalogue-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.produit-carte { background: var(--bg-carte); border: 1px solid var(--bord); border-radius: 10px; padding: 14px; text-decoration: none; color: var(--texte); display: flex; flex-direction: column; gap: 8px; transition: box-shadow .15s; }
.produit-carte:hover { box-shadow: 0 2px 10px var(--ombre-carte); }
.produit-carte img { width: 100%; height: 120px; object-fit: contain; }
.produit-carte-libelle { font-size: 14px; font-weight: 600; flex-grow: 1; }
.produit-carte-prix { font-size: 14px; color: var(--lien); font-weight: 700; }

.fiche-produit-principal { display: flex; gap: 28px; flex-wrap: wrap; }
.fiche-produit-image { width: 260px; height: 260px; object-fit: contain; flex-shrink: 0; }
.fiche-produit-infos { flex: 1; min-width: 260px; }
.fiche-produit-prix { font-size: 20px; font-weight: 700; margin: 10px 0; }
.fiche-produit-variantes { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0; }
.fiche-produit-attribut { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.fiche-produit-attribut select { padding: 8px 10px; border: 1px solid var(--bord); border-radius: 7px; font-size: 14px; }

/* Mode d'emploi (page /aide) : une carte par étape, numérotée, pour que le
   parcours se lise de haut en bas sans se perdre. */
.tuto-etape h2 { display: flex; align-items: center; gap: 10px; }
.tuto-numero {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 999px;
  background: var(--bleu); color: #fff; font-size: 15px; font-weight: 700;
}
.tuto-etape ol { padding-left: 20px; }
.tuto-etape li { margin-bottom: 6px; }
.tuto-etape td:first-child { white-space: nowrap; }

/* Fenêtre d'accueil de la première connexion. */
.tuto-popup {
  width: 92vw; max-width: 540px; padding: 24px; border: 1px solid var(--bord);
  border-radius: 10px; background: var(--bg-carte); color: var(--texte);
}
.tuto-popup::backdrop { background: rgba(0,0,0,.5); }
.tuto-popup h2 { margin-top: 0; }
.tuto-popup ol { padding-left: 20px; }
.tuto-popup li { margin-bottom: 6px; }

.devis-dialog { width: 90vw; max-width: 900px; height: 90vh; padding: 0; border: 0; border-radius: 10px; background: var(--bg-carte); color: var(--texte); }
.devis-dialog::backdrop { background: rgba(0,0,0,.5); }
.devis-dialog-barre { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--bord); font-size: 14px; font-weight: 600; }
.devis-dialog iframe { display: block; width: 100%; height: calc(90vh - 45px); border: 0; }

/* Suivi d'une commande chez Bureau Vallée : une expédition par bloc (une
   commande peut être scindée en plusieurs envois). */
/* Boutons alignés dans une cellule de tableau : comme .row-actions mais sans
   sa marge haute, qui décalerait les boutons vers le bas de la ligne. */
.cellule-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Ligne d'un tableau dont l'element est desactive : presente mais en retrait,
   pour qu'on la distingue au premier coup d'oeil sans la faire disparaitre. */
.ligne-inactive { opacity: .55; }

/* Badges de suivi sous le statut, dans le listing des demandes : ils passent a
   la ligne plutot que d'elargir la colonne. */
.suivi-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.suivi-badges .badge { font-size: 11px; padding: 2px 8px; }
.suivi-expedition { padding: 10px 0; border-top: 1px solid var(--bord); }
.suivi-expedition p { margin: 4px 0; }

/* Éditeur du modèle d'email d'invitation : barre de mise en forme au-dessus
   d'une zone de saisie qui rend le message tel qu'il partira. */
.barre-outils { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border: 1px solid var(--bord); border-bottom: 0; border-radius: 7px 7px 0 0; background: var(--help-bg); }
.barre-outils button { min-width: 30px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--texte); cursor: pointer; font-size: 13px; }
.barre-outils button:hover { background: var(--bg-carte); border-color: var(--bord); }
.barre-separateur { width: 1px; height: 20px; margin: 0 4px; background: var(--bord); }
.zone-wysiwyg { min-height: 260px; padding: 12px; border: 1px solid var(--bord); border-radius: 0 0 7px 7px; background: #fff; color: #222; overflow-y: auto; }
.zone-wysiwyg:focus { outline: 2px solid var(--lien); outline-offset: -2px; }
.btn-lien { padding: 0; border: 0; background: none; color: var(--lien); cursor: pointer; font-size: 13px; text-decoration: underline; }
.etiquette-groupe { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }

/* Zone de saisie d'un texte affiche dans la console (mode d'emploi, fenetre
   d'accueil) : contrairement a l'apercu d'email ci-dessus, elle prend les
   couleurs du site, sinon les encadres et les pastilles ne ressembleraient pas
   a ce que l'agence verra - et resteraient illisibles en theme sombre. */
.zone-wysiwyg.apercu-page { min-height: 150px; background: var(--bg-carte); color: var(--texte); }
.zone-wysiwyg.apercu-page hr { border: 0; border-top: 1px solid var(--bord); margin: 14px 0; }

/* Menu deroulant des pastilles : on choisit a la couleur, pas au nom de la
   classe. */
.menu-pastilles { position: relative; }
.menu-pastilles > summary { list-style: none; display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; border-radius: 5px; cursor: pointer; }
.menu-pastilles > summary::-webkit-details-marker { display: none; }
.menu-pastilles > summary:hover { background: var(--bg-carte); }
.menu-pastilles-liste { position: absolute; z-index: 5; top: 34px; left: 0; display: flex; flex-direction: column; gap: 2px; padding: 6px; border: 1px solid var(--bord); border-radius: 7px; background: var(--bg-carte); box-shadow: 0 2px 10px var(--ombre-carte); }
.menu-pastilles-liste button { display: block; width: 100%; height: auto; padding: 3px; text-align: left; }

/* Page /admin/aide : un point du mode d'emploi = un titre + un bloc. Le numero
   est affiche par l'application, jamais saisi - reordonner ne doit pas obliger
   a renumeroter a la main. */
.point-aide { border: 1px solid var(--bord); border-radius: 10px; padding: 14px; margin: 0 0 14px; }
.point-aide-entete { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.point-aide-entete input { flex: 1; min-width: 120px; }
.point-aide-actions { display: flex; gap: 4px; flex-shrink: 0; }
.point-aide-actions button { min-width: 32px; height: 32px; border: 1px solid var(--bord); border-radius: 6px; background: var(--bg-carte); color: var(--texte); cursor: pointer; }
.point-aide-actions button:hover { background: var(--gris); }
.point-aide-actions .supprimer:hover { color: var(--rouge); border-color: var(--rouge); }
