/* © 2026 Jean-Baptiste Guillon — Suite Atelier — Tous droits réservés. Reproduction, copie ou réutilisation interdites sans autorisation écrite. */
/* =========================================================================
   Suite Atelier — charte graphique commune (6 novembre 2026)
   Chargée par le serveur dans TOUTES les pages (accueil, modules, admin,
   connexion). Elle donne les mêmes couleurs, polices et la même barre du haut.
   Pour un nouveau module : sa couleur et son nom sont dans app/registre.js
   (le serveur ajoute la couleur du module dans la page).
   ========================================================================= */

/* ---------- Polices (fichiers sur le serveur, pas de Google) ---------- */
@font-face { font-family: "Lexend"; src: url("/interface/polices/lexend-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("/interface/polices/lexend-latin-600.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Lexend"; src: url("/interface/polices/lexend-latin-700.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/interface/polices/atkinson-latin-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/interface/polices/atkinson-latin-400-italique.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("/interface/polices/atkinson-latin-700.woff2") format("woff2"); font-weight: 600 900; font-display: swap; }

/* ---------- Couleurs de la marque ---------- */
:root {
  --sa-fond: #F7F5F0;      /* fond des pages */
  --sa-carte: #FFFFFF;     /* cartes, panneaux */
  --sa-encre: #23313A;     /* texte, barre du haut */
  --sa-doux: #5B6670;      /* texte secondaire */
  --sa-trait: #E4DED3;     /* bordures */
  --sa-moutarde: #E0A526;  /* touche de la marque (jamais pour du texte) */
  --sa-rouge: #B3261E;     /* supprimer, erreur */
  --sa-vert-ok: #2E7D32;   /* réussite */
  --sa-titres: "Lexend", "Segoe UI", system-ui, sans-serif;
  --sa-texte: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --sa-h-barre: 56px;
  /* couleur du module (par défaut : la marque) */
  --sa-m: #23313A; --sa-m-fonce: #182229; --sa-m-clair: #ECEAE4;
}

/* ---------- Une couleur par secteur : app/registre.js (posée par le serveur dans chaque page) ---------- */

/* ---------- Les anciennes couleurs des modules suivent la charte ----------
   (chaque module avait ses propres variables : on les redirige ici) */
html[data-module] {
  --fond: var(--sa-fond); --bg: var(--sa-fond);
  --bord: var(--sa-trait); --trait: var(--sa-trait);
  --texte: var(--sa-encre); --doux: var(--sa-doux);
  --carte: var(--sa-carte); --panneau: var(--sa-carte);
  --rouge: var(--sa-rouge); --alerte: var(--sa-rouge);
  --bleu: var(--sa-m); --bleu2: var(--sa-m-fonce);
}
html[data-module="espaces-verts"] { --vert: var(--sa-m); --vert-clair: var(--sa-m-clair); }
html[data-module="palettes"] { --bois: var(--sa-m); --bois-clair: var(--sa-m-clair); }
html[data-module="admin"], html[data-module="accueil"] { --bleu: var(--sa-encre); --bleu2: #3A4A55; }

/* ---------- Polices partout ---------- */
html[data-module] body { font-family: var(--sa-texte); background: var(--sa-fond); color: var(--sa-encre); }
html[data-module] button, html[data-module] input, html[data-module] select, html[data-module] textarea { font-family: inherit; }
html[data-module] h1, html[data-module] h2, html[data-module] h3, html[data-module] legend, html[data-module] th { font-family: var(--sa-titres); }
html[data-module] .page-a4, html[data-module] .page-a4 h1 { font-family: var(--sa-texte); } /* fiches atelier : chiffres très lisibles */

/* ---------- Boutons communs ---------- */
html[data-module] button { border-radius: 10px; }
html[data-module] button.danger, html[data-module] .danger { color: var(--sa-rouge); }
.sa-bouton { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border-radius: 12px; border: 2px solid var(--sa-encre); background: #fff; color: var(--sa-encre); font: 600 17px var(--sa-titres); text-decoration: none; cursor: pointer; }
.sa-bouton.principal { background: var(--sa-m); border-color: var(--sa-m); color: #fff; }
.sa-bouton.supprimer { background: var(--sa-rouge); border-color: var(--sa-rouge); color: #fff; }
:focus-visible { outline: 3px solid var(--sa-moutarde); outline-offset: 2px; }

/* ---------- La barre du haut, la même partout ---------- */
.sa-barre { position: relative; z-index: 40; flex: none; display: flex; align-items: center; gap: 12px; min-height: var(--sa-h-barre); padding: 0 16px; background: var(--sa-encre); color: #fff; font: 16px/1.2 var(--sa-titres); box-shadow: inset 0 -5px 0 var(--sa-m); padding-bottom: 5px; box-sizing: border-box; }
html[data-module="accueil"] .sa-barre { box-shadow: inset 0 -5px 0 var(--sa-moutarde); }
.sa-barre a { color: #fff; text-decoration: none; }
.sa-marque { display: flex; align-items: center; gap: 10px; min-height: 44px; border-radius: 10px; padding: 0 6px 0 0; }
.sa-marque:hover .sa-nom { text-decoration: underline; }
.sa-logo { width: 36px; height: 36px; border-radius: 10px; background: var(--sa-moutarde); display: grid; place-items: center; flex: none; }
.sa-logo svg { width: 25px; height: 25px; }
.sa-nom { font-weight: 700; font-size: 19px; white-space: nowrap; }
.sa-fil { color: #8C99A3; font-size: 20px; }
.sa-module { display: flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; font-size: 17px; white-space: nowrap; }
.sa-module:hover { text-decoration: underline; }
.sa-pastille { width: 14px; height: 14px; border-radius: 4px; background: var(--sa-m); box-shadow: 0 0 0 2px rgba(255,255,255,.85); }
.sa-espace { flex: 1; }
.sa-compte { display: flex; align-items: center; gap: 10px; font: 15px var(--sa-texte); color: #C5CDD3; }
.sa-initiales { width: 32px; height: 32px; border-radius: 50%; background: var(--sa-moutarde); color: var(--sa-encre); display: grid; place-items: center; font: 700 13px var(--sa-titres); flex: none; }
.sa-sortir { display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid #4A5A66; border-radius: 10px; color: #fff; font: 600 14px var(--sa-titres); }
.sa-sortir:hover { border-color: #fff; }
/* Fil Site › Atelier et menu du compte (plan de l'interface, étape 1d) */
.sa-site { display: flex; align-items: center; gap: 6px; font: 600 15px var(--sa-titres); white-space: nowrap; min-width: 0; }
.sa-barre [hidden] { display: none !important; }
.sa-site label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sa-site select { font: inherit; padding: 6px 8px; border-radius: 10px; border: 1px solid #C9D2D8; background: #fff; color: var(--sa-encre); max-width: 220px; min-width: 0; }
.sa-compte { position: relative; }
.sa-moi { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px; border: 0; border-radius: 10px; background: none; color: #C5CDD3; font: 15px var(--sa-texte); cursor: pointer; }
.sa-moi:hover { background: rgba(255,255,255,.08); }
.sa-menu-moi { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; display: flex; flex-direction: column; gap: 6px; min-width: 250px; max-width: calc(100vw - 20px); padding: 12px; background: #fff; color: var(--sa-encre); border: 1px solid var(--sa-trait); border-radius: 14px; box-shadow: 0 14px 34px rgba(0,0,0,.2); font: 15px var(--sa-texte); }
.sa-menu-moi span { color: var(--sa-doux); font-size: 14px; }
.sa-barre .sa-menu-moi a { display: flex; align-items: center; min-height: 42px; padding: 0 12px; border: 1px solid var(--sa-trait); border-radius: 10px; color: var(--sa-encre); background: var(--sa-fond); font: 600 15px var(--sa-titres); }
.sa-barre .sa-menu-moi a:hover { border-color: var(--sa-encre); }
@media (max-width: 720px) {
  .sa-barre { flex-wrap: wrap; row-gap: 0; }
  .sa-site select { max-width: 140px; }
}
@media (max-width: 720px) {
  .sa-barre { gap: 8px; padding: 0 10px 5px; }
  .sa-nom { font-size: 16px; }
  .sa-compte .sa-qui { display: none; }
  .sa-module { font-size: 15px; }
}
@media (max-width: 480px) { html:not([data-module="accueil"]) .sa-marque .sa-nom { display: none; } }

/* Les anciens boutons « ⌂ Suite » et logos « JB » sont remplacés par la barre */
html.sa-barre-on a[href="/"]:not(.sa-garder), html.sa-barre-on .logo-carre, html.sa-barre-on #lienDeconnexion { display: none !important; }

/* Pages qui occupent tout l'écran : on laisse la place de la barre */
html.sa-barre-on body:not(.apercu) #app { position: relative; height: calc(100vh - var(--sa-h-barre)); height: calc(100dvh - var(--sa-h-barre)); }

/* Jamais de barre à l'impression ni dans les aperçus */
body.apercu .sa-barre { display: none; }
@media print { .sa-barre { display: none !important; } }

/* ---------- Droits fins (6 novembre) ----------
   stockage-partage.js ajoute html.sans-supprimer / sans-creer / sans-modifier selon le compte.
   On cache les boutons de suppression connus des modules (le serveur refuse de toute façon). */
html.sans-supprimer #bSupprimer, html.sans-supprimer #btnSupprSite, html.sans-supprimer #zSuppr, html.sans-supprimer #fSuppr,
html.sans-supprimer [data-cl], html.sans-supprimer [data-msuppr], html.sans-supprimer [data-ss],
html.sans-supprimer #purge-ajouts, html.sans-supprimer #suppr-ref { display: none !important; }

/* ---------- Bandeau du module, à sa couleur, avec ses onglets (10 novembre) ----------
   S'applique tout seul aux en-têtes des modules faits sur le même modèle :
   <header class="barre"><h1>Module</h1><nav class="liens"><a class="actif">…</a>…</nav></header>
   (Conditionnement, Horticulture, Couture, Métallerie…) et à l'Administration (nav.onglets). */
html.sa-barre-on header.barre:has(> nav.liens),
html.sa-barre-on body > header:has(> nav.onglets) {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 20px;
  margin: 0; padding: 0 16px; min-height: 58px; box-sizing: border-box;
  background: var(--sa-m); color: #fff; border: 0; box-shadow: none;
}
html.sa-barre-on header.barre:has(> nav.liens) h1,
html.sa-barre-on body > header:has(> nav.onglets) h1 {
  align-self: center; margin: 10px 0; color: #fff; font: 700 21px/1.2 var(--sa-titres);
}
html.sa-barre-on header.barre > nav.liens,
html.sa-barre-on body > header > nav.onglets {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 0 auto; padding: 8px 0 0; align-self: flex-end; background: none; border: 0;
}
html.sa-barre-on header.barre > nav.liens a,
html.sa-barre-on body > header > nav.onglets button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 18px; margin: 0;
  border: 0; border-radius: 12px 12px 0 0; background: transparent; color: #fff;
  font: 600 16px var(--sa-titres); text-decoration: none; box-shadow: none; cursor: pointer;
}
html.sa-barre-on header.barre > nav.liens a:hover:not(.actif),
html.sa-barre-on body > header > nav.onglets button:hover:not(.actif) { background: rgba(255,255,255,.16); border: 0; }
html.sa-barre-on header.barre > nav.liens a.actif,
html.sa-barre-on body > header > nav.onglets button.actif { background: var(--sa-fond); color: var(--sa-encre); }
/* Liseré inutile quand le bandeau du module suit directement la barre */
html.sa-barre-on body:has(header.barre > nav.liens) .sa-barre,
html.sa-barre-on body:has(> header > nav.onglets) .sa-barre { box-shadow: none; padding-bottom: 0; }
/* En-tête vide qui ne contenait que l'ancien bouton « ⌂ Suite » (Machines) */
html.sa-barre-on header.ancien { display: none; }
@media (max-width: 720px) {
  html.sa-barre-on header.barre:has(> nav.liens), html.sa-barre-on body > header:has(> nav.onglets) { padding: 0 8px; gap: 0 10px; }
  html.sa-barre-on header.barre > nav.liens, html.sa-barre-on body > header > nav.onglets { margin-left: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  html.sa-barre-on header.barre > nav.liens a, html.sa-barre-on body > header > nav.onglets button { padding: 0 12px; font-size: 15px; white-space: nowrap; }
}
@media print { header.barre:has(> nav.liens), body > header:has(> nav.onglets) { display: none !important; } }
/* Brique Photos (app/briques/photos/page.js) : bloc « Photos » des fiches et photo en grand */
.photos-fiche { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 8px; }
.photos-fiche figure { position: relative; margin: 0; width: 112px; }
.photos-fiche img { width: 112px; height: 112px; object-fit: cover; border-radius: 10px; border: 1px solid #d6dbe3; background: #eceef2; cursor: zoom-in; display: block; }
.photos-fiche figcaption { font-size: 12px; margin-top: 3px; }
.photos-fiche figcaption select { width: 100%; font-size: 12px; padding: 2px; }
.photos-fiche [data-retirer] { position: absolute; top: 4px; right: 4px; padding: 0 7px; min-height: 0; line-height: 22px; border-radius: 8px; }
.photos-ajout { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
dialog.photo-grande { padding: 0; border: 0; border-radius: 14px; width: auto; max-width: 96vw; }
dialog.photo-grande img { display: block; max-width: 96vw; max-height: 80vh; }
dialog.photo-grande .dlg-pied { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; }
@media print { .photos-fiche, .photos-ajout { display: none !important; } }
/* Cases de remarque libre : rappel de la règle des données ESAT (CLAUDE.md, documents/rgpd-suite.md) */
.avert-perso { display: block; font-weight: 400; font-size: 0.82em; color: #6B5A00; margin-top: 3px; }
@media print { .avert-perso { display: none; } }
/* En-tête des documents remis aux clients (Administration › Établissement, 23/11/2026) */
.doc-entete { display: flex; align-items: center; gap: 14px; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1.5px solid #333; font-size: 10pt; line-height: 1.3; color: #222; }
.doc-entete .doc-logo { max-height: 22mm; max-width: 45mm; object-fit: contain; }
.doc-entete .doc-nom { font-size: 13pt; font-weight: 700; }
/* Bouton « Enregistrer » toujours visible (demande de JB, 23/11/2026) : la barre reste collée en bas de l'écran
   (ou de la fenêtre) au lieu d'obliger à descendre tout en bas */
.barre-enregistrer { position: sticky; bottom: 0; z-index: 5; background: #fff; padding: 10px 12px; margin-left: -12px; margin-right: -12px;
  border-top: 1px solid #DCE2E6; box-shadow: 0 -8px 14px -12px rgba(0,0,0,.35); border-radius: 0 0 10px 10px; }
dialog .dlg-pied { position: sticky; bottom: 0; z-index: 5; background: #fff; }
@media print { .barre-enregistrer { position: static; box-shadow: none; border: 0; } }
.doc-entete.court { padding-bottom: 4px; margin-bottom: 6px; font-size: 9.5pt; }
.doc-entete.court .doc-logo { max-height: 9mm; }
/* Tableaux larges sur téléphone (24/11/2026, essai de JB) : la carte défile de côté au lieu d'élargir toute la page
   (sinon la barre du haut et le bandeau ne couvrent plus que la gauche de l'écran) */
.carte:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
