/* ============================================================
   APEX PLUS — Redesign override (2026-11-14)
   ------------------------------------------------------------
   Loads AFTER the built stylesheet and re-themes the whole
   store WITHOUT touching the minified bundle. Warm off-white
   + signal orange (zero blue), Sora display + Inter body,
   light default + real dark mode (persisted by apex-enhance.js).
   Every token below is a CSS variable, so the admin Design
   panel's colour pickers (which set --primary etc. inline)
   still win where the app applies them.
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root,
:root[data-theme="light"] {
  --primary: #c2410c;
  --primary-strong: #9a3412;
  --primary-bright: #f97316;
  --on-primary: #ffffff;
  --secondary: #171412;
  --accent: #f59e0b;            /* stars / amber badges only */
  --accent-soft: #fef3c7;
  --success: #15803d;
  --success-tint: #dcfce7;
  --danger: #dc2626;
  --bg: #faf8f5;
  --bg-soft: #f1ece6;
  --surface: #ffffff;
  --surface-2: #f6f1eb;
  --card-bg: #ffffff;
  --border: #e7e0d8;
  --border-strong: #d6cfc5;
  --text: #171412;
  --text-muted: #6e675f;
  --text-faint: #97897b;
  --nav-bg: rgba(250, 248, 245, 0.92);
  --input-bg: #ffffff;
  --hero-glow: rgba(194, 65, 12, 0.12);
  --card-hover-border: #c2410c;
  --radius: 14px;
  --font-heading: "Sora", "Space Grotesk", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --shadow-sm: 0 1px 2px rgba(23, 20, 18, 0.06), 0 1px 3px rgba(23, 20, 18, 0.05);
  --shadow-md: 0 10px 28px rgba(23, 20, 18, 0.1);
  --shadow-lg: 0 22px 55px rgba(23, 20, 18, 0.16);
}

:root[data-theme="dark"] {
  --primary: #fb923c;
  --primary-strong: #fdba74;
  --primary-bright: #f97316;
  --on-primary: #1a120b;
  --secondary: #282420;
  --accent: #fbbf24;
  --accent-soft: #3a2c10;
  --success: #4ade80;
  --success-tint: #14532d;
  --danger: #f87171;
  --bg: #141210;
  --bg-soft: #1d1a17;
  --surface: #1d1a17;
  --surface-2: #282420;
  --card-bg: #1d1a17;
  --border: #2e2a25;
  --border-strong: #453e35;
  --text: #f5f1ec;
  --text-muted: #a9a29a;
  --text-faint: #7e786e;
  --nav-bg: rgba(20, 18, 16, 0.92);
  --input-bg: #1d1a17;
  --hero-glow: rgba(251, 146, 60, 0.16);
  --card-hover-border: #fb923c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 22px 55px rgba(0, 0, 0, 0.55);
}

/* ---------- 2. Base ---------- */
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--font-heading); letter-spacing: -0.02em; }
::selection { background: rgba(249, 115, 22, 0.28); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
a { color: var(--primary); }
a:hover { color: var(--primary-strong); }
:root[data-theme="dark"] a:hover { color: var(--primary-strong); }

/* ---------- 3. Buttons — the old blue gradient dies here ---------- */
.btn { border-radius: 12px; font-weight: 600; letter-spacing: 0; }
.btn-primary {
  color: var(--on-primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  background-size: 100% auto;
  background-position: 0% 50%;
  box-shadow: 0 2px 8px rgba(194, 65, 12, 0.35), 0 10px 24px rgba(194, 65, 12, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  background-position: 0% 50%;
  filter: brightness(1.07);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(194, 65, 12, 0.4), 0 16px 34px rgba(194, 65, 12, 0.28);
}
.btn-primary:not(:disabled):active { transform: translateY(0); box-shadow: 0 2px 8px rgba(194, 65, 12, 0.3); }
:root[data-theme="dark"] .btn-primary {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45), 0 10px 24px rgba(249, 115, 22, 0.25);
}
.btn-outline { color: var(--primary); background: transparent; }
.btn-outline::before {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
}
.btn-outline:not(:disabled):hover {
  color: var(--on-primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 4px 12px rgba(194, 65, 12, 0.35), 0 16px 34px rgba(194, 65, 12, 0.25);
}
.btn-outline:not(:disabled):hover::before { opacity: 0; }
:root[data-theme="dark"] .btn-outline { color: var(--primary); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }
.btn-glass,
.hero-has-video .btn-ghost {
  background: rgba(10, 10, 10, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.85);
  color: #fff;
}
.hero-has-video .btn-ghost:not(:disabled):hover,
.btn-glass:not(:disabled):hover {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: transparent;
  color: var(--on-primary);
  box-shadow: 0 4px 12px rgba(194, 65, 12, 0.4), 0 16px 34px rgba(194, 65, 12, 0.28);
}
.btn-whatsapp { background: #22a35a; }
.btn-whatsapp:not(:disabled):hover { background: #1d8f4e; filter: none; }
.link-arrow { color: var(--primary); }
.link-arrow:focus-visible { outline-color: rgba(194, 65, 12, 0.55); }
:root[data-theme="dark"] .link-arrow { color: var(--primary); }
@keyframes heroGlow {
  0%, 100% { box-shadow: 0 2px 8px rgba(194, 65, 12, 0.35), 0 10px 24px rgba(194, 65, 12, 0.22); }
  50% { box-shadow: 0 2px 8px rgba(194, 65, 12, 0.35), 0 10px 36px rgba(249, 115, 22, 0.45); }
}

/* ---------- 4. Navigation ---------- */
.navbar { border-bottom: 1px solid var(--border); }
.nav-links a { border-radius: 10px; }
.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  background: rgba(194, 65, 12, 0.09);
}
:root[data-theme="dark"] .nav-links a:hover,
:root[data-theme="dark"] .nav-links a.active { background: rgba(251, 146, 60, 0.12); }
.brand { font-family: var(--font-heading); font-weight: 700; letter-spacing: -0.02em; }
.icon-btn { border-radius: 10px; color: var(--text-muted); }
.icon-btn:hover { background: var(--surface-2); color: var(--primary); }

/* ---------- 5. Hero ---------- */
.hero-eyebrow {
  color: var(--primary);
  border: 1px solid rgba(194, 65, 12, 0.35);
  background: rgba(194, 65, 12, 0.07);
  border-radius: 999px;
  font-family: var(--font-body);
}
.hero-has-video .hero-eyebrow {
  color: #fdba74;
  border-color: rgba(253, 186, 116, 0.45);
  background: rgba(251, 146, 60, 0.16);
}
.hero h1 { font-weight: 700; letter-spacing: -0.025em; }
.hero-has-video h1 { color: #fff; }
.hero-has-video .lead { color: rgba(255, 247, 237, 0.85); }
.hero .lead { color: var(--text-muted); }
.hero-bg-overlay { background: linear-gradient(180deg, rgba(12, 8, 5, 0.62), rgba(12, 8, 5, 0.38), rgba(12, 8, 5, 0.66)); }
.hero-blobs i { background: radial-gradient(circle, rgba(249, 115, 22, 0.35), transparent 70%); }
.hero-blobs i:nth-child(2) { background: radial-gradient(circle, rgba(245, 158, 11, 0.3), transparent 70%); }

/* ---------- 6. Product & category cards ---------- */
.product-card, .cat-card, .cat-cine {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}
.product-card:hover, .cat-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
  border-color: var(--card-hover-border);
}
.cat-cine:hover { border-color: var(--card-hover-border); box-shadow: var(--shadow-md); }
.product-card .p-img, .cat-card .c-img { background: var(--bg-soft); }
:root[data-theme="dark"] .product-card .p-img,
:root[data-theme="dark"] .cat-card .c-img { background: #282420; }
.cat-cine .cine-img,
.cat-cine.no-img .cine-img {
  background: linear-gradient(135deg, #3a2c10, #7c4a12 60%, #171412);
}
:root[data-theme="dark"] .cat-cine .cine-img,
:root[data-theme="dark"] .cat-cine.no-img .cine-img {
  background: linear-gradient(135deg, #2a2118, #4a2f10 60%, #141210);
}
.cat-cine .cine-cta {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: var(--on-primary);
  box-shadow: 0 4px 14px rgba(194, 65, 12, 0.35);
  border-radius: 10px;
}
.p-name { font-family: var(--font-heading); font-weight: 600; }
.p-price {
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}
.p-price-old { color: var(--text-faint); }
.p-warranty { color: var(--text-muted); }
.p-meta { color: var(--text-muted); }

/* ---------- 7. Badges, stars, chips ---------- */
.badge { border-radius: 999px; }
.badge-featured { color: var(--primary); border-color: rgba(194, 65, 12, 0.4); background: rgba(194, 65, 12, 0.07); }
:root[data-theme="dark"] .badge-featured { border-color: rgba(251, 146, 60, 0.45); background: rgba(251, 146, 60, 0.12); }
.badge-available { color: var(--success); border-color: rgba(21, 128, 61, 0.4); }
:root[data-theme="dark"] .badge-available { border-color: rgba(74, 222, 128, 0.4); }
.badge-out_of_stock { color: var(--danger); }
.badge-coming_soon { color: var(--accent); border-color: rgba(245, 158, 11, 0.4); }
.stars { color: var(--accent); }
:root[data-theme="dark"] .stars { color: #fbbf24; }
.marquee-dot { color: var(--primary); }
.chip-row .badge { border-radius: 999px; }

/* ---------- 8. Sections, headings, promo ---------- */
.section-title { font-weight: 700; letter-spacing: -0.02em; }
.section-sub { color: var(--text-muted); }
.page-head h1, .detail-grid h1 { font-weight: 700; letter-spacing: -0.02em; }
.promo-banner {
  background: linear-gradient(135deg, #171412, #3a2410 70%, #171412);
  color: #fff7ed;
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: 20px;
}
:root[data-theme="dark"] .promo-banner {
  background: linear-gradient(135deg, #282420, #3a2a12 70%, #1d1a17);
  border-color: rgba(251, 146, 60, 0.3);
}
:root[data-theme="light"] .promo-banner { background: linear-gradient(135deg, #171412, #3a2410 70%, #171412); }
.promo-banner h2 { color: #fff7ed; font-weight: 700; }
.promo-banner p { color: rgba(255, 247, 237, 0.78); }
.notif-bar { background: #171412; color: #fff7ed; }
:root[data-theme="light"] .notif-bar { background: #171412; }
:root[data-theme="dark"] .notif-bar { background: #282420; color: #f5f1ec; }

/* Offer bar — background + text colours come from the settings doc as
   inline styles, so !important is required here. The bar is hidden by
   apex-enhance.js once its countdown reaches 00:00:00 (expired offer). */
.offer-bar {
  background: linear-gradient(90deg, #171412, #3a2410) !important;
  color: #fde68a !important;
}
.offer-chip { background: rgba(255, 255, 255, 0.14) !important; }
.offer-chip strong { color: #fff7ed; }

/* ---------- 9. Footer ---------- */
.footer { border-top: 1px solid var(--border); }
.footer h4 { font-family: var(--font-heading); font-weight: 700; color: var(--text); }
.footer a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); color: var(--text-faint); }

/* ---------- 10. Forms, search, reviews, modal, toast ---------- */
.input, .textarea, .select { border-radius: 12px; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(194, 65, 12, 0.16);
}
:root[data-theme="dark"] .input:focus,
:root[data-theme="dark"] .textarea:focus,
:root[data-theme="dark"] .select:focus { box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.22); }
.checkbox-row input { accent-color: var(--primary); }
.search-results { border-radius: 14px; box-shadow: var(--shadow-lg); }
.search-item:hover { background: var(--surface-2); }
.review-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.review-head strong { font-family: var(--font-heading); }
.modal-overlay img { background: var(--surface-2) !important; }
.copy-toast { background: var(--text); color: var(--bg); border-radius: 12px; }
.copy-toast-error { background: #b4232a; color: #fff; }

/* ---------- 11. Product detail page ---------- */
.detail-grid .detail-img { background: var(--surface-2) !important; }
.detail-grid h1 { font-family: var(--font-heading); }
.detail-grid .kv dt { color: var(--text-muted); }
.detail-grid .kv dd { color: var(--text); }

/* ---------- 12. Sticky buy bar (mobile product pages, injected by JS) ---------- */
.apex-sticky-buy {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 95;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(23, 20, 18, 0.12);
}
.apex-sticky-buy.on { display: flex; }
.apex-sticky-buy .apex-sb-info { flex: 1; min-width: 0; }
.apex-sticky-buy .apex-sb-name {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.apex-sticky-buy .apex-sb-price {
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-size: 0.95rem;
}
.apex-sticky-buy .btn { flex-shrink: 0; }
@media (min-width: 821px) {
  .apex-sticky-buy.on { display: none; }
}
@media (max-width: 820px) {
  body.apex-has-sticky-buy { padding-bottom: 78px; }
  body.apex-has-sticky-buy .wa-float { bottom: 86px; }
}

/* ---------- 14. Admin (inherits tokens; polish only) ---------- */
.admin-shell { background: var(--bg); }
.admin-side { background: var(--bg-soft); }
.admin-side a.active, .admin-side a:hover { color: var(--primary); }
.stat-num { font-family: var(--font-heading); font-variant-numeric: tabular-nums; }
.tbl th { color: var(--text-muted); font-family: var(--font-body); }

/* ---------- 15. Motion, small screens ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
@media (max-width: 640px) {
  .hero h1 { letter-spacing: -0.02em; }
}
