/* app/styles.css — PWA capture (vanilla, zéro framework — contrainte B).
   Anti-zoom/scroll RÉEL : touch-action manipulation global + none sur le viseur +
   overscroll-behavior none (le meta viewport est ignoré par iOS — vérifié MDN). */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overscroll-behavior: none; touch-action: manipulation; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f172a; color: #e2e8f0;
  user-select: none; -webkit-user-select: none;
}

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }

/* --- Connexion / Ventes ------------------------------------------------- */
.center-card { margin: auto; width: min(92vw, 24rem); display: flex; flex-direction: column; gap: 1rem; text-align: center; }
.center-card h1 { font-size: 1.3rem; color: #fb923c; }
input[type="password"], input[type="text"] {
  font-size: 1.2rem; padding: .9rem 1rem; border-radius: .6rem; border: 1px solid #334155;
  background: #1e293b; color: #e2e8f0; width: 100%;
}
.btn-big {
  font-size: 1.25rem; font-weight: 700; padding: 1rem; border: 0; border-radius: .7rem;
  background: #ea580c; color: #fff;
}
.btn-big:active { background: #c2410c; }
.error { color: #f87171; }

.ventes-wrap { padding: max(env(safe-area-inset-top), 1rem) 1rem 1rem; overflow-y: auto; width: 100%; }
.ventes-wrap h1 { color: #fb923c; margin-bottom: 1rem; }
.new-vente { display: flex; gap: .5rem; margin-bottom: 1.2rem; }
.new-vente .btn-big { width: auto; padding: .9rem 1.2rem; font-size: 1rem; }
#ventes-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }
#ventes-list li {
  background: #1e293b; border: 1px solid #334155; border-radius: .7rem; padding: 1rem;
  display: flex; justify-content: space-between; align-items: center; font-size: 1.05rem;
}
#ventes-list li .meta { color: #94a3b8; font-size: .85rem; }
#ventes-list li.cloturee { opacity: .5; }

/* --- Capture ------------------------------------------------------------- */
#cap-header {
  position: relative; display: flex; flex-direction: column; gap: .25rem;
  padding: max(env(safe-area-inset-top), .4rem) .6rem .3rem;
  background: #0f172a; z-index: 3;
}
.cap-row { display: flex; align-items: center; width: 100%; }
.cap-row-nav { justify-content: space-between; gap: .3rem; }
.cap-row-tools { justify-content: center; gap: .9rem; }
.cap-row-nav .btn-ghost { flex: 0 0 auto; padding: .35rem .6rem; font-size: 1.4rem; line-height: 1; }
#cap-numero {
  /* flex:1 + min-width:0 → le libellé prend la place restante et ne POUSSE jamais les flèches hors
     écran ; clamp réduit pour que #A125 tienne entre les 4 boutons sur 390 px. */
  font-size: clamp(2.2rem, 12vw, 3.6rem); font-weight: 800; line-height: 1;
  color: #4ade80; font-variant-numeric: tabular-nums;
  flex: 1 1 auto; min-width: 0; text-align: center; overflow: hidden; white-space: nowrap;
}
#cap-qty { display: flex; align-items: center; gap: .45rem; }
.btn-qty {
  width: 2.6rem; height: 2.6rem; font-size: 1.5rem; border-radius: 50%;
  border: 1px solid #475569; background: #1e293b; color: #e2e8f0;
}
#qty-value { font-size: 1.5rem; font-weight: 700; min-width: 2.2rem; text-align: center; color: #fb923c; }
#btn-note.has-note { background: #ea580c; color: #fff; border-color: #ea580c; }

.note-editor {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8;
  background: #1e293b; border-top: 1px solid #475569;
  padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: .6rem;
}
.note-editor[hidden] { display: none; }
#note-text {
  width: 100%; font-size: 1.05rem; padding: .7rem; border-radius: .5rem;
  border: 1px solid #334155; background: #0f172a; color: #e2e8f0; resize: none;
}
.note-actions { display: flex; gap: .6rem; justify-content: flex-end; }
.note-actions .btn-big { width: auto; padding: .7rem 1.6rem; }
.badge {
  position: absolute; top: calc(max(env(safe-area-inset-top), .4rem) + .2rem); right: .5rem;
  background: #b45309; color: #fff; font-size: .75rem; font-weight: 700;
  border-radius: 999px; padding: .15rem .5rem; z-index: 4;
}
.badge.err { background: #b91c1c; }

#viseur-wrap { position: relative; flex: 1; overflow: hidden; background: #000; touch-action: none; }
#viseur { width: 100%; height: 100%; object-fit: cover; }
#flash { position: absolute; inset: 0; background: #fff; opacity: .85; z-index: 5; }

/* Code-barres : cadre léger de la bande LUE, en HAUT à DROITE (haut 10 %, bord droit 5 %, 62 % L × 20 % H)
   → laisse libre la colonne de vignettes à gauche. Purement VISUEL (pointer-events:none) — le re-scan passe
   par un toucher du viseur. Les % DOIVENT rester synchrones avec BC_BAND_W/H/TOP/RIGHT (app.js) :
   le découpage décodé = ce cadre. */
.bc-frame {
  position: absolute; right: 5%; top: 10%; width: 62%; height: 20%; z-index: 2; pointer-events: none;
  border: 2px solid rgba(255,255,255,.55); border-radius: .6rem;
  transition: border-color .15s, box-shadow .15s;
}
/* Flash VERT au verrouillage (iPhone : remplace la vibration absente). */
.bc-frame.ok { border-color: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.7), 0 0 18px rgba(34,197,94,.6); }
/* Badge « ✓ code lu · <EAN> » — vert, juste au-dessus du cadre (aligné à droite). */
.bc-badge {
  position: absolute; right: 5%; top: calc(10% - 2.2rem); z-index: 4;
  background: #16a34a; color: #fff; font-weight: 700;
  padding: .3rem .7rem; border-radius: 999px; font-size: .95rem; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
/* Panneau diagnostic (triple appui) : texte + vignette de la bande vue par le décodeur. */
.bc-diag {
  position: absolute; left: .4rem; bottom: .4rem; z-index: 6; max-width: 70%;
  background: rgba(0,0,0,.72); color: #e5e7eb; border: 1px solid #334155; border-radius: .5rem;
  padding: .4rem .5rem; font: 600 .72rem/1.3 ui-monospace, Menlo, Consolas, monospace;
}
.bc-diag img { display: block; margin-top: .35rem; width: 100%; max-width: 16rem; image-rendering: pixelated; border: 1px solid #475569; border-radius: .25rem; }

/* Liste des photos BLOQUÉES (à rattacher) : miniature + libellé/motif + actions. */
#queue-modal-rows { max-height: 55vh; overflow-y: auto; margin: .5rem 0; }
.qm-row { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid #334155; }
.qm-row img { width: 2.8rem; height: 2.8rem; object-fit: cover; border-radius: .35rem; flex: 0 0 auto; }
.qm-row .qm-info { flex: 1 1 auto; min-width: 0; font-size: .82rem; }
.qm-row .qm-info .muted { font-size: .72rem; }
.qm-row button { flex: 0 0 auto; }

#thumbs {
  position: absolute; left: .4rem; top: .4rem; display: flex; flex-direction: column; gap: .3rem; z-index: 2;
  max-height: 60%; overflow: hidden;
}
#thumbs img { width: 3.4rem; height: 3.4rem; object-fit: cover; border-radius: .4rem; border: 2px solid #4ade80; }

#shutter {
  position: absolute; bottom: 1.1rem; left: 50%; transform: translateX(-50%);
  width: 5.2rem; height: 5.2rem; border-radius: 50%; z-index: 2;
  border: 5px solid #fff; background: rgba(255,255,255,.25);
}
#shutter:active { background: rgba(255,255,255,.7); }

.btn-retour { position: absolute; bottom: 2.2rem; left: 1rem; z-index: 2; }
.btn-ghost {
  background: rgba(30,41,59,.7); color: #cbd5e1; border: 1px solid #475569;
  border-radius: .6rem; font-size: 1.3rem; padding: .45rem .8rem;
}

.btn-suivant {
  width: 100%; border: 0; font-size: 1.7rem; font-weight: 800; letter-spacing: .05em;
  padding: 1.05rem 0 calc(1.05rem + env(safe-area-inset-bottom));
  background: #16a34a; color: #fff;
}
.btn-suivant:active { background: #15803d; }
.btn-suivant.refus { background: #b91c1c; animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.cap-message {
  position: fixed; bottom: 7rem; left: 50%; transform: translateX(-50%);
  background: #1e293b; border: 1px solid #f59e0b; color: #fcd34d;
  padding: .6rem 1rem; border-radius: .6rem; z-index: 6; max-width: 90vw; text-align: center;
}

/* Fenêtre applicative générique (point 1 : remplace confirm/prompt/alert).
   display:flex en CSS + [hidden] plus spécifique → jamais d'inline display qui casse le masquage. */
.app-modal {
  position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.app-modal[hidden] { display: none; }
.app-modal-card {
  background: #1e293b; border: 1px solid #475569; border-radius: .9rem; padding: 1.2rem;
  width: min(92vw, 22rem); display: flex; flex-direction: column; gap: .9rem;
}
.app-modal-card h2 { color: #fb923c; font-size: 1.2rem; text-align: center; }
.app-modal-field { display: flex; flex-direction: column; gap: .3rem; font-size: .9rem; color: #94a3b8; }
.app-modal-field input {
  font-size: 1.3rem; padding: .7rem; border-radius: .5rem; border: 1px solid #334155;
  background: #0f172a; color: #e2e8f0; text-align: center; width: 100%;
}
.app-modal-msg { color: #fcd34d; text-align: center; font-size: .9rem; }
.app-modal-msg[hidden] { display: none; }
.app-modal-actions { display: flex; flex-direction: column; gap: .5rem; }
.app-modal-actions .btn-big, .app-modal-actions .btn-ghost { width: 100%; font-size: 1.1rem; padding: .9rem; }

/* Bandeau file — fixe en bas, visible sur toutes les vues, tap = forcer l'envoi */
.queue-status {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7;
  padding: .5rem 1rem calc(.5rem + env(safe-area-inset-bottom));
  background: #14532d; color: #bbf7d0; font-size: .85rem; text-align: center;
}
.queue-status.err { background: #7f1d1d; color: #fecaca; }
.queue-status[hidden] { display: none; }
