﻿/* =================================================================
   1. CSS Variables & Base
   ================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --brand-primary: #ff6f61;
  --brand-dark:    #e8503f;
  --brand-light:   #ff8b7e;
  --brand-glow:    rgba(255, 111, 97, 0.35);

  --accent:        #ff914d;
  --success:       #22c55e;
  --danger:        #ef4444;

  --bg:            #f4f6fb;
  --bg-2:          #eef0f7;
  --surface:       #ffffff;
  --surface-2:     #f9fafb;
  --border:        #e8eaf0;

  --text-1:        #111827;
  --text-2:        #4b5563;
  --text-3:        #9ca3af;

  --radius-sm:     8px;
  --radius:        14px;
  --radius-lg:     20px;
  --radius-xl:     28px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow:    0 4px 16px rgba(0,0,0,0.09);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.13);
  --shadow-brand: 0 6px 22px var(--brand-glow);

  --font: 'Poppins', sans-serif;
  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: 100%;
  padding: 0 16px;
  max-width: 960px;
  margin: 0 auto;
}

/* =================================================================
   2. Offer Bar (Marquee)
   ================================================================= */
.offer-bar {
  background: linear-gradient(90deg, var(--brand-dark) 0%, var(--brand-primary) 50%, var(--accent) 100%);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  overflow: hidden;
  white-space: nowrap;
  padding: 7px 0;
  letter-spacing: 0.01em;
}

.offer-bar-track {
  display: inline-block;
  animation: marquee 28s linear infinite;
}

@keyframes marquee {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* =================================================================
   3. Header
   ================================================================= */
.site-header {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid transparent;
  transition: box-shadow var(--transition), border-color var(--transition), background var(--transition);
}

.site-header.scrolled {
  box-shadow: var(--shadow);
  border-color: var(--border);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 62px;
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--brand-primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  box-shadow: var(--shadow-brand);
  flex-shrink: 0;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--brand-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

/* Header Actions */
.header-actions { display: flex; gap: 10px; align-items: center; }

.icon-btn {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-2);
  font-size: 1.15rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  border: 1px solid var(--border);
}

.icon-btn:hover, .icon-btn:active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-brand);
  transform: scale(1.05);
}

.badge {
  background: var(--brand-primary);
  color: #fff;
  border-radius: 99px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  position: absolute;
  top: -3px;
  right: -3px;
  border: 2px solid var(--surface);
  min-width: 18px;
  text-align: center;
  line-height: 1.3;
}

/* =================================================================
   4. Hero Banner
   ================================================================= */
.hero-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #fff5f4 0%, #fff9f0 100%);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  margin: 18px 0 14px;
  border: 1px solid #fde8e4;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  position: relative;
}

.hero-banner::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,111,97,0.12), transparent 70%);
  pointer-events: none;
}

.hero-greeting {
  font-size: 0.85rem;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 4px;
}

.hero-title {
  font-size: 1.45rem;
  font-weight: 900;
  color: var(--text-1);
  line-height: 1.25;
}

.hero-title .highlight {
  background: linear-gradient(135deg, var(--brand-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-art {
  font-size: 3.2rem;
  flex-shrink: 0;
  margin-left: 12px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

/* =================================================================
   5. Search Bar
   ================================================================= */
.search-bar {
  display: flex;
  align-items: center;
  margin: 0 0 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 0 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar:focus-within {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px var(--brand-glow);
}

.search-icon {
  color: var(--text-3);
  font-size: 1rem;
  pointer-events: none;
  flex-shrink: 0;
}

.search-bar input {
  flex-grow: 1;
  padding: 13px 12px;
  border: none;
  outline: none;
  font-size: 0.95rem;
  font-family: var(--font);
  background: transparent;
  color: var(--text-1);
}

.search-bar input::placeholder { color: var(--text-3); }

.search-clear-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  padding: 4px;
  transition: color var(--transition);
}
.search-clear-btn:hover { color: var(--brand-primary); }

#search-btn { display: none; }

/* =================================================================
   6. Info Row (Store Status + Credit Card)
   ================================================================= */
.info-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

/* Store Status Card */
.store-status-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}

.status-dot.closed {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.2);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2); }
  50% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.1); }
}

.status-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-1);
  line-height: 1.3;
}

.status-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--text-2);
  margin-top: 2px;
}

/* Credit Card Widget */
.credit-card {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--accent) 100%);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #fff;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: var(--shadow-brand);
  position: relative;
  overflow: hidden;
}

.credit-card::before {
  content: '';
  position: absolute;
  top: -20px; right: -20px;
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.12);
  border-radius: 50%;
}

.credit-card:hover, .credit-card:active {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px var(--brand-glow);
}

.credit-top {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  opacity: 0.9;
  margin-bottom: 2px;
}

.credit-score {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1.1;
}

.credit-balance {
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 2px;
}

.credit-balance strong { opacity: 1; font-weight: 700; }

.credit-pay-btn {
  display: inline-block;
  margin-top: 8px;
  background: rgba(255,255,255,0.22);
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  border: 1px solid rgba(255,255,255,0.4);
  letter-spacing: 0.02em;
  transition: background var(--transition);
}

.credit-card:hover .credit-pay-btn { background: rgba(255,255,255,0.35); }

/* =================================================================
   7. Categories Strip
   ================================================================= */
.categories-strip-section {
  position: sticky;
  top: 62px;
  z-index: 990;
  background: var(--bg);
  transition: box-shadow var(--transition);
  margin: 0 -16px;
  padding: 0 16px;
}

.categories-strip-section.is-pinned {
  box-shadow: 0 4px 12px rgba(0,0,0,0.07);
}

.categories-strip {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  padding: 14px 0;
  scrollbar-width: none;
}

.categories-strip::-webkit-scrollbar { display: none; }

.category-item {
  flex: 0 0 auto;
  padding: 8px 18px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.category-item i { font-size: 0.9rem; }

.category-item:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  transform: translateY(-1px);
}

.category-item.active {
  background: linear-gradient(135deg, var(--brand-primary), var(--accent));
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}

/* =================================================================
   8. Section Titles
   ================================================================= */
.product-section { margin-top: 28px; }

.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-1);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.title-icon { font-size: 1.1rem; }

.title-icon.flash {
  animation: flicker 1.5s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; transform: scale(1.15); }
}

/* =================================================================
   9. Product Grid & Cards
   ================================================================= */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.product-card {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.02);
  position: relative;
}

.product-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 32px rgba(0,0,0,0.06);
  border-color: rgba(255, 111, 97, 0.25);
}

.image-container {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(180deg, transparent, #fafafa);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.product-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1;
}

.product-card:hover img {
  transform: scale(1.12);
}

.out-of-stock-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  padding: 4px 10px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.product-info {
  padding: 14px;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
  position: relative;
  z-index: 2;
}

.product-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-0); /* Use a darker color if defined, otherwise text-1 */
  margin: 0 0 12px;
  line-height: 1.4;
  height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.product-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  gap: 8px;
}

.product-price {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-1);
  letter-spacing: -0.02em;
}

.btn-add {
  padding: 8px 16px;
  border-radius: 99px;
  font-weight: 800;
  font-size: 0.8rem;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  background: rgba(255, 111, 97, 0.08);
  border: 1.5px solid rgba(255, 111, 97, 0.15);
  color: var(--brand-primary);
  flex-shrink: 0;
}

.btn-add:hover {
  background: linear-gradient(135deg, var(--brand-primary), var(--accent));
  color: #fff;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 111, 97, 0.25);
}

.btn-add:active {
  transform: translateY(0);
}

/* Quantity Controls */
.action-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 34px;
  width: 105px;
}

.action-wrap .btn-add {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%; height: 100%;
  margin: 0;
  z-index: 2;
}

.qty-controls {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1.5px solid var(--brand-primary);
  border-radius: 99px;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 1;
  overflow: hidden;
}

.qty-controls.visible {
  opacity: 1;
  pointer-events: all;
  transform: scale(1);
  z-index: 3;
}

.qty-btn {
  background: transparent;
  border: none;
  color: var(--brand-primary);
  font-size: 1.1rem;
  font-weight: 900;
  width: 32px;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.qty-btn:hover { background: rgba(255, 111, 97, 0.1); }
.qty-btn:active { background: rgba(255, 111, 97, 0.2); }

.qty-display {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-1);
  flex-grow: 1;
  text-align: center;
}

.qty-timer-bar {
  position: absolute;
  bottom: 0; left: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand-primary), var(--accent));
  width: 100%;
  transform-origin: left;
  transform: scaleX(0);
  opacity: 0;
  z-index: 4;
}

.qty-timer-bar.visible {
  opacity: 1;
  animation: shrink-timer 3s linear forwards;
}

@keyframes shrink-timer {
  0% { transform: scaleX(1); }
  100% { transform: scaleX(0); }
}

.out-of-stock img {
  opacity: 0.5;
  filter: grayscale(100%);
}

.btn-add:disabled {
  background: var(--bg-2);
  border-color: var(--border);
  color: var(--text-3);
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.btn-add.added {
  background: var(--success);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* =================================================================
   10. Skeleton Loader
   ================================================================= */
.skeleton {
  opacity: 0.75;
  animation: skeleton-loading 1.4s infinite linear;
  background: linear-gradient(90deg, #eaecf0 25%, #f5f6f8 50%, #eaecf0 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
}

@keyframes skeleton-loading {
  to { background-position-x: -200%; }
}

/* =================================================================
   11. Toast Notifications
   ================================================================= */
#toast-container {
  position: fixed;
  bottom: 94px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 230px;
  max-width: 300px;
  transform: translateY(80px) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
}

.toast.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast.success { background: #059669; }
.toast.error   { background: var(--danger); }

.toast.success::before {
  content: '\f058';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 1.1rem;
}

.toast.error::before {
  content: '\f071';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 1.1rem;
}

/* =================================================================
   12. Bottom Navigation
   ================================================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 12px;
  box-shadow: 0 -1px 0 var(--border), 0 -8px 24px rgba(0,0,0,0.06);
  z-index: 1000;
}

.nav-link {
  color: var(--text-3);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  padding: 0 20px;
  transition: color var(--transition);
}

.nav-link i {
  font-size: 1.35rem;
  transition: transform var(--transition);
}

.nav-link.active {
  color: var(--brand-primary);
}

.nav-link.active i { transform: scale(1.15); }

.nav-link:active i { transform: scale(0.9); }

.nav-indicator {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 22px;
  height: 3px;
  background: var(--brand-primary);
  border-radius: 99px;
  transition: transform var(--transition);
}

.nav-link.active .nav-indicator { transform: translateX(-50%) scaleX(1); }

.badge.small {
  font-size: 0.6rem;
  padding: 1px 5px;
  top: -4px;
  right: 10px;
  position: absolute;
}

/* =================================================================
   13. Responsive
   ================================================================= */
@media (max-width: 767px) {
  .desktop-only { display: none !important; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 1.2rem; }
  .hero-art { font-size: 2.6rem; }

  .info-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .product-grid { 
    grid-template-columns: 1fr 1fr;
    gap: 10px; 
  }

  .product-card img { height: 110px; }

  .product-info { padding: 8px 10px 10px; }

  .product-name {
    font-size: 0.8rem;
    height: 2.24em;
  }

  .product-price { font-size: 1rem; }

  .btn-add {
    padding: 8px;
    font-size: 0.78rem;
    margin-top: 8px;
  }

  .section-title { font-size: 1.05rem; }
}

@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .hero-title { font-size: 1.7rem; }
}

@media (min-width: 768px) {
  body { padding-bottom: 0; }
  .bottom-nav { display: none; }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .section-title { font-size: 1.35rem; }
  .container { padding: 0 24px; }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
  .categories-strip { justify-content: flex-start; }
}

/* =================================================================
   14. QR Scanner Modal — UPI-App Style (camera at top)
   ================================================================= */

/* ---- Full-screen modal ---- */
#qr-scanner-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  z-index: 3000 !important;
  background: #000 !important;
  /* no flex here — block so wrapper can fill with absolute */
}

/* ---- Inner layout wrapper ---- */
#scanner-wrapper {
  position: absolute !important;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden;
}

/* ---- Top bar ---- */
#scanner-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: #000;
  color: #fff;
  z-index: 2;
}

#scanner-topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

#scanner-topbar button {
  background: rgba(255,255,255,0.12);
  border: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#scanner-topbar button:active { background: rgba(255,255,255,0.25); }

/* ---- Camera viewport: expands to fill remaining space ---- */
#scanner-viewport {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  background: #000;
  min-height: 0;        /* important for flex shrink */
}

/* ---- #reader: force it to fully fill the viewport ----
   html5-qrcode injects inline height/width — defeat it with
   position:absolute so we escape the flow entirely            */
#reader,
#scanner-viewport #reader {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: #000 !important;
}

/* Hide the library's own buttons/status/dashboard */
#reader__dashboard,
#reader__dashboard_section,
#reader__dashboard_section_csr,
#reader__dashboard_section_fsr,
#reader__filescan_input,
#reader__status_span,
#reader > img {
  display: none !important;
  visibility: hidden !important;
}

/* ---- Force the <video> to fill the container like a cover image ---- */
#reader video,
#scanner-viewport video {
  position: absolute !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

/* ---- Also hide the canvas the library draws (we don't need it visible) ---- */
#reader canvas {
  position: absolute !important;
  top: 0 !important; left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  opacity: 0 !important;   /* keep it for scanning but invisible */
}

/* ---- Scan frame: corner brackets + sweep line overlay ---- */
.scan-frame {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

/* Darkened vignette — centre square stays bright */
.scan-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55))
    padding-box,
    linear-gradient(rgba(0,0,0,0.55), rgba(0,0,0,0.55));
  /* punch a transparent hole in the middle */
  -webkit-mask:
    linear-gradient(#000 0 0) center / 200px 200px no-repeat,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: destination-out;
  mask:
    linear-gradient(#000 0 0) center / 200px 200px no-repeat,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
}

/* Corner brackets */
.sc-corner {
  position: absolute;
  width: 30px;
  height: 30px;
  border-color: #fff;
  border-style: solid;
  border-width: 0;
}
.sc-tl { top: calc(50% - 100px); left: calc(50% - 100px); border-top-width: 4px; border-left-width: 4px;  border-radius: 6px 0 0 0; }
.sc-tr { top: calc(50% - 100px); right: calc(50% - 100px); border-top-width: 4px; border-right-width: 4px; border-radius: 0 6px 0 0; }
.sc-bl { bottom: calc(50% - 100px); left: calc(50% - 100px); border-bottom-width: 4px; border-left-width: 4px;  border-radius: 0 0 0 6px; }
.sc-br { bottom: calc(50% - 100px); right: calc(50% - 100px); border-bottom-width: 4px; border-right-width: 4px; border-radius: 0 0 6px 0; }

/* Animated green scan line */
.scan-line {
  position: absolute;
  top: calc(50% - 95px);
  left: calc(50% - 95px);
  width: 190px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #22c55e 30%, #4ade80 50%, #22c55e 70%, transparent);
  border-radius: 2px;
  animation: scan-sweep 2s ease-in-out infinite;
  box-shadow: 0 0 10px rgba(34,197,94,0.7), 0 0 20px rgba(34,197,94,0.3);
}

@keyframes scan-sweep {
  0%   { transform: translateY(0px);   opacity: 1; }
  48%  { transform: translateY(190px); opacity: 1; }
  50%  { opacity: 0; }
  52%  { transform: translateY(0px);   opacity: 0; }
  54%  { opacity: 1; }
  100% { transform: translateY(0px);   opacity: 1; }
}

/* ---- Bottom instruction strip ---- */
#scanner-bottom {
  flex-shrink: 0;
  background: #000;
  padding: 20px 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  z-index: 2;
}

#scanner-hint {
  color: rgba(255,255,255,0.5);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Flash button active state */
#toggle-flash-btn.torch-on {
  background: #facc15 !important;
  color: #000 !important;
}
