/* ============================================================
   Sivakasi Fireworks - Global Styles (mobile-first)
   Theme: festive Diwali — deep maroon & marigold-gold, warm glow
   Palette: rich maroon surfaces/primary, marigold-gold accent for
            prices & highlights, warm cream base, functional red/green
   ============================================================ */
:root {
  --bg: #fdf6ea;
  --surface: #fffdf8;
  --surface-2: #fbeed9;
  --border: #eddcb8;
  --text: #2a1207;
  --muted: #8a6a45;
  /* primary (mapped onto the old --gold token so every existing class updates) */
  --gold: #c8951f;
  --gold-dark: #a5780f;
  --primary: #8a1220;
  --primary-dark: #6b0d18;
  --accent: #c8951f;      /* marigold-gold accent for prices */
  --crimson: #dc2626;
  --green: #16a34a;
  --marigold: #f2a900;
  --marigold-light: #ffd76a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 20, 5, .06), 0 8px 24px rgba(120, 40, 10, .10);
  --shadow-sm: 0 1px 2px rgba(60, 20, 5, .08);
}

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

body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  /* Establishes a stacking context (with z-index:0) so the watermark
     pseudo-element below (z-index:-1) is guaranteed to stay behind all
     normal page content without having to touch every child's z-index -
     this keeps things like .modal / .toast-wrap unaffected. */
  position: relative;
  z-index: 0;
}

/* ---------- Brand watermark background ----------
   A single, large, centered logo watermark fixed behind all content, so
   it stays visible to the user no matter how far they scroll down the
   page. Semi-transparent and non-interactive so it never blocks clicks/
   taps or hurts text readability, while still being clearly viewable. */
body.has-brand-bg::before {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  background-image: url("../img/logo.webp");
  background-repeat: no-repeat;
  background-position: center;
  background-size: min(80vmin, 820px);
  opacity: 0.28;
  pointer-events: none;
  user-select: none;
}
@media print { body.has-brand-bg::before { display: none; } }

/* The header, cards, tables and footer normally use a fully opaque white
   surface, which was hiding the watermark behind them almost everywhere
   on real, content-heavy pages (the logo only showed in the thin gray
   gaps between panels). Making those panels slightly translucent lets
   the watermark show through consistently across the whole page, while
   the ~95% opacity keeps text contrast and readability unaffected.
   Scoped to .has-brand-bg only, so the admin panel (which reuses this
   same stylesheet but has no watermark) keeps its solid white surfaces. */
body.has-brand-bg .site-header,
body.has-brand-bg .site-footer,
body.has-brand-bg .card,
body.has-brand-bg table.products,
body.has-brand-bg .invoice,
body.has-brand-bg .cart-bar {
  background: rgba(255, 255, 255, 0.94);
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }

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

/* ---------- Header / Nav ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--primary), var(--marigold), var(--primary)) 1;
  box-shadow: var(--shadow-sm);
  position: sticky; top: 0; z-index: 50;
}
.diwali-banner {
  background: linear-gradient(90deg, var(--primary-dark), var(--primary) 45%, #a3311f 55%, var(--primary-dark));
  color: #ffe9b8;
  font-size: 0.82rem; font-weight: 700; letter-spacing: .02em;
  text-align: center; padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 215, 106, .35);
}
.diwali-banner .diya { display: inline-block; vertical-align: -3px; margin: 0 4px; }
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.25rem; color: var(--text); letter-spacing: -.01em; }
.brand span.spark { color: var(--primary); }
.brand-logo {
  height: 44px; width: 44px; object-fit: contain; border-radius: 8px; flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--marigold-light), 0 2px 10px rgba(200, 149, 31, .35);
}
.brand-name { max-width: 220px; line-height: 1.15; }
.nav-links { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.lang-switch { display: inline-flex; align-items: center; gap: 2px; margin-left: 6px; padding: 2px; background: var(--surface-2); border-radius: 999px; }
.lang-switch a { color: var(--muted); padding: 5px 12px; border-radius: 999px; font-weight: 700; font-size: 0.85rem; }
.lang-switch a.active { background: var(--primary); color: #fff; }
@media (max-width: 560px) { .brand-name { font-size: 1rem; max-width: 150px; } }
.nav-links a {
  color: var(--muted); padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 0.95rem;
  transition: background .15s ease, color .15s ease;
}
.nav-links a:hover { background: var(--surface-2); color: var(--primary); }
.nav-links a.active { background: linear-gradient(135deg, #fdecc2, #fbdc94); color: var(--primary-dark); }

.cart-badge {
  background: var(--crimson); color: #fff; border-radius: 999px;
  font-size: 0.75rem; padding: 1px 7px; margin-left: 4px; font-weight: 700;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffe9b8; border: 1px solid var(--primary-dark); border-radius: 10px;
  padding: 10px 18px; font-weight: 700; font-size: 0.95rem; cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, filter .15s ease;
  box-shadow: var(--shadow-sm), 0 0 0 1px rgba(242, 169, 0, .25) inset;
}
.btn:hover { filter: brightness(1.08); box-shadow: var(--shadow), 0 0 14px rgba(242, 169, 0, .35); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #cbd5e1; border-color: #cbd5e1; color: #ffffff; cursor: not-allowed; box-shadow: none; filter: none; }
.btn-outline { background: var(--surface); border: 1px solid var(--gold); color: var(--primary); box-shadow: none; }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--surface-2); }
.btn-danger { background: var(--crimson); border-color: var(--crimson); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* ---------- Cards / Sections ---------- */
.section { padding: 28px 0; }
.page-title { font-size: 1.6rem; color: var(--text); margin-bottom: 4px; letter-spacing: -.02em; font-weight: 800; }
.page-sub { color: var(--muted); margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}

/* ---------- Product table (user) ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters input, .filters select {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: 10px; font-size: 0.95rem;
}
.filters input:focus, .filters select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 149, 31, .18); }
.filters input { flex: 1; min-width: 180px; }

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
table.products { width: 100%; border-collapse: collapse; min-width: 640px; background: var(--surface); }
table.products th, table.products td {
  padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.products tbody tr:last-child td { border-bottom: none; }
table.products tbody tr:hover { background: var(--surface-2); }
table.products th { background: linear-gradient(135deg, var(--surface-2), #f6dfae); color: var(--primary-dark); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.thumb {
  width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border);
  cursor: pointer; background: var(--surface-2);
}
.price-now { color: var(--accent); font-weight: 800; }
.price-old { color: var(--muted); text-decoration: line-through; font-size: 0.85rem; margin-left: 6px; }
.qty-input { width: 74px; background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 8px; border-radius: 8px; text-align: center; }
.qty-input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 149, 31, .18); }
.pill { font-size: 0.72rem; padding: 3px 9px; border-radius: 999px; font-weight: 700; }
.pill-out { background: #fef2f2; color: var(--crimson); }
.pill-stock { background: #ecfdf5; color: var(--green); }

/* ---------- Sticky cart bar ---------- */
.cart-bar {
  position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; z-index: 40;
}
.cart-bar .total { font-weight: 700; }
.cart-bar .total b { color: var(--accent); font-size: 1.15rem; }
.hint { color: var(--muted); font-size: 0.85rem; }
.hint.warn { color: var(--crimson); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: 10px; font-size: 0.95rem;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 149, 31, .18); }
.field textarea { min-height: 84px; resize: vertical; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 600; border: 1px solid transparent; }
.alert-success { background: #ecfdf5; color: #15803d; border-color: #bbf7d0; }
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.alert-info { background: #fdf3e0; color: var(--primary-dark); border-color: #f2cf8e; }

/* ---------- Grid of stat cards (admin) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (min-width: 800px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat .num { font-size: 1.9rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.stat .label { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

/* ---------- Admin sidebar layout ---------- */
.admin-shell { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 860px) { .admin-shell { grid-template-columns: 232px 1fr; } }
.admin-nav {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px; box-shadow: var(--shadow); align-self: start;
}
.admin-nav a {
  color: var(--muted); padding: 10px 14px; border-radius: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  transition: background .15s ease, color .15s ease;
}
.admin-nav a:hover { background: var(--surface-2); color: var(--text); }
.admin-nav a.active { background: linear-gradient(135deg, #fdecc2, #fbdc94); color: var(--primary-dark); }
.admin-nav .note { background: var(--crimson); color: #fff; border-radius: 999px; font-size: 0.72rem; padding: 1px 8px; }

/* ---------- Invoice ---------- */
.invoice { background: var(--surface); color: #1a1a1a; border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; max-width: 720px; margin: 0 auto; box-shadow: var(--shadow); }
.invoice h2 { color: var(--text); }
.invoice table { width: 100%; border-collapse: collapse; margin: 18px 0; }
.invoice th, .invoice td { border: 1px solid var(--border); padding: 9px 11px; text-align: left; font-size: 0.9rem; }
.invoice th { background: var(--surface-2); color: var(--muted); text-transform: uppercase; font-size: .78rem; letter-spacing: .04em; }
.invoice .totals td { border: none; }
.invoice .totals .grand { font-weight: 800; font-size: 1.1rem; color: var(--text); }
.qr-box { text-align: center; margin: 18px 0; }
.qr-box img { width: 200px; margin: 0 auto; border: 1px solid var(--border); border-radius: 8px; }

/* ---------- Mobile enhancements (product / cart / price list / contact) ---------- */
@media (max-width: 640px) {
  .section { padding: 18px 0; }
  .page-title { font-size: 1.3rem; }
  .filters { flex-direction: column; }
  .filters input, .filters select { width: 100%; }

  /* Turn product & cart tables into stacked cards on small screens */
  table.responsive-cards { min-width: 0; }
  table.responsive-cards thead { display: none; }
  table.responsive-cards, table.responsive-cards tbody, table.responsive-cards tr, table.responsive-cards td {
    display: block; width: 100%;
  }
  .table-wrap:has(table.responsive-cards) { overflow-x: visible; }
  table.responsive-cards tr {
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
  }
  table.responsive-cards tbody tr:last-child { border-bottom: none; }
  table.responsive-cards td {
    border-bottom: none;
    padding: 6px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    text-align: right;
  }
  table.responsive-cards td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: .04em;
    font-weight: 700; text-align: left; flex-shrink: 0;
  }
  table.responsive-cards td.cell-name {
    font-weight: 700; font-size: 1rem;
    justify-content: flex-start; text-align: left; flex-wrap: wrap;
  }
  table.responsive-cards .thumb { width: 64px; height: 64px; margin-left: auto; }
  table.responsive-cards .qty-input { width: 100%; max-width: 110px; }

  /* Cart summary + checkout stack full width */
  .card[style*="max-width:420px"] { max-width: 100% !important; }

  /* Price list: shrink the embedded PDF viewer and stack buttons */
  embed[type="application/pdf"] { height: 480px !important; }
  .price-list-actions { flex-direction: column; }
  .price-list-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
  .brand-logo { height: 36px; width: 36px; }
  .nav-links a { padding: 7px 10px; font-size: 0.88rem; }
  embed[type="application/pdf"] { height: 380px !important; }
}

/* ---------- Image modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .72); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal.open { display: flex; }
.modal img { max-width: 92vw; max-height: 88vh; border-radius: 12px; border: 2px solid var(--surface); box-shadow: var(--shadow); }
.modal .close { position: absolute; top: 18px; right: 22px; color: #fff; font-size: 2rem; cursor: pointer; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 3px solid transparent;
  border-image: linear-gradient(90deg, var(--primary), var(--marigold), var(--primary)) 1;
  padding: 24px 0; color: var(--muted); font-size: 0.9rem; margin-top: 30px; background: var(--surface);
}
.site-footer strong { color: var(--primary) !important; }

/* ---------- Toast notification ---------- */
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--gold);
  color: var(--text); padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 320px;
  animation: slidein .3s ease;
}
@keyframes slidein { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media print {
  .site-header, .site-footer, .no-print, .cart-bar { display: none !important; }
  body { background: #fff; }
  .invoice { box-shadow: none; border: none; }
}
