/* ════════════════════════════════════════════════════════════════════
   ZE FUITES — Design system « équipement de chantier »
   Public : plombiers terrain (gants, soleil, urgence, peu familiers UI).
   Principes : signalétique industrielle, contrastes francs, jaune
   sécurité pour l'action principale, cibles tactiles ≥ 52px, états
   impossibles à rater. Typo : Archivo Black (titres) / Archivo (corps).

   Règle d'or : AUCUN style de champ au cas par cas dans les vues.
   Tout type de champ hérite des règles génériques. Pour un nouveau
   composant : tokens d'abord, classe ensuite.
   ════════════════════════════════════════════════════════════════════ */

/* ── Fontes (vendorées, subset latin) ───────────────────────────── */
@font-face {
  font-family: "Archivo";
  src: url("/static/archivo-regular.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Archivo";
  src: url("/static/archivo-semibold.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}
@font-face {
  font-family: "Archivo Black";
  src: url("/static/archivo-black.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}

/* ── Tokens ──────────────────────────────────────────────────────── */
:root {
  --bleu: #002b5c;            /* bleu nuit ZE FUITES — en-têtes, titres */
  --bleu-2: #0a4a8f;          /* bleu intermédiaire */
  --jaune: #ffb400;           /* jaune sécurité — action principale */
  --jaune-soft: #fff3d6;
  --accent: #0066cc;
  --odoo: #714b67;
  --ok: #1e7d36;
  --ok-soft: #e8f5e9;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --bg: #eef1f4;
  --surface: #ffffff;
  --text: #15191e;
  --text-muted: #5b6570;
  --border: #b9c2cc;
  --radius: 6px;              /* coins francs, esthétique outil */
  --pad-field: 12px;
  --font: "Archivo", system-ui, sans-serif;
  --font-display: "Archivo Black", "Archivo", sans-serif;
  --shadow-press: 0 3px 0 rgba(0, 0, 0, .25);  /* bouton « physique » */
  --shadow-card: 0 1px 4px rgba(0, 30, 60, .12);
  --touch: 52px;              /* cible tactile : doigts mouillés + gants */
}

/* ── Base ────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
html {
  /* Empêche le rebond élastique / pull-to-refresh → ressenti « app ». */
  overscroll-behavior: none;
  /* Bloque le double-tap-to-zoom (et le délai de 300 ms) — la méta
     user-scalable=no est ignorée par iOS moderne, c'est ici que ça se joue.
     « manipulation » conserve le scroll, supprime seulement les gestes
     de zoom par tap. */
  touch-action: manipulation;
  /* Pas de surlignage bleu au tap, ni d'agrandissement auto du texte. */
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}
body {
  font-family: var(--font);
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(0, 43, 92, .025) 14px 28px),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  /* Pas de sélection de texte sur l'UI (comportement natif d'app)… */
  -webkit-user-select: none;
  user-select: none;
  /* …ni de menu contextuel long-press sur iOS. */
  -webkit-touch-callout: none;
}
/* …sauf dans les champs de saisie, où la sélection reste utile. */
input, textarea, select { -webkit-user-select: text; user-select: text; }

/* Header : barre bleu nuit + liseré « rubalise » jaune */
header {
  background: var(--bleu);
  color: white;
  /* Marge haute = encoche/Dynamic Island en mode standalone. */
  padding: calc(14px + env(safe-area-inset-top)) 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 4px solid var(--jaune);
}
header h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
header a { color: white; text-decoration: none; font-size: 1.3rem; }
/* Marge basse = barre d'accueil (home indicator) iPhone. */
main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 14px calc(40px + env(safe-area-inset-bottom));
}

/* ── Champs de formulaire : RÈGLE GÉNÉRIQUE ──────────────────────────
   Tout input textuel (text, password, email, tel, number, date, time,
   datetime-local…), select et textarea reçoit le même habillage.
   Ne JAMAIS restyler un champ individuellement. */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=submit]):not([type=button]),
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: var(--pad-field);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
textarea { min-height: 90px; resize: vertical; }
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23002b5c' stroke-width='2.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* Focus : impossible à rater (halo jaune sécurité) */
input:focus, select:focus, textarea:focus {
  outline: 3px solid var(--jaune);
  outline-offset: 0;
  border-color: var(--bleu);
}

/* Labels : petites capitales techniques */
label {
  display: block;
  margin: 14px 0 5px;
  font-weight: 600;
  font-size: .82rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--bleu);
}

/* ── Cases à cocher : l'état coché saute aux yeux ────────────────── */
input[type=checkbox], input[type=radio] {
  width: 26px;
  height: 26px;
  min-height: 0;
  accent-color: var(--ok);
  flex-shrink: 0;
}
.check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  min-height: var(--touch);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  font-size: 1.02rem;
  background: var(--surface);
  transition: background .15s, border-color .15s;
}
/* Ligne entière verte quand cochée (feedback périphérique) */
.check:has(input[type=checkbox]:checked) {
  background: var(--ok-soft);
  border-color: var(--ok);
}
.check label { margin: 0; text-transform: none; letter-spacing: 0; font-size: 1.02rem; color: var(--text); }

/* ── Champ obligatoire non satisfait : bordure rouge + libellé ─────── */
.err,
.err textarea,
.err select,
.err input {
  border-color: var(--danger) !important;
}
.check.err,
textarea.err,
select.err {
  border-color: var(--danger) !important;
  background: #fdecee;
}
.err-msg {
  display: inline-block;
  color: var(--danger);
  font-weight: 600;
  font-size: .85rem;
  margin: 2px 0 8px;
}
/* Wrapper d'un champ obligatoire en erreur : liseré rouge à gauche */
.fielderr {
  border-left: 4px solid var(--danger);
  padding-left: 10px;
  margin-bottom: 10px;
}

/* ── Boutons : « boutons physiques » d'outil ─────────────────────── */
.btn {
  display: inline-block;
  background: var(--jaune);
  color: #1a1a1a;
  border: none;
  border-radius: var(--radius);
  padding: 14px 22px;
  min-height: var(--touch);
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  letter-spacing: .02em;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  box-shadow: var(--shadow-press);
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 rgba(0,0,0,.25); }
.btn.full { width: 100%; }
.btn.secondary { background: var(--surface); color: var(--bleu); border: 2px solid var(--bleu); }
.btn.odoo { background: var(--odoo); color: white; }
.btn.recording { background: var(--danger); color: white; animation: zf-pulse 1.2s infinite; }
@keyframes zf-pulse { 50% { opacity: .75; } }

/* ── Cartes : sections signalées par un chant coloré ─────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border-left: 5px solid var(--bleu);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
  animation: zf-rise .25s ease-out both;
}
.card:nth-child(2) { animation-delay: .05s; }
.card:nth-child(3) { animation-delay: .1s; }
.card:nth-child(4) { animation-delay: .15s; }
@keyframes zf-rise { from { opacity: 0; transform: translateY(6px); } }
.card h2 {
  font-family: var(--font-display);
  font-size: .95rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin: 0 0 12px;
  color: var(--bleu);
}

/* ── Fil d'étapes : numéros lisibles, étape courante en jaune ────── */
.steps { display: flex; gap: 5px; margin-bottom: 18px; }
.steps span {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: var(--radius);
  background: #d3dae1;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: .85rem;
}
.steps span.done { background: var(--ok); color: white; }
.steps span.current {
  background: var(--jaune);
  color: #1a1a1a;
  outline: 2px solid var(--bleu);
  outline-offset: 1px;
}

/* ── Liste des interventions ─────────────────────────────────────── */
.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 12px;
  min-height: var(--touch);
  border-bottom: 1px solid #e2e7ec;
  text-decoration: none;
  color: inherit;
}
.item:hover, .item:active { background: var(--jaune-soft); }
.item small { color: var(--text-muted); }

.badge {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 3px;
  background: var(--bleu);
  color: white;
  white-space: nowrap;
}

/* ── Alertes : panneau de chantier ───────────────────────────────── */
.alert {
  background: var(--danger-soft);
  border: 2px solid var(--danger);
  border-left-width: 8px;
  color: var(--danger);
  font-weight: 600;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.progress {
  background: var(--jaune-soft);
  border: 2px dashed var(--jaune);
  border-radius: var(--radius);
  padding: 14px;
  font-size: .95rem;
  font-weight: 600;
}

audio { width: 100%; margin-top: 8px; }
img { max-width: 100%; }

/* ── Barre de progression de navigation (HTMX boost) ─────────────── */
#zf-bar {
  position: fixed;
  top: env(safe-area-inset-top); left: 0;
  height: 4px;
  width: 0;
  background: var(--jaune);
  box-shadow: 0 0 6px rgba(255, 180, 0, .7);
  z-index: 9999;
  opacity: 0;
  transition: width .3s ease, opacity .2s;
}
/* Pendant la requête : monte vite à 80% et patiente */
#zf-bar.run {
  opacity: 1;
  width: 80%;
  transition: width 2.5s cubic-bezier(.1, .7, .2, 1);
}
/* Réponse reçue : termine à 100% puis s'efface */
#zf-bar.run.done {
  width: 100%;
  transition: width .2s ease;
}
small { color: var(--text-muted); }

/* Loader d'analyse photo (Pixtral en arrière-plan) */
.zf-spin { display:inline-block; animation: zf-rot 1.2s linear infinite; }
@keyframes zf-rot { to { transform: rotate(360deg); } }
