/* ============================================================================
   GÉNÉRATION DES HEURES — /app/generation-heures
   Maquette « Génération des heures » (docs/modeles/design_handoff_generation_heures),
   reprise le 2026-09-30.

   SA FEUILLE, ET RIEN QUE LA SIENNE : le flux à quatre temps n'existe que sur cet écran.
   Ce qui est partagé vient du gabarit — cadre d'écran (.ecran-*), boutons (.mx-btn,
   .mx-btn-cta), bandeau à lignes marquées (.mx-signal), rangée critique (.tbl-critique),
   liste en cartes et panneau replié sous 1024 px (.mx-liste-cartes), fenêtres (.mx-modale-*).

   Aucune couleur en dur : tout passe par les jetons --et-*.
   ========================================================================= */

/* ---------------------------------------------------------------------------
   0. L'EN-TÊTE — la période y monte, à 44 px : elle borne ce qui est calculé, et le
   panneau replié la cachait avec lui. Ses deux listes (année, période) se posent côte à
   côte ; le composant les empile par défaut pour une colonne de filtres. */
.gen-outils { align-items: stretch; flex-wrap: wrap; }
.gen-outils > .mx-btn { min-height: 44px; }

.gen-periode {
    display: flex; flex-direction: column; justify-content: center; gap: 2px;
    min-width: 280px; padding: 2px 10px 4px;
    background: var(--et-surface); border: 1px solid var(--et-bord-champ);
}
.gen-periode-lbl { font-size: 12px; color: var(--et-muted); }
.gen-periode > div { grid-template-columns: 84px minmax(0, 1fr); }
.gen-periode .gen-periode-choix {
    min-height: 32px; padding-top: 2px; padding-bottom: 2px;
    border: 0; border-radius: 0; background-color: transparent;
    font-size: 14px; font-weight: 600; color: var(--et-ink);
}

/* ---------------------------------------------------------------------------
   1. LE CORPS — colonne unique, sections empilées. */
.gen-colonne { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.gen-colonne > .mx-signal { margin-bottom: 0; }

/* ---------------------------------------------------------------------------
   2. LE RAIL D'ÉTAPES — il dit où l'on est et ce qu'il reste à faire ; on ne clique pas
   dessus. L'étape courante porte son décompte. */
.gen-rail {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
    background: var(--et-hairline); border: 1px solid var(--et-hairline);
}
.gen-etape { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 14px; background: var(--et-surface); }
.gen-etape.est-actif { background: var(--et-tint); box-shadow: inset 0 -3px 0 var(--et-form-blue); }
.gen-etape-num {
    flex: none; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 13px; font-weight: 700;
    background: var(--et-surface); color: var(--et-muted); border: 1px solid var(--et-bord-champ);
}
.gen-etape.est-actif .gen-etape-num { background: var(--et-form-blue); border-color: var(--et-form-blue); color: var(--et-sur-aplat); }
/* Faite : l'encre verte sur son fond pâle — le blanc sur le vert tombait à 1,5:1 en sombre. */
.gen-etape.est-faite .gen-etape-num { background: var(--et-succes-bg); border-color: var(--et-succes-ink); color: var(--et-succes-ink); }
.gen-etape-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.gen-etape-titre { font-size: 13px; color: var(--et-ink); }
.gen-etape-detail { font-size: 12px; color: var(--et-muted); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------------------
   3. LE BLOC — cadre commun des sections. Filets et surfaces plates. */
.gen-bloc { background: var(--et-surface); border: 1px solid var(--et-hairline); min-width: 0; }
.gen-bloc-tete {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px;
    padding: 14px 20px; border-bottom: 1px solid var(--et-hairline);
}
.gen-bloc-titres { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; min-width: 0; }
.gen-bloc-titre { margin: 0; flex: 1 1 auto; font-size: 16px; font-weight: 700; color: var(--et-ink); }
.gen-bloc-meta { font-size: 13px; color: var(--et-muted); }
.gen-bloc-tete > .mx-btn { min-height: 36px; }
.gen-vide { padding: 14px 20px; font-size: 13px; color: var(--et-muted); }
.gen-methode { margin: 0; padding: 10px 16px 14px; font-size: 12px; line-height: 1.5; color: var(--et-faint); }
.gen-code { font-family: var(--et-font-mono); font-weight: 600; color: var(--et-form-blue-d); }

.est-moins { color: var(--et-danger-ink); }
.est-plus  { color: var(--et-avertissement-ink); }
.est-avert { color: var(--et-avertissement-ink); }
.est-ok    { color: var(--et-succes-ink); }

/* La pastille d'état — trois couleurs, trois sens : rouge interdit, ambre se reconnaît,
   vert est levé. L'encre est le rang -ink, jamais la couleur d'état sur son propre fond. */
.gen-puce {
    flex: none; display: inline-flex; align-items: center; height: 24px; padding: 0 10px;
    border-radius: 12px; border: 1px solid var(--et-hairline);
    font-size: 12px; font-weight: 700; white-space: nowrap;
}
.gen-puce.est-bloquant { background: var(--et-danger-badge-bg); color: var(--et-danger-ink); border-color: var(--et-danger-bord); }
.gen-puce.est-avert    { background: var(--et-avertissement-bg); color: var(--et-avertissement-ink); }
.gen-puce.est-leve     { background: var(--et-succes-bg); color: var(--et-succes-ink); }

/* ---------------------------------------------------------------------------
   4. LES CONTRÔLES PRÉALABLES */
.gen-ctrl {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px;
    padding: 12px 20px; border-bottom: 1px solid var(--et-hairline);
}
.gen-ctrl.est-bloquant { background: var(--et-danger-badge-bg); box-shadow: inset 3px 0 0 var(--et-danger); }
.gen-ctrl-txt { display: flex; flex-direction: column; gap: 2px; flex: 1 1 260px; min-width: 0; }
.gen-ctrl-titre { font-size: 14px; color: var(--et-ink); }
.gen-ctrl-detail { font-size: 13px; color: var(--et-muted); }
.gen-ctrl-val { font-family: var(--et-font-mono); font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--et-ink); }
.gen-traiter {
    display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 4px;
    font-size: 14px; font-weight: 700; color: var(--et-form-blue-d); text-decoration: none;
}
.gen-traiter:hover { text-decoration: underline; }

.gen-reco {
    display: flex; align-items: flex-start; gap: 12px; margin: 0;
    padding: 14px 20px; background: var(--et-avertissement-bg); cursor: pointer;
}
.gen-reco-case { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--et-form-blue); }
.gen-reco-txt { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--et-ink); }   /* muted tombait à 4,46:1 sur l'ambre pâle, en sombre */
.gen-reco-txt > strong { font-size: 14px; color: var(--et-ink); }
.gen-raison {
    margin: 0; padding: 12px 20px; border-top: 1px solid var(--et-hairline);
    font-size: 13px; font-weight: 600; color: var(--et-danger-ink);
}

.gen-trace-ligne {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
    padding: 12px 20px; border-bottom: 1px solid var(--et-hairline);
}
.gen-trace-ligne:last-child { border-bottom: 0; }
.gen-trace-num { font-family: var(--et-font-mono); font-size: 13px; font-weight: 600; color: var(--et-form-blue-d); }
.gen-trace-txt { flex: 1 1 240px; min-width: 0; font-size: 13px; color: var(--et-muted); }

/* ---------------------------------------------------------------------------
   5. L'APERÇU — signal, résultat, traçabilité, clôture. */

.gen-signal-titre { margin: 0; font-size: 14px; font-weight: 700; color: var(--et-danger-ink); }
.gen-signal .mx-signal-ligne { flex-wrap: wrap; }
.gen-signal-txt { flex: 1 1 280px; min-width: 0; }
.gen-lien {
    display: inline-flex; align-items: center; min-height: 28px; padding: 0; border: 0; background: none;
    font: inherit; font-size: 13px; font-weight: 600; color: var(--et-form-blue-d); white-space: nowrap; cursor: pointer;
}
.gen-lien:hover { text-decoration: underline; }

.gen-delta {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%;
    min-height: 44px; padding: 8px 20px; border: 0; border-bottom: 1px solid var(--et-hairline);
    background: var(--et-surface); font: inherit; font-size: 13px; color: var(--et-ink); text-align: left; cursor: pointer;
}
.gen-delta:hover { background: var(--et-rang); }
.gen-delta-val { font-family: var(--et-font-mono); font-weight: 700; }

/* Le tri — deux boutons, le retenu en ardoise. */
.gen-tri { display: flex; }
.gen-tri > button {
    min-height: 44px; padding: 0 14px; border: 1px solid var(--et-form-border); background: var(--et-surface);
    font: inherit; font-size: 13px; font-weight: 600; color: var(--et-ink); cursor: pointer; white-space: nowrap;
}
.gen-tri > button + button { border-left: 0; }
.gen-tri > button.est-actif { background: var(--et-table-head); border-color: var(--et-table-head); color: var(--et-sur-ardoise-plein); }

.gen-qui { display: flex; flex-direction: column; gap: 2px; }
.gen-qui > strong { font-size: 14px; overflow-wrap: anywhere; }
.gen-qui > span { font-size: 12px; color: var(--et-muted); }
.gen-qui > strong, .gen-qui > span { display: block; }
.gen-ouvrir { padding: 0 !important; text-align: center; }
/* La hauteur d'une ligne au bureau ; 44 px seulement là où la règle tactile la demande
   (docs/cibles-tactiles.md) — posés partout, ils faisaient des rangées de 53 px (2026-10-26). */
.gen-ouvrir > button {
    width: 32px; height: 24px; border: 0; background: transparent; color: var(--et-muted); cursor: pointer;
}
@media (max-width: 1024px), (any-pointer: coarse) {
    .gen-ouvrir > button { width: 44px; height: 44px; }
}
.gen-ouvrir > button:hover { color: var(--et-form-blue-d); }

.gen-total {
    display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 16px;
    padding: 12px 16px; border-top: 2px solid var(--et-table-head); background: var(--et-surface-2); font-size: 13px;
}
.gen-total > span { font-family: var(--et-font-mono); font-weight: 600; }

/* La traçabilité, repliée sur une ligne. */
.gen-tracabilite > summary {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px;
    min-height: 44px; padding: 8px 20px; cursor: pointer; list-style: none;
}
.gen-tracabilite > summary::-webkit-details-marker { display: none; }
.gen-tracabilite > summary::before {
    content: ""; flex: none; width: 8px; height: 8px;
    border-right: 2px solid var(--et-muted); border-bottom: 2px solid var(--et-muted);
    transform: rotate(-45deg); transition: transform .15s;
}
.gen-tracabilite[open] > summary::before { transform: rotate(45deg); }
.gen-tracabilite > summary > strong { font-size: 14px; }
.gen-trace {
    margin: 0; padding: 4px 20px 8px; border-top: 1px solid var(--et-hairline);
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px;
}
.gen-trace-champ { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--et-hairline); }
.gen-trace-champ > dt { font-size: 13px; font-weight: 600; color: var(--et-muted); }
.gen-trace-champ > dd { margin: 0; font-size: 13px; color: var(--et-ink); overflow-wrap: anywhere; }
.gen-trace-champ > dd.mono { font-family: var(--et-font-mono); }
.gen-trace-champ > dd ul { margin: 0; padding-left: 16px; }
.gen-absent { color: var(--et-muted); }

/* La clôture : un filet orange en tête, le seul bouton orange de l'aperçu. */
.gen-cloture {
    display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; padding: 16px 20px;
    background: var(--et-surface); border: 1px solid var(--et-hairline); border-top: 3px solid var(--et-action);
}
.gen-cloture.est-retour { border-top-color: var(--et-hairline); }
.gen-cloture-txt { display: flex; flex-direction: column; gap: 4px; flex: 1 1 360px; min-width: 0; font-size: 13px; line-height: 1.5; color: var(--et-muted); }
.gen-cloture > .mx-btn { min-height: 44px; }

/* ---------------------------------------------------------------------------
   6. LA PÉRIODE CLÔTURÉE */
.gen-close > .gen-trace { border-top: 0; }
.gen-duo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; padding: 12px 20px 16px; }
.gen-sous-titre { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--et-ink); }
.gen-liste { margin: 0; padding-left: var(--et-puce-retrait); display: flex; flex-direction: column; gap: calc(var(--et-puce-li-ecart) * 2); font-size: 13px; line-height: 1.5; color: var(--et-ink); }
.gen-liste > li.est-moins::marker { color: var(--et-danger); }

/* ---------------------------------------------------------------------------
   7. LE DÉTAIL PAR JOUR — par semaine, repos regroupés. */
.gen-fermer {
    flex: none; width: 44px; height: 44px; margin-left: auto; border: 0; background: transparent;
    color: inherit; display: grid; place-items: center; cursor: pointer;
}
.gen-detail-corps { padding: 0; }
/* Le sous-titre de la fenêtre (matricule, service, bornes) se replie plutôt que d'être
   coupé par « … » au téléphone : les bornes sont la moitié de l'information. */
.gen-detail .mx-modale-sous { white-space: normal; overflow: visible; text-overflow: clip; }
.gen-det-resume { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--et-hairline); }
.gen-det-resume > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 16px; border-right: 1px solid var(--et-hairline); }
.gen-det-resume > div:last-child { border-right: 0; }
.gen-det-resume span { font-size: 12px; color: var(--et-muted); }
.gen-det-resume strong { font-family: var(--et-font-mono); font-size: 16px; }

.gen-jours { width: 100%; border-collapse: collapse; font-size: 13px; }
.gen-jours thead th { padding: var(--et-cellule-tete-y) 12px; background: var(--et-table-head); color: var(--et-sur-ardoise-plein); font-weight: 600; text-align: left; white-space: nowrap; }
.gen-jours thead th:first-child, .gen-jours td:first-child { padding-left: 16px; }
.gen-jours td { padding: var(--et-cellule-y) 12px; border-top: 1px solid var(--et-hairline); color: var(--et-ink); vertical-align: baseline; }
.gen-jours .num { text-align: right; font-family: var(--et-font-mono); }
.gen-jours thead th.num { font-family: inherit; }
.gen-jours td.est-vide { color: var(--et-muted); }
.gen-jours td.est-moins { color: var(--et-danger-ink); font-weight: 700; }
.gen-j-jour { font-weight: 700; white-space: nowrap; }
.gen-j-pointages { font-family: var(--et-font-mono); white-space: nowrap; }
.gen-j-obs.est-moins { font-weight: 600; }
.gen-jours tr.est-repos > td { padding-top: var(--et-cellule-y); padding-bottom: var(--et-cellule-y); background: var(--et-surface-2); color: var(--et-muted); }
.gen-semaine > th {
    padding: 8px 16px; background: var(--et-surface-3); border-top: 1px solid var(--et-form-border);
    font-weight: 700; text-align: left; color: var(--et-ink);
}
.gen-semaine > th { position: relative; }
.gen-semaine-total { float: right; font-family: var(--et-font-mono); font-weight: 600; }

/* ---------------------------------------------------------------------------
   8. LA FENÊTRE DE PROGRESSION */
.gen-prog-barre { height: 8px; background: var(--et-piste); overflow: hidden; }
.gen-prog-jauge { height: 100%; background: var(--et-form-blue); transition: width .2s; }
.gen-prog-jauge.est-positif { background: var(--et-succes); }
.gen-prog-jauge.est-negatif { background: var(--et-danger); }
.gen-prog-pct { margin-top: 6px; font-family: var(--et-font-mono); font-size: 12px; color: var(--et-muted); }
.gen-phases { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.gen-phase { display: flex; align-items: center; gap: 10px; }

.gen-phase-puce {
    flex: none;
    width: 18px; height: 18px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--et-surface-2);
    color: var(--et-inerte);
    font-size: 12px;
}

.gen-phase.est-faite .gen-phase-puce { background: var(--et-succes-bg); color: var(--et-succes-ink); }
.gen-phase-lbl { flex: 1; min-width: 0; font-size: 13px; color: var(--et-faint); }
.gen-phase.est-faite .gen-phase-lbl, .gen-phase.est-courante .gen-phase-lbl { color: var(--et-ink); }

/* Le « Meta » de la cinquième phase porte les natures calculées ÉCARTÉES pour formule
   illisible. Il s'affiche : une formule écartée ne fait pas échouer la génération, et
   c'est bien pour cela qu'elle passerait inaperçue. */
.gen-phase-meta { flex: none; max-width: 55%; font-size: 12px; color: var(--et-faint); text-align: right; }

.gen-bilan {
    margin-top: 14px;
    padding: 10px 13px;
    background: var(--et-succes-bg);
    border: 1px solid var(--et-succes-bord);
    font-size: 13px;
    line-height: 1.55;
    color: var(--et-succes-ink);
}

.gen-bilan.est-negatif { background: var(--et-danger-badge-bg); border-color: var(--et-danger-bord); color: var(--et-danger-ink); }

/* ---------------------------------------------------------------------------
   13. LA COLONNE DE L'ÉCRAN — les blocs s'empilent avec la même gouttière que la
   grille de l'écran, pour que rien ne flotte entre deux mesures. */
.gen-colonne { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.gen-pile { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gen-phases { list-style: none; padding: 0; margin-bottom: 0; }
.gen-bilan-duree { color: var(--et-muted); }

/* ---------------------------------------------------------------------------
   9. LES PALIERS — 1100 (traçabilité), 1024 (cartes), 640 (téléphone). */
@media (max-width: 1100px) {
    .gen-trace { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
    .gen-outils { flex: 1 1 100%; }
    .gen-periode .gen-periode-choix { min-height: 44px; }
    .gen-bloc-tete > .mx-btn { min-height: 44px; }
    .gen-lien { min-height: 44px; }

    .gen-det-resume { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gen-det-resume > div { border-bottom: 1px solid var(--et-hairline); }

    /* Le détail par jour en cartes : jour et heures du jour en tête, nature et pointages
       dessous, l'observation en dernier. */
    .gen-jours, .gen-jours tbody { display: block; }
    .gen-jours thead { display: none; }
    .gen-jours tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 9px 12px; border-top: 1px solid var(--et-hairline); }
    .gen-jours td { display: block; padding: 0 !important; border: 0; }
    .gen-jours tr.est-repos { background: var(--et-surface-2); padding-top: 6px; padding-bottom: 6px; }
    .gen-jours tr.est-repos > td { background: transparent; }
    .gen-jours tr.est-repos > td:last-child { display: none; }
    .gen-j-jour { flex: 1 1 auto; }
    .gen-j-nature { color: var(--et-muted); }
    .gen-jours td.num.est-vide { display: none; }
    .gen-jours td.num[data-lib]::before { content: attr(data-lib) " "; font-family: var(--et-font); color: var(--et-muted); }
    .gen-j-obs { flex: 1 1 100%; }
    .gen-j-obs.est-vide { display: none; }
    .gen-semaine { display: block !important; padding: 0 !important; }
    .gen-semaine > th { display: block; padding: 8px 12px; }
}

@media (max-width: 640px) {
    .gen-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .gen-periode { flex: 1 1 100%; min-width: 0; }
    .gen-outils > .mx-btn { flex: 1 1 auto; justify-content: center; }
    .gen-bloc-tete { padding: 12px 14px; }
    .gen-ctrl, .gen-reco, .gen-raison, .gen-trace-ligne { padding-left: 14px; padding-right: 14px; }
    .gen-tri { flex: 1 1 100%; }
    .gen-tri > button { flex: 1 1 50%; }
    .gen-trace-champ { grid-template-columns: minmax(0, 1fr); gap: 2px; }
    .gen-duo { grid-template-columns: minmax(0, 1fr); }
    .gen-cloture > .mx-btn { flex: 1 1 100%; justify-content: center; }
}
