/* IsdFlow web — la charte du bureau : bleu nuit, orange ISD, turquoise. */

@font-face { font-family: "Nunito"; src: url("/static/fonts/Nunito-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/static/fonts/Nunito-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Nunito"; src: url("/static/fonts/Nunito-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --fond: #F8FBFD;
  --surface: #FFFFFF;
  --surface-alt: #F3F7FA;
  --texte: #2C3E50;
  --texte-doux: #6B7785;
  --orange: #ED7132;
  --orange-fonce: #D85F23;
  --turquoise: #27B1AE;
  --turquoise-fonce: #1E8F8C;
  --bleu: #136F9A;
  --nuit: #2C3E50;
  --nuit-fonce: #22313F;
  --bord: #E5EBF0;
  --bord-fort: #CBD5E0;
  --ok: #1E8F8C;
  --alerte: #C2410C;
  --erreur: #C62828;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(44, 62, 80, .06), 0 4px 14px rgba(44, 62, 80, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 14px/1.45 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--bleu); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.doux { color: var(--texte-doux); }
.petit { font-size: 12px; }
.gras { font-weight: 700; }
.droite { text-align: right; }
.nowrap { white-space: nowrap; }
.cache { display: none !important; }

/* --- cadre ------------------------------------------------------------ */
.cadre { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.barre {
  background: var(--nuit); color: #DCE4EC; padding: 18px 10px; position: sticky; top: 0;
  height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
.barre .marque { font-size: 22px; font-weight: 700; color: #fff; padding: 4px 12px 18px; letter-spacing: .2px; }
.barre .section { font-size: 11px; font-weight: 700; letter-spacing: .08em; color: #8FA1B3; padding: 10px 12px 4px; }
.barre a.lien {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 8px;
  color: #DCE4EC; font-weight: 600; text-decoration: none;
}
.barre a.lien:hover { background: rgba(255,255,255,.07); }
.barre a.lien.actif { background: var(--turquoise); color: #fff; }
.barre .pied { margin-top: auto; padding: 14px 12px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.barre .pied form { margin: 6px 0 0; }
.barre .pied button { background: none; border: 0; color: #9FB0C0; cursor: pointer; padding: 0; font: inherit; }
.barre .pied button:hover { color: #fff; }
.icone {
  width: 18px; height: 18px; flex: 0 0 18px; background: currentColor;
  -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat;
}

.principal { padding: 22px 28px 40px; min-width: 0; }
.entete { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.entete h1 { flex: 1; }
.sous-titre { color: var(--texte-doux); margin: 0 0 14px; }

/* --- boutons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--bord-fort);
  background: var(--surface); color: var(--texte); font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--texte-doux); text-decoration: none; }
.btn.primaire { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.primaire:hover { background: var(--orange-fonce); border-color: var(--orange-fonce); }
.btn.secondaire { border-color: var(--turquoise); color: var(--turquoise-fonce); }
.btn.secondaire:hover { background: #E8F7F6; }
.btn.danger { border-color: #F2C4C4; color: var(--erreur); }
.btn.danger:hover { background: #FDF0F0; }
.btn.lien { border: 0; background: none; color: var(--bleu); padding: 8px 6px; }
.btn.petit { padding: 5px 10px; font-size: 13px; }
.btn[disabled], .btn.htmx-request { opacity: .55; pointer-events: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* --- cartes, panneaux --------------------------------------------------- */
.carte { background: var(--surface); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); }
.carte.pad { padding: 16px 18px; }
.grille-2 { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(420px, 1.25fr); gap: 16px; align-items: start; }
.grille-tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.tuile { padding: 16px 18px; }
.tuile .valeur { font-size: 24px; font-weight: 700; margin-top: 4px; }
.tuile .libelle { color: var(--texte-doux); font-weight: 600; font-size: 13px; }

/* --- onglets ------------------------------------------------------------ */
.onglets { display: flex; gap: 4px; border-bottom: 1px solid var(--bord); margin: 6px 0 14px; }
.onglets a {
  padding: 10px 14px; color: var(--texte-doux); font-weight: 600; border-bottom: 3px solid transparent;
  margin-bottom: -1px; text-decoration: none;
}
.onglets a.actif { color: var(--texte); border-bottom-color: var(--orange); }
.onglets a:hover { color: var(--texte); }

/* --- tableaux ----------------------------------------------------------- */
table.liste { width: 100%; border-collapse: collapse; }
table.liste th {
  text-align: left; font-size: 12px; font-weight: 700; color: var(--texte-doux);
  padding: 10px 12px; border-bottom: 1px solid var(--bord); background: var(--surface-alt); position: sticky; top: 0;
}
table.liste td { padding: 10px 12px; border-bottom: 1px solid var(--bord); vertical-align: top; }
table.liste tr.cliquable { cursor: pointer; }
table.liste tr.cliquable:hover td { background: #F6FAFC; }
table.liste tr.choisie td { background: #E8F7F6; }
table.liste td.num, table.liste th.num { text-align: right; white-space: nowrap; }
.defile { max-height: calc(100vh - 230px); overflow: auto; border-radius: var(--rayon); }

/* --- pastilles d'etat --------------------------------------------------- */
.pastille { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #EEF2F6; color: var(--texte); white-space: nowrap; }
.pastille.ok { background: #E3F5F4; color: var(--turquoise-fonce); }
.pastille.alerte { background: #FDEBDD; color: var(--alerte); }
.pastille.erreur { background: #FDE7E7; color: var(--erreur); }
.pastille.info { background: #E3EEF6; color: var(--bleu); }
.pastille.neutre { background: #EEF2F6; color: var(--texte-doux); }
.qui-vous { color: var(--erreur); font-weight: 700; }

/* --- formulaires -------------------------------------------------------- */
.champ { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.champ label { font-weight: 700; font-size: 13px; }
.champ .aide { font-size: 12px; color: var(--texte-doux); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--bord-fort); border-radius: 8px;
  font: inherit; color: var(--texte); background: #fff;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(39, 177, 174, .35); border-color: var(--turquoise); }
.rangee { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.erreur-champ { color: var(--erreur); font-size: 12px; }
.recherche { max-width: 320px; }

/* --- messages ----------------------------------------------------------- */
.message { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-weight: 600; }
.message.ok { background: #E3F5F4; color: var(--turquoise-fonce); }
.message.erreur { background: #FDE7E7; color: var(--erreur); }
.message.info { background: #E3EEF6; color: var(--bleu); }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
#toasts .message { box-shadow: var(--ombre); margin: 0; animation: disparait 6s forwards; }
@keyframes disparait { 0%, 85% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

/* --- fenetre (dialog) --------------------------------------------------- */
dialog.fenetre {
  border: 0; border-radius: 14px; padding: 0; width: min(880px, 94vw); max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--texte);
}
dialog.fenetre.large { width: min(1180px, 96vw); }
dialog.fenetre::backdrop { background: rgba(28, 40, 52, .45); }
dialog.fenetre .tete { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--bord); }
dialog.fenetre .tete h2 { flex: 1; }
dialog.fenetre .corps { padding: 16px 20px; overflow: auto; max-height: calc(90vh - 140px); }
dialog.fenetre .pied { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--bord); background: var(--surface-alt); }

/* --- le Flux ------------------------------------------------------------ */
.etapes { display: flex; align-items: flex-start; gap: 0; margin: 4px 0 14px; overflow-x: auto; }
.etape { display: flex; flex-direction: column; align-items: center; min-width: 64px; flex: 1; position: relative; }
.etape .rond {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--bord-fort); background: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--texte-doux); z-index: 1;
}
.etape .nom { font-size: 11px; color: var(--texte-doux); margin-top: 4px; text-align: center; }
.etape::before { content: ""; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: var(--bord-fort); }
.etape:first-child::before { display: none; }
.etape.faite .rond { background: var(--turquoise); border-color: var(--turquoise); color: #fff; }
.etape.faite::before, .etape.courante::before { background: var(--turquoise); }
.etape.courante .rond { background: var(--orange); border-color: var(--orange); color: #fff; }
.etape.courante .nom { color: var(--orange); font-weight: 700; }

.bloc-afaire { background: #FFF3EA; border: 1px solid #F6C3A8; border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 12px; }
.bloc-attente { background: #F1F5F9; border: 1px solid #D5DCE3; border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 12px; }
.bloc-rapport { background: #FFF8E6; border: 1px solid #F0DDA8; border-radius: var(--rayon); padding: 14px 16px; margin-bottom: 12px; }
.bloc-rapport ul { margin: 4px 0 8px; padding-left: 20px; }
.surtitre { font-size: 12px; color: var(--texte-doux); margin-bottom: 2px; }

.fil { display: flex; flex-direction: column; gap: 10px; }
.bulle { max-width: 86%; padding: 10px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; }
.bulle.recue { background: #EEF1F4; align-self: flex-start; }
.bulle.envoyee { background: #DCEBFF; align-self: flex-end; }
.bulle.interne { background: #FFF4D6; border: 1px dashed #E8C66A; align-self: flex-end; }
.bulle .meta { font-size: 11px; color: var(--texte-doux); margin-bottom: 4px; white-space: normal; }
.jour { text-align: center; font-size: 11px; color: var(--texte-doux); margin: 4px 0; }
.consigne { display: flex; gap: 8px; margin-top: 12px; }
.consigne input { flex: 1; }
.panneau-droit { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }

/* --- page de connexion -------------------------------------------------- */
.connexion { min-height: 100vh; display: grid; place-items: center; background: var(--nuit); }
.connexion .carte { width: min(380px, 92vw); padding: 28px; }
.connexion h1 { margin-bottom: 4px; }

.vide { text-align: center; color: var(--texte-doux); padding: 40px 10px; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* --- fiche client : les champs suivent le type et les cases ------------- */
.fiche-client:has(input[name=client_type][value=B2B]:checked) .seulement-b2c { display: none; }
.fiche-client:has(input[name=client_type][value=B2C]:checked) .seulement-b2b { display: none; }
.fiche-client:not(:has(input[name=livraison]:checked)) .livraison { display: none; }
.fiche-client:has(input[name=remise_defaut]:checked) .remise-perso { display: none; }
