*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

#app {
  display: flex;
  height: 100dvh;
  gap: 12px;
  padding: 12px;
}

/* ── Portrait : colonne ── */
@media (orientation: portrait) {
  #app { flex-direction: column; }
  #zone-camera    { flex: 0 0 42%; }
  #zone-resultats { flex: 1; }
}

/* ── Paysage : ligne ── */
@media (orientation: landscape) {
  #app { flex-direction: row; }
  #zone-camera    { flex: 0 0 48%; }
  #zone-resultats { flex: 1; }
}

/* ── Zone caméra ── */
#zone-camera {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#preview-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  overflow: hidden;
}

#preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #475569;
}

#placeholder svg { width: 64px; height: 64px; opacity: .4; }
#placeholder p   { font-size: .85rem; }

#btn-capture {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  border-radius: 0 0 var(--radius) var(--radius);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  user-select: none;
}

/* ── Zone résultats ── */
#zone-resultats {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#resultats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#resultats-titre { font-weight: 700; font-size: 1rem; }

#resultats-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* ── États ── */
#etat-initial p, #etat-chargement p, #etat-erreur p {
  color: var(--text-muted);
  font-size: .9rem;
  text-align: center;
  margin-top: 24px;
}

#etat-erreur p { color: #dc2626; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 24px auto 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Table résumé ── */
#table-champs { width: 100%; border-collapse: collapse; font-size: .9rem; }
#table-champs tr + tr td { border-top: 1px solid var(--border); }
#table-champs td { padding: 8px 6px; vertical-align: top; }
#table-champs td:first-child {
  font-weight: 600;
  white-space: nowrap;
  width: 36%;
  color: var(--text-muted);
}

/* ── Vue détail JSON ── */
#json-detail {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

/* ── Boutons ── */
.btn {
  border: none;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary  { background: var(--primary);   color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); }

.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
