/* Full-screen scanner layout */
#page-scan {
  position: relative;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

/* Scanner container — fills the page */
.scanner-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Scandit v8 DataCaptureView internals — ensure video/canvas fill the container */
.scanner-container > div {
  width: 100% !important;
  height: 100% !important;
  position: absolute !important;
  inset: 0 !important;
}

.scanner-container video,
.scanner-container canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  max-width: none !important;   /* override global img/media max-width rule */
  max-height: none !important;
}

/* Scandit viewfinder brand override */
.scanner-container [class*="viewfinder"] {
  border-color: rgba(135, 168, 120, 0.6) !important;
}

/* Placeholder (loading / error states) */
.scan-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: calc(var(--tab-bar-height, 64px) + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  line-height: 1.4;
  font-family: var(--font-body, sans-serif);
  letter-spacing: 0.02em;
  background: #0A0A0A;
  z-index: 5;
}

.scan-placeholder.hidden {
  display: none;
}

.scan-placeholder.error svg {
  stroke: var(--color-error, #F44336);
}

.scan-placeholder.error p {
  color: var(--color-error, #F44336);
}

/* Bottom controls overlay — sits above camera */
.scan-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0 16px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 10;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7) 30%, rgba(0, 0, 0, 0.85));
  pointer-events: none;
}

.scan-controls > * {
  pointer-events: auto;
}

/* Status bar */
.scan-status {
  padding: 10px 14px;
  border-radius: 13px;
  font-size: 13px;
  text-align: center;
  margin-bottom: 8px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.scan-status.status-scanning {
  background: rgba(59, 130, 246, 0.15);
  color: #93C5FD;
}

.scan-status.status-found {
  background: rgba(135, 168, 120, 0.15);
  color: #A0BF9C;
}

.scan-status.status-not-found {
  background: rgba(217, 119, 6, 0.15);
  color: #FCD34D;
}

.scan-status.status-error {
  background: rgba(244, 67, 54, 0.15);
  color: #FCA5A5;
}

/* Result card */
.scan-result {
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
  margin-bottom: 8px;
}

.scan-result-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.scan-result-image {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  overflow: hidden;
  padding: 4px;
}

.scan-result-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.scan-result-info {
  flex: 1;
  min-width: 0;
}

.scan-result-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scan-result-brand {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 2px;
}

.scan-result-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.scan-result-score-number {
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
}

.scan-result-tier {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.scan-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.scan-result-action {
  flex: 1;
  text-align: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.scan-result-action:hover {
  background: rgba(255, 255, 255, 0.1);
}

.scan-again-btn {
  flex-shrink: 0;
  padding: 8px 14px;
  background: rgba(135, 168, 120, 0.25);
  border: 1px solid rgba(135, 168, 120, 0.4);
  border-radius: 10px;
  color: #A0BF9C;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body, sans-serif);
}

.scan-again-btn:hover {
  background: rgba(135, 168, 120, 0.35);
}

/* ── Scan limit overlay (paywall) ──────────────────────── */

.scan-limit-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: scanLimitFadeIn 0.3s ease;
}

@keyframes scanLimitFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.scan-limit-card {
  background: #1A1A1A;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 32px 24px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.scan-limit-icon {
  margin-bottom: 16px;
}

.scan-limit-title {
  font-size: 20px;
  font-weight: 700;
  color: #FFFFFF;
  margin: 0 0 12px;
  font-family: var(--font-display, var(--font-body, sans-serif));
}

.scan-limit-text {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.65);
  margin: 0 0 20px;
}

.scan-limit-text strong {
  color: rgba(255, 255, 255, 0.9);
}

.scan-limit-pricing {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.scan-limit-price {
  font-size: 18px;
  font-weight: 700;
  color: #A0BF9C;
}

.scan-limit-price small {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.7;
}

.scan-limit-separator {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
}

.scan-limit-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scan-limit-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-body, sans-serif);
  transition: background 0.15s ease;
}

.scan-limit-btn--primary {
  background: var(--sage-400, #87A878);
  color: #FFFFFF;
}

.scan-limit-btn--primary:hover {
  background: var(--sage-500, #6E9460);
}

.scan-limit-btn--secondary {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.5);
}

.scan-limit-btn--secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.scan-limit-footer {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.3);
  margin: 16px 0 0;
}

/* ── Scans remaining hint ──────────────────────────────── */

.scans-remaining-hint {
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  padding: 6px 0 2px;
  animation: hintFadeIn 0.3s ease;
}

.scans-remaining-hint--low {
  color: #FCD34D;
}

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

/* ── Floating mode chip (top) ────────────────────────────
   Small "Barcode" label that tells users what scan mode they're in.
   Sits at the top of the viewport, styled to match the existing
   sage-accent glass aesthetic used elsewhere on the scan screen. */
.scan-mode-chip {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(135, 168, 120, 0.45);
  border-radius: 100px;
  z-index: 11;
  pointer-events: none;
  animation: scanChipFadeIn 0.4s ease;
}

@keyframes scanChipFadeIn {
  from { opacity: 0; transform: translate(-50%, -4px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ── Floating aim guide (center) ─────────────────────────
   A small corner-bracket square that suggests where to aim.
   ZBar still decodes the full frame — this is purely a visual cue
   so users know the app is actively scanning. Uses Rabbithole's
   sage brand accent. */
.scan-aim-guide {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 210px;
  height: 140px;
  z-index: 3;
  pointer-events: none;
  animation: scanChipFadeIn 0.4s ease;
}

/* Line-based corner brackets — 2 clean lines per corner, no square boxes. */
.scan-aim-line {
  position: absolute;
  background: rgba(135, 168, 120, 0.9);
  box-shadow: 0 0 10px rgba(135, 168, 120, 0.4);
  border-radius: 2px;
}

.scan-aim-line--tl-h { top: 0; left: 0; width: 28px; height: 2px; }
.scan-aim-line--tl-v { top: 0; left: 0; width: 2px; height: 28px; }
.scan-aim-line--tr-h { top: 0; right: 0; width: 28px; height: 2px; }
.scan-aim-line--tr-v { top: 0; right: 0; width: 2px; height: 28px; }
.scan-aim-line--bl-h { bottom: 0; left: 0; width: 28px; height: 2px; }
.scan-aim-line--bl-v { bottom: 0; left: 0; width: 2px; height: 28px; }
.scan-aim-line--br-h { bottom: 0; right: 0; width: 28px; height: 2px; }
.scan-aim-line--br-v { bottom: 0; right: 0; width: 2px; height: 28px; }
