/* app.css — Reanova Réception Travaux.
   Registre product, thème clair (lecture plein soleil), couleur Restrained. Neutres OKLCH teintés bleu ;
   statuts = hex du gabarit client (fidélité PDF/Excel). Mouvement = feedback d'état, ease-out-expo. Voir DESIGN.md. */
:root {
  /* Bleu Reanova + neutres OKLCH (jamais #000/#fff ; teinte 258) */
  --navy: oklch(0.33 0.085 258);   --banner: var(--navy);
  --banner-2: oklch(0.385 0.08 258);
  --header: oklch(0.52 0.13 256);  --blue: var(--header);
  --blue-press: oklch(0.46 0.13 256);
  --ink: oklch(0.27 0.022 258);
  --muted: oklch(0.53 0.022 258);
  --line: oklch(0.915 0.008 256);
  --bg: oklch(0.975 0.006 256);
  --card: oklch(0.995 0.0025 256);
  --zebra: oklch(0.966 0.008 256);
  --label: oklch(0.95 0.009 256);
  --soft: oklch(0.95 0.03 256);     /* fond bouton "soft" / chips */
  --ring: oklch(0.52 0.13 256 / 0.30);
  /* Statuts (gabarit client — conservés en hex pour la fidélité des exports) */
  --ok: #C6F6D5; --ok-ink: #22543D; --ok-acc: #2F855A;
  --warn: #FEEBC8; --warn-ink: #744210; --warn-acc: #C05621;
  --res: #FEFCBF; --res-ink: #744210; --res-acc: #B7791F;
  --bad: #FED7D7; --bad-ink: #822727; --bad-acc: #C53030;
  --wait: var(--label); --wait-ink: oklch(0.45 0.02 258); --wait-acc: oklch(0.6 0.02 258);
  --danger: #C53030;
  /* Élévation douce teintée */
  --shadow: 0 1px 2px oklch(0.33 0.06 258 / 0.05), 0 2px 8px oklch(0.33 0.06 258 / 0.06);
  --shadow-md: 0 4px 14px oklch(0.33 0.06 258 / 0.10);
  --shadow-lg: 0 14px 38px oklch(0.30 0.07 258 / 0.16);
  /* Rayons / cibles / mouvement */
  --r-sm: 10px; --r: 14px; --r-lg: 18px; --radius: var(--r);
  --tap: 46px;
  --dur-fast: 120ms; --dur: 180ms; --dur-slow: 250ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);   /* ease-out-expo */
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  font-size: 16px; line-height: 1.45; letter-spacing: -0.006em;
  overscroll-behavior-y: none; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--header); text-decoration: none; }
:focus-visible { outline: none; }

/* ---------- Mouvement : feedback d'état (jamais décoratif) ---------- */
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes sheet-up { from { transform: translateY(8%); opacity: 0.6 } to { transform: translateY(0); opacity: 1 } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }
@keyframes pop { 0% { transform: scale(0.8); opacity: 0 } 60% { transform: scale(1.04) } 100% { transform: scale(1); opacity: 1 } }
@keyframes shake { 10%,90%{transform:translateX(-1px)} 20%,80%{transform:translateX(2px)} 30%,50%,70%{transform:translateX(-6px)} 40%,60%{transform:translateX(6px)} }
.shake { animation: shake 0.4s var(--ease); }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(177deg, var(--banner), var(--banner-2));
  color: oklch(0.98 0.01 256);
  padding: calc(var(--safe-t) + 11px) 14px 11px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 oklch(0.2 0.05 258 / 0.5), var(--shadow);
}
.appbar .back, .appbar .act { width: var(--tap); height: var(--tap); display: grid; place-items: center; color: #fff; border-radius: 11px; transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.appbar .back { font-size: 24px; margin-left: -8px; }
.appbar .back:active, .appbar .act:active { background: oklch(1 0 0 / 0.14); transform: scale(0.92); }
.appbar .titles { flex: 1; min-width: 0; }
.appbar .titles h1 { margin: 0; font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .titles .sub { font-size: 12.5px; opacity: .82; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandmark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: oklch(1 0 0 / 0.14); font-weight: 800; font-size: 13px; }
.appbar-logo { height: 28px; width: auto; max-width: 190px; object-fit: contain; display: block; }

/* ---------- Layout ---------- */
.view { max-width: 920px; margin: 0 auto; padding: 16px 16px calc(100px + var(--safe-b)); animation: fade-in var(--dur) var(--ease); }
.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 22px 4px 9px; }
.muted { color: var(--muted); }
.center-empty { text-align: center; color: var(--muted); padding: 64px 24px; animation: rise-in var(--dur-slow) var(--ease); }
.center-empty .big { font-size: 46px; margin-bottom: 10px; opacity: .9; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.card + .card { margin-top: 12px; }
.card-pad { padding: 16px; }

/* Constat list item */
.constat-card { display: block; margin-bottom: 12px; transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease); animation: rise-in var(--dur-slow) var(--ease) both; }
.constat-card:active { transform: scale(0.985); }
.constat-card .top { display: flex; align-items: flex-start; gap: 10px; padding: 15px 16px 12px; }
.constat-card .type-chip { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--header); background: var(--soft); padding: 3px 9px; border-radius: 999px; align-self: flex-start; }
.constat-card h3 { margin: 8px 0 2px; font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.constat-card .meta { font-size: 12.5px; color: var(--muted); }
.constat-card .foot { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--zebra); font-size: 12.5px; color: var(--muted); }
.constat-card .foot .grow { flex: 1; }
@media (hover: hover) { .constat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); } }

/* ---------- Status pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 4px 10px 4px 8px; border-radius: 999px; line-height: 1.2; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.conforme, .pill.global-ok, .pill.levee { background: var(--ok); color: var(--ok-ink); }
.pill.a_reprendre, .pill.global-res { background: var(--warn); color: var(--warn-ink); }
.pill.sous_reserve { background: var(--res); color: var(--res-ink); }
.pill.non_conforme { background: var(--bad); color: var(--bad-ink); }
.pill.en_attente { background: var(--wait); color: var(--wait-ink); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 0 2px 6px; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 13px; min-height: var(--tap); outline: none;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.field textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--header); box-shadow: 0 0 0 3.5px var(--ring); }
.field input::placeholder, .field textarea::placeholder { color: oklch(0.7 0.02 258); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 460px) { .grid-2 { grid-template-columns: 1fr; } }

/* Metadata block */
.metablock { display: grid; grid-template-columns: 1fr; gap: 0; }
.metarow { display: grid; grid-template-columns: 0.85fr 1.15fr; border-bottom: 1px solid var(--line); }
.metarow:last-child { border-bottom: none; }
.metarow .k { background: var(--zebra); font-weight: 600; font-size: 12px; color: var(--muted); padding: 11px 13px; display: flex; align-items: center; }
.metarow .v { padding: 6px 8px; display: flex; align-items: center; }
.metarow .v input, .metarow .v select { width: 100%; border: 1px solid transparent; border-radius: 8px; min-height: 36px; padding: 7px 9px; background: transparent; transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease); }
.metarow .v input:focus, .metarow .v select:focus { border-color: var(--header); background: var(--card); box-shadow: 0 0 0 3px var(--ring); }
@media (max-width: 520px) { .metarow { grid-template-columns: 1fr; } .metarow .k { border-bottom: 1px solid var(--line); } }

/* ---------- Inspection rows (statut = badge teinté + fond léger + pastille ; PAS de filet latéral) ---------- */
.rows-head { display: flex; align-items: center; justify-content: space-between; margin: 10px 4px; }
.rows-head h2 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.item-row { margin-bottom: 12px; transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur) var(--ease); animation: rise-in var(--dur-slow) var(--ease) both; }
.item-row:active { transform: scale(0.99); }
.item-row.conforme, .item-row.levee { background: linear-gradient(0deg, var(--card), color-mix(in oklab, var(--ok) 22%, var(--card))); }
.item-row.a_reprendre { background: linear-gradient(0deg, var(--card), color-mix(in oklab, var(--warn) 24%, var(--card))); }
.item-row.sous_reserve { background: linear-gradient(0deg, var(--card), color-mix(in oklab, var(--res) 26%, var(--card))); }
.item-row.non_conforme { background: linear-gradient(0deg, var(--card), color-mix(in oklab, var(--bad) 24%, var(--card))); }
.item-row .ir-top { display: flex; align-items: center; gap: 11px; padding: 13px 15px; }
.item-row .num { width: 30px; height: 30px; border-radius: 9px; background: var(--navy); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 14px; flex: none; }
.item-row.conforme .num, .item-row.levee .num { background: var(--ok-acc); }
.item-row.a_reprendre .num { background: var(--warn-acc); }
.item-row.sous_reserve .num { background: var(--res-acc); }
.item-row.non_conforme .num { background: var(--bad-acc); }
.item-row .ir-loc { flex: 1; min-width: 0; }
.item-row .ir-loc .l1 { font-weight: 700; font-size: 14.5px; letter-spacing: -0.01em; }
.item-row .ir-loc .l2 { font-size: 12.5px; color: var(--muted); }
.item-row .ir-body { padding: 0 15px 13px 15px; }
.item-row .ir-obs { font-size: 13.5px; color: oklch(0.36 0.02 258); line-height: 1.5; }
.item-row .thumbs { display: flex; gap: 6px; margin-top: 11px; flex-wrap: wrap; }
.item-row .thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); }
.item-row .thumbs .count { width: 56px; height: 56px; border-radius: 9px; background: oklch(1 0 0 / 0.5); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; }

/* ---------- Buttons (états complets) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 17px; border-radius: 12px; font-weight: 700; font-size: 14.5px; letter-spacing: -0.005em; transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { box-shadow: 0 0 0 3.5px var(--ring); }
.btn-primary { background: var(--header); color: #fff; box-shadow: var(--shadow); }
.btn-primary:active { background: var(--blue-press); }
@media (hover: hover) { .btn-primary:hover { box-shadow: var(--shadow-md); } .btn-ghost:hover { border-color: var(--header); } .btn-soft:hover { background: color-mix(in oklab, var(--soft) 80%, var(--header) 8%); } }
.btn-dark { background: var(--navy); color: #fff; box-shadow: var(--shadow); }
.btn-ghost { background: var(--card); color: var(--navy); border: 1px solid var(--line); }
.btn-soft { background: var(--soft); color: var(--header); }
.btn-danger { background: var(--card); color: var(--danger); border: 1px solid color-mix(in oklab, var(--danger) 35%, var(--card)); }
.btn-danger:active { background: color-mix(in oklab, var(--danger) 8%, var(--card)); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* FAB */
.fab { position: fixed; right: 18px; bottom: calc(18px + var(--safe-b)); z-index: 25; height: 56px; padding: 0 22px; border-radius: 28px; background: var(--header); color: #fff; font-weight: 800; letter-spacing: -0.01em; box-shadow: var(--shadow-lg); display: inline-flex; align-items: center; gap: 8px; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); animation: pop var(--dur-slow) var(--ease) both; }
.fab:active { transform: scale(0.94); }

/* Bottom action bar */
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 26; background: oklch(0.99 0.003 256 / 0.9); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 11px 14px calc(11px + var(--safe-b)); display: flex; gap: 10px; }
.actionbar .btn { flex: 1; }

/* ---------- Photo capture / annotate ---------- */
.capture-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.capture-grid .ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--zebra); transition: transform var(--dur-fast) var(--ease); }
.capture-grid .ph:active { transform: scale(0.96); }
.capture-grid .ph img { width: 100%; height: 100%; object-fit: cover; }
.capture-grid .ph .edit { position: absolute; inset: auto 6px 6px auto; background: oklch(0.33 0.08 258 / 0.88); color: #fff; border-radius: 8px; font-size: 11px; padding: 3px 7px; font-weight: 700; }
.capture-grid .ph .del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; background: oklch(0.2 0.02 258 / 0.6); color: #fff; display: grid; place-items: center; font-size: 14px; }
.capture-grid .add { aspect-ratio: 1; border: 2px dashed var(--line); border-radius: 12px; display: grid; place-items: center; gap: 2px; color: var(--header); background: var(--card); transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.capture-grid .add:active { transform: scale(0.96); background: var(--soft); }
.capture-grid .add .ico { font-size: 26px; }
.capture-grid .add .lbl { font-size: 11px; font-weight: 700; }
.loc-annot { position: relative; display: inline-block; }
.loc-annot svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }

/* ---------- Modal / sheet ---------- */
.scrim { position: fixed; inset: 0; background: oklch(0.2 0.03 258 / 0.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade-in var(--dur) var(--ease); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.sheet { background: var(--card); width: 100%; max-width: 920px; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: sheet-up var(--dur-slow) var(--ease); }
.sheet.full { border-radius: 0; max-height: 100vh; height: 100%; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 13px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); z-index: 2; }
.sheet-head h3 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; letter-spacing: -0.01em; }
.sheet-body { padding: 16px; overflow: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 14px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-foot .btn { flex: 1; }
.iconbtn { width: var(--tap); height: var(--tap); display: grid; place-items: center; border-radius: 11px; color: var(--muted); transition: background var(--dur-fast) var(--ease); }
.iconbtn:active { background: var(--zebra); }

/* status chooser */
.status-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-choices button { padding: 13px; border-radius: 12px; font-weight: 700; font-size: 14px; border: 1.5px solid transparent; text-align: left; display: flex; align-items: center; gap: 8px; transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.status-choices button:active { transform: scale(0.97); }
.status-choices button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--header); }

/* annotation toolbar */
.annot-wrap { display: flex; flex-direction: column; height: 100%; }
.annot-stage { flex: 1; display: grid; place-items: center; background: oklch(0.2 0.02 258); overflow: hidden; }
.annot-toolbar { display: flex; gap: 6px; padding: 10px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); background: var(--card); }
.tool { min-width: 44px; height: 44px; border-radius: 11px; background: var(--zebra); display: grid; place-items: center; font-size: 18px; border: 1px solid var(--line); transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.tool:active { transform: scale(0.93); }
.tool[aria-pressed="true"] { background: var(--header); color: #fff; border-color: var(--header); }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--card); box-shadow: 0 0 0 1px var(--line); transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.swatch:active { transform: scale(0.9); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--header); }

/* signature pads */
.sig-pad { width: 100%; height: 180px; background: var(--card); border: 1.5px dashed var(--line); border-radius: 12px; touch-action: none; }
.sig-card h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translateX(-50%) translateY(10px); background: var(--navy); color: oklch(0.98 0.01 256); padding: 12px 17px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 60; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* storage chip */
.storage-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 5px 11px; border-radius: 999px; }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-acc); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ok-acc) 22%, transparent); }
.offline-dot.off { background: var(--bad-acc); box-shadow: 0 0 0 3px color-mix(in oklab, var(--bad-acc) 22%, transparent); }

/* locked banner */
.locked-banner { display: flex; align-items: center; gap: 8px; background: color-mix(in oklab, var(--warn) 40%, var(--card)); border: 1px solid color-mix(in oklab, var(--warn) 70%, var(--card)); color: var(--warn-ink); padding: 11px 13px; border-radius: 12px; font-size: 13px; font-weight: 600; margin-bottom: 12px; }

/* ---------- Connexion / verrouillage (moment signature) ---------- */
.lock-overlay { position: fixed; inset: 0; z-index: 100; background: radial-gradient(120% 90% at 50% -10%, var(--banner-2), var(--navy) 70%); display: grid; place-items: center; padding: 24px; animation: fade-in var(--dur-slow) var(--ease); }
.lock-card { background: var(--card); border-radius: var(--r-lg); padding: 28px 24px; width: 100%; max-width: 372px; box-shadow: var(--shadow-lg); text-align: center; animation: rise-in var(--dur-slow) var(--ease); }
.lock-card .lock-logo { margin-bottom: 14px; }
.lock-card h2 { margin: 6px 0 4px; font-size: 19px; font-weight: 800; letter-spacing: -0.015em; }
.lock-card p { margin: 0 0 16px; font-size: 13.5px; color: var(--muted); }
.lock-card #otp-input, .lock-card input[type="text"] { width: 100%; text-align: center; font-size: 27px; font-weight: 700; letter-spacing: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; font-variant-numeric: tabular-nums; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.lock-card #otp-input:focus { border-color: var(--header); box-shadow: 0 0 0 3.5px var(--ring); outline: none; }
.lock-err { color: var(--danger); font-size: 13px; font-weight: 600; min-height: 18px; margin-top: 8px; }
.qr-wrap { display: flex; justify-content: center; padding: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.qr-wrap svg { width: 200px; height: 200px; }

@media (min-width: 720px) { .view { padding-top: 20px; } }

/* ---------- Accessibilité : mouvement réduit ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
