/* ═══════════════════════════════════════════════════════════════════════════
   RANGEMENT — style.css
   Police minimale 16px partout — Boutons minimum 48px
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 16px;
  background-color: #f8fafc;   /* slate-50 */
  color: #1e293b;              /* slate-800 */
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

button { cursor: pointer; font-size: 16px; font-family: inherit; border: none; }
input  { font-size: 16px; font-family: inherit; }

/* ── Utilitaire hidden ───────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ═══════════════════════════════════════════════════════════════════════════
   ÉCRAN SETUP
   ═══════════════════════════════════════════════════════════════════════════ */
#setup-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  gap: 2rem;
}

.setup-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.setup-logo .setup-emoji { font-size: 3.5rem; }
.setup-logo h1 {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #1e293b;
}

.setup-card {
  width: 100%;
  max-width: 360px;
  background: white;
  border-radius: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px 0 rgb(0 0 0 / 0.06);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setup-card label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

#setup-name {
  width: 100%;
  height: 52px;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0 1rem;
  font-size: 1.125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1e293b;
  transition: border-color 0.15s;
  outline: none;
}
#setup-name:focus { border-color: #f59e0b; }
#setup-name::placeholder { font-weight: 400; text-transform: none; color: #cbd5e1; }

#setup-btn {
  height: 52px;
  width: 100%;
  background: #f59e0b;
  color: white;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  border-radius: 0.75rem;
  transition: background-color 0.15s, transform 0.1s;
}
#setup-btn:hover    { background: #d97706; }
#setup-btn:active   { transform: scale(0.98); }
#setup-btn:disabled {
  background: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.setup-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  color: #94a3b8;
  font-size: 0.9375rem;
  padding: 0.125rem 0;
}
.setup-loader .spinner { border-top-color: #f59e0b; }

/* ═══════════════════════════════════════════════════════════════════════════
   ÉCRAN PRINCIPAL
   ═══════════════════════════════════════════════════════════════════════════ */
#main-screen:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  min-height: 100dvh;
  padding: 1rem 1rem max(1.25rem, env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
}

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-emoji { font-size: 1.75rem; }

.header-title  { font-size: 1.25rem; font-weight: 900; color: #1e293b; letter-spacing: 0.03em; }
#session-label {
  font-size: 0.6875rem;
  font-family: 'Courier New', monospace;
  color: #94a3b8;
  margin-top: 1px;
  letter-spacing: 0.02em;
}

#config-btn {
  width: 44px; height: 44px; min-height: 44px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06);
  transition: border-color 0.15s;
  flex-shrink: 0;
}
#config-btn:hover { border-color: #cbd5e1; }

/* ── Panneau config ───────────────────────────────────────────────────────── */
#config-panel:not(.hidden) {
  display: flex;
  flex-direction: column;
}

.config-card {
  background: white;
  border-radius: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px 0 rgb(0 0 0 / 0.06);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.config-card label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.config-row {
  display: flex;
  gap: 0.5rem;
}

#config-name {
  flex: 1;
  height: 48px;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  padding: 0 0.875rem;
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}
#config-name:focus { border-color: #3b82f6; }

#config-save {
  height: 48px;
  padding: 0 1.25rem;
  background: #2563eb;
  color: white;
  font-weight: 700;
  border-radius: 0.625rem;
  font-size: 1rem;
  transition: background-color 0.15s;
}
#config-save:hover { background: #1d4ed8; }

#config-close {
  background: none;
  color: #94a3b8;
  font-size: 0.875rem;
  height: 48px;
  padding: 0;
  align-self: center;
  transition: color 0.15s;
}
#config-close:hover { color: #64748b; }

/* ═══════════════════════════════════════════════════════════════════════════
   ZONE CARTON
   ═══════════════════════════════════════════════════════════════════════════ */

/* Carton actif */
#carton-active:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgb(254 243 199 / 0.6);  /* amber-100/60 */
  border: 2px solid #f59e0b;
  border-radius: 1.25rem;
  padding: 1.25rem 1.5rem;
}

.ca-header {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #92400e;
}

#ca-code {
  font-size: 2.25rem;
  font-weight: 900;
  font-family: 'Courier New', monospace;
  color: #b45309;
  letter-spacing: 0.04em;
}

#carton-change-btn {
  align-self: flex-start;
  height: 48px;
  padding: 0 1rem;
  background: transparent;
  color: #b45309;
  font-weight: 600;
  font-size: 0.9375rem;
  border: 1.5px solid #f59e0b;
  border-radius: 0.625rem;
  transition: background-color 0.15s;
}
#carton-change-btn:hover { background: rgb(245 158 11 / 0.1); }

/* Carton vide */
#carton-empty:not(.hidden) {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: white;
  border: 1.5px dashed #cbd5e1;
  border-radius: 1.25rem;
  padding: 1.25rem 1.5rem;
}

.ce-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #93c5fd;
  flex-shrink: 0;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.ce-text { display: flex; flex-direction: column; gap: 0.25rem; }
.ce-title {
  font-size: 1rem;
  font-weight: 600;
  color: #475569;
}
.ce-hint {
  font-size: 0.9375rem;
  color: #94a3b8;
}
.ce-hint code {
  font-family: 'Courier New', monospace;
  font-size: 0.9375rem;
  color: #f59e0b;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ZONE RÉSULTAT — cartes de statut
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Base card ────────────────────────────────────────────────────────────── */
.r-card {
  background: white;
  border-radius: 1.25rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid #e2e8f0;
  border-left-width: 5px;
  box-shadow: 0 1px 4px 0 rgb(0 0 0 / 0.06);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Idle ─────────────────────────────────────────────────────────────────── */
.r-idle {
  background: white;
  border-radius: 1.25rem;
  padding: 1.5rem;
  text-align: center;
  color: #94a3b8;
  font-size: 1rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 4px 0 rgb(0 0 0 / 0.04);
}

/* ── Loading ──────────────────────────────────────────────────────────────── */
.r-loading {
  background: white;
  border-radius: 1.25rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  color: #64748b;
  font-size: 1rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 4px 0 rgb(0 0 0 / 0.04);
}

.spinner {
  width: 26px; height: 26px;
  border: 3px solid #e2e8f0;
  border-top-color: #f59e0b;
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.75s linear infinite;
}

/* ── Status dots & badges ────────────────────────────────────────────────── */
.r-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.r-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.r-dot.found    { background: #22c55e; }
.r-dot.notfound { background: #f97316; }
.r-dot.error    { background: #ef4444; }
.r-dot.warning  { background: #f59e0b; }

.r-badge {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
}
.r-badge.found    { background: #dcfce7; color: #166534; }
.r-badge.notfound { background: #fff7ed; color: #c2410c; }
.r-badge.error    { background: #fef2f2; color: #991b1b; }

/* ── SKU display ─────────────────────────────────────────────────────────── */
.r-sku {
  font-size: 1.375rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  color: #f59e0b;
  letter-spacing: 0.02em;
}
.r-sku.ok { color: #16a34a; }

/* ── Statut FOUND ────────────────────────────────────────────────────────── */
.r-card.found { border-left-color: #22c55e; }

.r-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #f8fafc;
  border-radius: 0.75rem;
  padding: 0.875rem 1rem;
}

.r-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.r-label {
  font-size: 0.9375rem;
  color: #94a3b8;
  font-weight: 500;
}
.r-value {
  font-size: 1rem;
  font-weight: 700;
  color: #334155;
}
.r-value.price      { color: #16a34a; font-size: 1.125rem; }
.r-value.stock-ok   { color: #16a34a; }
.r-value.stock-zero { color: #ef4444; }

.r-ebay-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  height: 48px;
  padding: 0 0.5rem;
  margin: -0.5rem;
  border-radius: 0.5rem;
  transition: color 0.15s;
}
.r-ebay-link:hover { color: #1d4ed8; text-decoration: underline; }

/* ── Statut RANGEMENT OK ─────────────────────────────────────────────────── */
.r-card.ok {
  border-left-color: #22c55e;
  background: #f0fdf4;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
}

.r-ok-icon {
  font-size: 3rem;
  line-height: 1;
}

.r-ok-detail {
  font-size: 1rem;
  color: #475569;
}
.r-ok-detail strong {
  font-family: 'Courier New', monospace;
  font-size: 1.0625rem;
  color: #f59e0b;
  font-weight: 800;
}

/* ── Statut NOT FOUND ────────────────────────────────────────────────────── */
.r-card.notfound { border-left-color: #f97316; }
.r-hint {
  font-size: 0.9375rem;
  color: #94a3b8;
}

/* ── Statut ERROR ────────────────────────────────────────────────────────── */
.r-card.error { border-left-color: #ef4444; }
.r-err-msg {
  font-size: 0.9375rem;
  color: #64748b;
  line-height: 1.5;
}

/* ── Warning (pas de carton) ─────────────────────────────────────────────── */
.r-warning {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: 1.25rem;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  color: #92400e;
}

/* ═══════════════════════════════════════════════════════════════════════════
   BOUTON SCANNER (action principale)
   ═══════════════════════════════════════════════════════════════════════════ */
.actions { margin-top: auto; padding-top: 0.5rem; }

#camera-btn {
  width: 100%;
  height: 64px;
  background: #f59e0b;
  color: white;
  font-size: 1.125rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.625rem;
  transition: background-color 0.15s, transform 0.1s;
  box-shadow: 0 4px 14px 0 rgb(245 158 11 / 0.35);
}
#camera-btn:hover  { background: #d97706; }
#camera-btn:active { transform: scale(0.98); box-shadow: none; }

/* ═══════════════════════════════════════════════════════════════════════════
   MODALE CAMÉRA
   ═══════════════════════════════════════════════════════════════════════════ */
#camera-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.78);
  padding: 1rem;
}
#camera-modal.hidden { display: none !important; }

.cam-card {
  background: white;
  border-radius: 1.25rem;
  padding: 1rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  box-shadow: 0 20px 40px 0 rgb(0 0 0 / 0.4);
}

.cam-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cam-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
}

#camera-close {
  width: 40px; height: 40px;
  background: none;
  color: #94a3b8;
  font-size: 1.1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}
#cam-close:hover { background: #f1f5f9; color: #475569; }

#camera-region {
  width: 100%;
  min-height: 260px;
  border-radius: 0.875rem;
  overflow: hidden;
  background: #f1f5f9;
}

.cam-hint {
  font-size: 0.875rem;
  color: #94a3b8;
  text-align: center;
  line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════════
   LISTE ARTICLES SCANNÉS
   ═══════════════════════════════════════════════════════════════════════════ */
.sl-card {
  background: white;
  border-radius: 1.25rem;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px 0 rgb(0 0 0 / 0.06);
  overflow: hidden;
}

.sl-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}

.sl-count {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.sl-items {
  display: flex;
  flex-direction: column;
}

.sl-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  min-height: 56px;
  border-bottom: 1px solid #f8fafc;
}
.sl-item:last-child { border-bottom: none; }

.sl-sku {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: #334155;
  word-break: break-all;
}

.sl-prix {
  font-size: 0.9375rem;
  font-weight: 600;
  color: #16a34a;
  flex-shrink: 0;
}

/* Bouton ✕ suppression — touch target 48px */
.sl-del-btn {
  width: 48px;
  height: 48px;
  min-height: 48px;
  background: none;
  color: #cbd5e1;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 0.15s, color 0.15s;
}
.sl-del-btn:hover { background: #fef2f2; color: #ef4444; }
.sl-del-btn:active { transform: scale(0.92); }

/* Spinner inline (état deleting) */
.sl-spinner {
  width: 20px; height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #94a3b8;
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.75s linear infinite;
}

/* Ligne en erreur de suppression */
.sl-err-row { background: #fff5f5; }

.sl-err-txt {
  font-size: 0.875rem;
  color: #ef4444;
  flex: 1;
}

/* ═══════════════════════════════════════════════════════════════════════════
   ONGLETS DE MODE
   ═══════════════════════════════════════════════════════════════════════════ */
#mode-tabs {
  display: flex;
  gap: 0.5rem;
  background: #f1f5f9;
  border-radius: 0.875rem;
  padding: 0.3rem;
}

.mode-tab {
  flex: 1;
  height: 44px;
  border-radius: 0.625rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #94a3b8;
  background: transparent;
  letter-spacing: 0.02em;
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.mode-tab.active {
  background: white;
  color: #1e293b;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.10);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODE INVENTAIRE — dots & badges
   ═══════════════════════════════════════════════════════════════════════════ */
.r-dot.inv-found    { background: #22c55e; }
.r-dot.inv-notfound { background: #ef4444; }

.r-badge.inv-found {
  background: #dcfce7;
  color: #166534;
}
.r-badge.inv-notfound {
  background: #fef2f2;
  color: #991b1b;
}

/* ── Cartes inventaire ────────────────────────────────────────────────────── */
.r-card.inv-found    { border-left-color: #22c55e; }
.r-card.inv-notfound { border-left-color: #ef4444; }

.r-value-carton {
  font-family: 'Courier New', monospace;
  color: #b45309;
  font-weight: 800;
}

/* ── Mise à jour carton ──────────────────────────────────────────────────── */
.r-carton-input {
  width: 100%;
  height: 48px;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  padding: 0 0.875rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}
.r-carton-input:focus { border-color: #f59e0b; }
.r-carton-input::placeholder {
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #cbd5e1;
}

.r-maj-carton-btn {
  align-self: flex-start;
  height: 48px;
  padding: 0 1.125rem;
  background: transparent;
  color: #b45309;
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1.5px solid #fde68a;
  border-radius: 0.625rem;
  transition: background-color 0.15s, border-color 0.15s;
}
.r-maj-carton-btn:hover { background: #fffbeb; border-color: #f59e0b; }

.r-carton-flash {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 0.625rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: center;
  animation: flashIn 0.2s ease;
}

@keyframes flashIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modifier prix ────────────────────────────────────────────────────────── */
.r-modifier-btn {
  align-self: flex-start;
  height: 48px;
  padding: 0 1.125rem;
  background: transparent;
  color: #2563eb;
  font-size: 0.9375rem;
  font-weight: 600;
  border: 1.5px solid #bfdbfe;
  border-radius: 0.625rem;
  transition: background-color 0.15s, border-color 0.15s;
}
.r-modifier-btn:hover { background: #eff6ff; border-color: #93c5fd; }

.r-prix-edit {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}
.r-prix-edit.hidden { display: none !important; }

.r-prix-input {
  width: 100%;
  height: 48px;
  border: 1.5px solid #e2e8f0;
  border-radius: 0.625rem;
  padding: 0 0.875rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1e293b;
  outline: none;
  transition: border-color 0.15s;
}
.r-prix-input:focus { border-color: #22c55e; }

.r-prix-btns {
  display: flex;
  gap: 0.5rem;
}

.r-prix-confirm {
  flex: 1;
  height: 48px;
  background: #22c55e;
  color: white;
  font-size: 0.9375rem;
  font-weight: 700;
  border-radius: 0.625rem;
  transition: background-color 0.15s;
}
.r-prix-confirm:hover { background: #16a34a; }

.r-prix-cancel {
  height: 48px;
  padding: 0 1rem;
  background: transparent;
  color: #94a3b8;
  font-size: 0.9375rem;
  border-radius: 0.625rem;
  transition: color 0.15s;
}
.r-prix-cancel:hover { color: #64748b; }

/* ═══════════════════════════════════════════════════════════════════════════
   LISTE — dot statut eBay (mode inventaire)
   ═══════════════════════════════════════════════════════════════════════════ */
.sl-status {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sl-status.found    { background: #22c55e; }
.sl-status.notfound { background: #ef4444; }

/* ═══════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
