/* Feuille unique de l'app — remplace CL_CSS, HOURS_CSS, INV_CSS, VOLS_CSS,
   LOGIN_CSS et le <style> de la page d'accueil de la v1.

   Tout passe par des tokens : changer la typo mobile ou la couleur d'accent se
   fait ici, une fois, et vaut pour toutes les pages. */

:root {
  color-scheme: light;
  --fond:        #f6f5f2;
  --surface:     #ffffff;
  --surface-alt: #efece6;
  --bord:        #ddd8cf;   /* séparateurs décoratifs */
  --bord-fort:   #8c8578;   /* contour des composants — 3:1 minimum */
  --texte:       #232019;
  --texte-doux:  #6b6459;
  --accent:      #0a6b52;   /* lagon */
  --sur-accent:  #ffffff;   /* texte posé SUR l'accent (cf. bloc sombre) */
  --accent-doux: #d9ece5;
  --danger:      #a3331f;
  --alerte:      #8a5a00;
  --ok:          #0a6b52;

  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --pas: 8px;
  --ombre: 0 1px 2px rgb(35 32 25 / 8%), 0 4px 12px rgb(35 32 25 / 6%);
  --police: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --touche: 44px;           /* cible tactile minimale — l'app vit sur téléphone */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --fond: #17150f; --surface: #201d16; --surface-alt: #2a261d; --bord: #3b362b; --bord-fort: #847b63;
    --texte: #ece7dc; --texte-doux: #a49b8a; --accent: #4fbf9b; --accent-doux: #1c3a31; --sur-accent: #10231d;
    --danger: #e8785f; --alerte: #d9a441; --ok: #4fbf9b;
    --ombre: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px rgb(0 0 0 / 30%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --fond: #17150f; --surface: #201d16; --surface-alt: #2a261d; --bord: #3b362b; --bord-fort: #847b63;
  --texte: #ece7dc; --texte-doux: #a49b8a; --accent: #4fbf9b; --accent-doux: #1c3a31; --sur-accent: #10231d;
  --danger: #e8785f; --alerte: #d9a441; --ok: #4fbf9b;
  --ombre: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 12px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 var(--police);
  -webkit-text-size-adjust: 100%;
}

.enveloppe { max-width: 780px; margin: 0 auto; padding: calc(var(--pas) * 1.5); }

/* --- liens ---
   Sans cette règle, un lien nu prend le bleu par défaut du navigateur (#0000EE),
   illisible sur le fond sombre. On force la couleur d'accent, y compris pour
   :visited — sinon les liens déjà ouverts repartent sur le violet par défaut,
   qui a exactement le même problème. */
a { color: var(--accent); text-underline-offset: 2px; }
a:visited { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.bouton, .bouton:visited { color: var(--sur-accent); }
.bouton.second, .bouton.second:visited { color: var(--texte); }

/* --- barre du haut --- */
.barre {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--pas);
  padding: var(--pas) calc(var(--pas) * 1.5);
  background: var(--surface); border-bottom: 1px solid var(--bord);
}
.barre .marque { font-weight: 700; color: var(--accent); text-decoration: none; }
.barre nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.barre nav a {
  padding: 6px 10px; border-radius: var(--r-s); text-decoration: none;
  color: var(--texte-doux); font-size: 15px;
}
.barre nav a:hover { background: var(--surface-alt); color: var(--texte); }
.barre nav a[aria-current="page"] { background: var(--accent-doux); color: var(--accent); font-weight: 600; }
.barre .qui { font-size: 13px; color: var(--texte-doux); }

/* --- blocs --- */
.carte {
  background: var(--surface); border: 1px solid var(--bord);
  border-radius: var(--r-m); padding: calc(var(--pas) * 1.5);
  margin-bottom: calc(var(--pas) * 1.5); box-shadow: var(--ombre);
}
.carte > h2 { margin-top: 0; }

h1 { font-size: 1.5rem; margin: 0 0 var(--pas); }
h2 { font-size: 1.15rem; margin: calc(var(--pas) * 2) 0 var(--pas); }
h3 { font-size: 1rem; margin: calc(var(--pas) * 1.5) 0 6px; color: var(--texte-doux);
     text-transform: uppercase; letter-spacing: .04em; font-size: .8rem; }

.discret { color: var(--texte-doux); font-size: .875rem; }
.note { color: var(--texte-doux); font-size: .8125rem; font-style: italic; margin: 2px 0 0 30px; }

/* --- lignes cochables : le cœur de la checklist --- */
.lignes { list-style: none; margin: 0; padding: 0; }
.ligne {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 4px; border-bottom: 1px solid var(--bord);
  min-height: var(--touche);
}
.ligne:last-child { border-bottom: 0; }

/* Case en attente du second appui. Le message passe à la ligne (flex-basis
   100 %) plutôt que de rétrécir le libellé du client, qui reste l'information
   principale. */
.ligne { flex-wrap: wrap; }
.ligne.a-confirmer {
  background: color-mix(in srgb, var(--alerte) 14%, transparent);
  border-radius: var(--r-s);
}
.ligne.a-confirmer input[type="checkbox"] {
  outline: 2px solid var(--alerte); outline-offset: 2px;
}
.ligne.a-confirmer::after {
  content: "Appuyez à nouveau pour valider";
  flex: 0 0 100%; margin-left: 34px;
  color: var(--alerte); font-size: .8125rem; font-weight: 600;
}

/* Visible des lecteurs d'écran uniquement (le repère visuel est le surlignage). */
.hors-ecran {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ligne input[type="checkbox"] {
  width: 24px; height: 24px; margin: 0; flex: 0 0 auto; accent-color: var(--accent);
}
.ligne .corps { flex: 1; min-width: 0; }
.ligne.faite .corps { opacity: .65; text-decoration: line-through; }
.ligne.faite .note { text-decoration: none; }
.ligne .par { font-size: .75rem; color: var(--texte-doux); }

.etiquette {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: .75rem; background: var(--surface-alt); color: var(--texte-doux);
  border: 1px solid var(--bord); white-space: nowrap;
}
.etiquette.du { background: color-mix(in srgb, var(--alerte) 15%, transparent); color: var(--alerte); }
.etiquette.solde { background: var(--accent-doux); color: var(--accent); }
/* Trop-perçu : Maeva l'affiche à tort comme « à encaisser ». Il doit trancher
   visuellement du « dû », sinon on réclame de l'argent à qui a déjà trop payé. */
.etiquette.alerte { background: color-mix(in srgb, var(--danger) 15%, transparent);
                    color: var(--danger); border-color: var(--danger); font-weight: 600; }
.vol { font-weight: 600; }
.averifier { color: var(--alerte); font-weight: 600; }

/* --- formulaires & boutons --- */
input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%; padding: 10px; font: inherit; color: var(--texte);
  background: var(--surface-alt); border: 1px solid var(--bord-fort);
  border-radius: var(--r-s); min-height: var(--touche);
}
textarea { min-height: 40vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
label { display: block; font-size: .875rem; color: var(--texte-doux); margin: var(--pas) 0 4px; }

.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--touche); padding: 10px 16px; font: inherit; font-weight: 600;
  color: var(--sur-accent); background: var(--accent); border: 0; border-radius: var(--r-s);
  cursor: pointer; text-decoration: none;
}
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.bouton.second { background: var(--surface-alt); color: var(--texte);
                 border: 1px solid var(--bord-fort); }
.bouton.danger { background: var(--danger); }
.bouton.large { width: 100%; }

/* --- tableaux (heures, vols, occupation) : scrollables, jamais la page --- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--bord); white-space: nowrap; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--texte-doux); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-alt); }
tr.total td { font-weight: 700; border-top: 2px solid var(--bord); }

/* --- messages --- */
.message {
  padding: 10px 12px; border-radius: var(--r-s); margin-bottom: var(--pas);
  border: 1px solid var(--bord); background: var(--surface-alt);
}
.message.success { background: var(--accent-doux); border-color: var(--accent); color: var(--accent); }
.message.error { background: color-mix(in srgb, var(--danger) 12%, transparent);
                 border-color: var(--danger); color: var(--danger); }
.message.warning { background: color-mix(in srgb, var(--alerte) 12%, transparent);
                   border-color: var(--alerte); color: var(--alerte); }

/* --- statuts d'inventaire --- */
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.st-ok       { background: var(--ok); }
.st-bientot  { background: var(--alerte); }
.st-racheter { background: var(--danger); }
.st-commande { background: #6b7fd7; }
.st-appro    { background: #9b6bd7; }

/* --- état d'un run --- */
.journal {
  background: var(--surface-alt); border: 1px solid var(--bord); border-radius: var(--r-s);
  padding: 10px; font-family: ui-monospace, monospace; font-size: 13px;
  max-height: 40vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
}

/* --- bloc de saisie des quantités ---
   Grille 2 colonnes : l'intitulé au-dessus du champ, pour que « Inventaire du
   jour » soit lisible en permanence. En v1 ces champs n'avaient qu'un
   placeholder, qui disparaît dès qu'on tape — donc plus rien n'indiquait ce
   qu'on était en train de saisir. */
.statuts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.bouton-cycle { min-height: 38px; padding: 4px 12px; font-size: .85rem; font-weight: 600; }
/* Les deux cycles se distinguent au premier coup d'œil : le terrain constate,
   l'appro achemine. Confondre les deux boutons, c'est poser le mauvais statut. */
.cycle-terrain { border-left: 3px solid var(--accent); }
.cycle-appro   { border-left: 3px solid #9b6bd7; }

.retirer { margin-left: auto; }
.bouton-retirer {
  min-width: 38px; min-height: 38px; padding: 0 10px;
  font: inherit; color: var(--texte-doux);
  background: transparent; border: 1px solid var(--bord); border-radius: var(--r-s);
  cursor: pointer;
}
.bouton-retirer:hover { color: var(--danger); border-color: var(--danger); }

.pied-categorie {
  padding: 0 calc(var(--pas) * 1.5) calc(var(--pas) * 1.5);
  border-top: 1px dashed var(--bord); margin-top: var(--pas); padding-top: var(--pas);
}
.ajout-article { display: flex; gap: var(--pas); }
.ajout-article input { flex: 1; }

/* Action destructrice : discrète au repos, elle ne doit pas concurrencer
   « Ajouter » du regard, mais rester atteignable au doigt (44 px). */
.bouton-retirer-cat {
  margin-top: var(--pas); min-height: var(--touche);
  padding: 8px 12px; font: inherit; font-size: .8125rem;
  color: var(--texte-doux); background: transparent;
  border: 1px dashed var(--bord-fort); border-radius: var(--r-s); cursor: pointer;
}
.bouton-retirer-cat:hover { color: var(--danger); border-color: var(--danger); }
/* Le double appui surligne normalement la .ligne parente ; ici il n'y en a pas,
   on marque donc le bouton lui-même. */
.bouton-retirer-cat.a-confirmer,
.bouton-retirer.a-confirmer {
  color: var(--alerte); border-color: var(--alerte); border-style: solid;
  background: color-mix(in srgb, var(--alerte) 14%, transparent);
}
.quantites {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 4px 10px; margin-top: 10px;
  padding-top: 10px; border-top: 1px dashed var(--bord);
}
.quantites label { margin: 0; grid-row: 1; font-size: .75rem; }
.quantites input { grid-row: 2; min-height: 40px; }

/* --- catégories repliables ---
   Le pliage est natif (<details>). Le chevron du navigateur est remplacé par le
   nôtre : Safari iOS ne dessine pas le même, et un repère qui change de forme
   d'un téléphone à l'autre se lit moins bien qu'un repère constant. */
.barre-pli { display: flex; gap: var(--pas); margin-bottom: var(--pas); flex-wrap: wrap; }
.barre-pli .bouton { min-height: 38px; padding: 6px 12px; font-size: .875rem; font-weight: 500; }

details.cat { padding: 0; }
details.cat > summary {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: calc(var(--pas) * 1.5); cursor: pointer;
  list-style: none; min-height: var(--touche);
  border-radius: var(--r-m);
}
details.cat > summary::-webkit-details-marker { display: none; }   /* Safari */
details.cat > summary::before {
  content: "▸"; flex: none; color: var(--accent);
  font-size: 1rem; transition: transform .15s;
}
details.cat[open] > summary::before { transform: rotate(90deg); }
details.cat > summary:hover { background: var(--surface-alt); }
details.cat > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cat-titre { font-weight: 700; font-size: 1.15rem; }
.cat-resume { margin-left: auto; font-size: .8125rem; color: var(--texte-doux); white-space: nowrap; }
.cat-resume b { color: var(--danger); }
details.cat > .lignes { padding: 0 calc(var(--pas) * 1.5) var(--pas); }

/* --- dialogue de confirmation (élément <dialog> natif) --- */
.dialogue {
  max-width: 26rem; width: calc(100% - 2rem);
  padding: calc(var(--pas) * 2);
  color: var(--texte); background: var(--surface);
  border: 1px solid var(--bord-fort); border-radius: var(--r-m);
  box-shadow: var(--ombre);
}
.dialogue::backdrop { background: rgb(0 0 0 / 55%); }
.dialogue h2 { margin-top: 0; }
.actions-dialogue {
  display: flex; gap: var(--pas); justify-content: flex-end;
  margin: calc(var(--pas) * 2) 0 0; padding: 0; list-style: none; flex-wrap: wrap;
}
.actions-dialogue .bouton { flex: 1 1 auto; }

/* htmx : indication visuelle pendant une requête */
.htmx-request { opacity: .6; transition: opacity .1s; }

@media (max-width: 480px) {
  .enveloppe { padding: var(--pas); }
  .barre { flex-wrap: wrap; }
  .barre nav { width: 100%; margin-left: 0; }
}

/* --- identité ---
   Le logo est un dessin à l'encre NOIRE : posé tel quel, il disparaît sur le
   thème sombre. On l'utilise donc en MASQUE, ce qui lui fait prendre la couleur
   d'accent du thème — lisible dans les deux, et cohérent avec le reste. */
.barre .marque { display: inline-flex; align-items: center; gap: 10px; }
.logo {
  display: inline-block; width: var(--touche); height: var(--touche); flex: none;
  background-color: currentColor;
  -webkit-mask: url("../img/logo.svg") center / contain no-repeat;
  mask: url("../img/logo.svg") center / contain no-repeat;
}
.logo-grand { width: 96px; height: 96px; color: var(--accent); }

/* --- disponibilité des bungalows --- */
table.dispo td { text-align: center; font-size: .8125rem; }
table.dispo td.occupe { color: var(--alerte); font-weight: 600; }
table.dispo td.libre { color: var(--accent); }

/* --- listes de statut (remplacent les boutons de cycle) --- */
.liste-statut { display: inline-flex; flex-direction: column; gap: 2px; margin: 0; }
.liste-titre { font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
               color: var(--texte-doux); }
.liste-statut select { min-height: 38px; padding: 4px 8px; font-size: .85rem;
                       width: auto; min-width: 11rem; }
/* Un repère de couleur par métier, comme pour les anciens boutons : confondre
   les deux listes, c'est poser le mauvais statut. */
.liste-statut:first-child select { border-left: 3px solid var(--accent); }
.liste-statut:last-child select  { border-left: 3px solid #9b6bd7; }

/* --- tâche ajoutée à la main : texte modifiable en place ---
   Sélecteur `input.texte-modifiable` et non `.texte-modifiable` seul : la règle
   générale `input[type="text"]` a la même spécificité qu'une classe et l'aurait
   emporté — le champ s'affichait alors en pleine largeur, encadré, et rejetait
   la croix à la ligne. */
input.texte-modifiable {
  width: auto; min-width: 12rem; max-width: calc(100% - 4rem);
  min-height: 32px; padding: 2px 6px; font-size: 1rem;
  background: transparent; border: 1px dashed transparent;
}
input.texte-modifiable:hover { border-color: var(--bord-fort); }
input.texte-modifiable:focus { background: var(--surface-alt); border-style: solid;
                               border-color: var(--accent); }
.retirer-tache { display: inline-block; margin-left: 6px; vertical-align: middle; }
.retirer-tache .bouton-retirer { min-height: 32px; min-width: 32px; }
.ligne.faite input.texte-modifiable { text-decoration: line-through; }

/* Étiquette d'approvisionnement, à côté de celle du stock : les deux états
   coexistent, ils doivent se lire ensemble. */
.etiquette.appro { background: color-mix(in srgb, #9b6bd7 18%, transparent);
                   color: #9b6bd7; border-color: #9b6bd7; }

/* --- listes dérivées : des LISTES, pas des fiches ---
   Le produit et ses champs de saisie vivent dans sa catégorie. Ici on lit, on
   copie, on envoie : une ligne par article, rien à manipuler. */
.ligne.compacte { min-height: 0; padding: 6px 4px; gap: 6px; align-items: baseline; }
.liste-courses { padding: 0 calc(var(--pas) * 1.5); }
.pied-liste { margin: var(--pas) calc(var(--pas) * 1.5) calc(var(--pas) * 1.5); }
.pied-liste .bouton { min-height: 38px; padding: 6px 14px; font-size: .875rem; }

/* Liste déroulante d'appro dans une liste de courses : compacte, alignée à
   droite, elle ne doit pas concurrencer le nom du produit. */
.appro-compact { width: auto; min-width: 9rem; max-width: 14rem;
                 min-height: 32px; padding: 2px 6px; font-size: .8125rem;
                 margin-left: auto; border-left: 3px solid #9b6bd7; }

/* Accusé de réception d'un comptage : le champ se vide, un liseré vert dit
   pourquoi. Sans ce signal, le vidage passe pour une saisie perdue. */
input.enregistre {
  border-color: var(--ok);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--ok) 35%, transparent);
  transition: box-shadow .2s ease;
}
