/* ── Reset ──────────────────────────────────────────────────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ═══════════════════════════════════════════════════════════════════════════
   SCAN PAGE  (index.html)
═══════════════════════════════════════════════════════════════════════════ */

body.scan-page {
  background: #000;
  color: #fff;
  height: 100dvh;
  overflow: hidden;
  font-family: system-ui, sans-serif;
}

#video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  pointer-events: none;
}

/* The viewfinder box — box-shadow creates the dark surround */
.viewfinder {
  width: min(72vw, 72vh, 300px);
  aspect-ratio: 1;
  border-radius: 12px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.75);
  position: relative;
  overflow: hidden;
}

.viewfinder.found {
  border-color: #4ade80;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.55), 0 0 0 4px #4ade80;
}

.scan-line {
  position: absolute;
  inset-inline: 0;
  height: 2px;
  background: linear-gradient(to right, transparent, #6366f1 40%, #6366f1 60%, transparent);
  animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
  0%   { top: 8%;  opacity: 1; }
  48%  { top: 92%; opacity: 1; }
  50%  { top: 92%; opacity: 0; }
  52%  { top: 8%;  opacity: 0; }
  54%  { top: 8%;  opacity: 1; }
  100% { top: 8%;  opacity: 1; }
}

.status {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  max-width: 300px;
  min-height: 1.5em;
}

.status.found { color: #4ade80; font-weight: 600; }
.status.error { color: #f87171; }

/* Fallback panel when BarcodeDetector is unavailable */
.fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0.875rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-radius: 14px;
  max-width: 320px;
  width: 88%;
  pointer-events: all;
}

.fallback p {
  font-size: 0.82rem;
  opacity: 0.7;
  text-align: center;
  line-height: 1.4;
}

.fallback input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: #fff;
  outline: none;
}

.fallback input::placeholder { color: rgba(255, 255, 255, 0.45); }
.fallback input:focus        { border-color: #6366f1; }

.fallback button {
  width: 100%;
  padding: 0.75rem;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.fallback button:active { background: #4f46e5; }

/* ═══════════════════════════════════════════════════════════════════════════
   PRODUCT PAGE  (product.html)
═══════════════════════════════════════════════════════════════════════════ */

body.product-page {
  font-family: system-ui, sans-serif;
  background: #f4f4f5;
  color: #18181b;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 2rem;
}

#content {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Product card ───────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border: 1px solid #e4e4e7;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.card-body {
  padding: 1.25rem 1.5rem;
}

.product-image {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  background: #f4f4f5;
  display: block;
  border-bottom: 1px solid #e4e4e7;
}

.product-image.hidden { display: none; }

.product-name {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.sku {
  font-size: 0.78rem;
  color: #71717a;
  margin-bottom: 1rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.badge-special      { background: #fef9c3; color: #713f12; }
.badge-discontinued { background: #fee2e2; color: #b91c1c; }

.price {
  font-size: 2rem;
  font-weight: 800;
  color: #16a34a;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.price .per-unit {
  font-size: 0.95rem;
  font-weight: 500;
  color: #52525b;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1rem;
}

td {
  padding: 0.45rem 0;
  vertical-align: top;
  border-top: 1px solid #f4f4f5;
}

td:first-child {
  color: #71717a;
  width: 38%;
  padding-right: 0.75rem;
}

tr:first-child td { border-top: none; }

/* ── Scan Again button ──────────────────────────────────────────────────── */

.scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1rem;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.scan-btn:hover  { background: #4f46e5; }
.scan-btn:active { background: #4338ca; }

/* ── Error / loading states ─────────────────────────────────────────────── */

.error-card {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 14px;
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
}

.loading {
  color: #71717a;
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
}
