:root {
  --brand: #f68b1e;
  --brand-dark: #e07a0f;
  --whatsapp: #25D366;
  --whatsapp-dark: #1ebc59;
  --sale: #e02424;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --border: #ececec;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
}

body.dark-mode {
  --bg: #0f1115;
  --surface: #1a1d24;
  --text: #f0f0f0;
  --text-muted: #9aa0ab;
  --border: #2a2d35;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, 'Segoe UI', Roboto, sans-serif;
  transition: background .25s ease, color .25s ease;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ---------------- Page loader ---------------- */
.page-loader {
  position: fixed; inset: 0; background: var(--bg); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .3s ease;
}
.page-loader.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 40px; height: 40px; border: 4px solid var(--border); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Topbar ---------------- */
.store-topbar {
  position: sticky; top: 0; z-index: 800; background: var(--brand);
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.topbar-row { display: flex; align-items: center; gap: 10px; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; flex-shrink: 0; color: #fff; }
.brand-icon {
  font-size: 1.15rem; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand-icon-logo { background: rgba(255,255,255,.95); padding: 3px; overflow: hidden; }
.brand-icon-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text { color: #fff; }
.search-wrap { position: relative; max-width: 480px; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input {
  width: 100%; padding: 10px 14px 10px 38px; border-radius: 999px; border: none;
  background: #fff; color: var(--text); font-size: .9rem; box-shadow: 0 1px 4px rgba(0,0,0,.12);
}
.search-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,.4); }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); max-height: 400px; overflow-y: auto;
  z-index: 900; border: 1px solid var(--border);
}
.search-result-item { display: flex; gap: 10px; padding: 10px 14px; align-items: center; }
.search-result-item:hover { background: var(--bg); }
.search-result-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,.18); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem; cursor: pointer; transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.3); color: #fff; }
.cart-badge {
  position: absolute; top: -2px; right: -2px; background: var(--sale); color: #fff;
  font-size: .62rem; font-weight: 800; min-width: 17px; height: 17px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px; border: 2px solid var(--brand);
}

/* ---------------- Hero carousel ---------------- */
.hero-carousel { position: relative; margin-bottom: 24px; }
@media (min-width: 768px) {
  .hero-carousel { max-width: 1200px; margin-left: auto; margin-right: auto; padding: 0 16px; margin-top: 16px; }
  .hero-slide { border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-lg); }
}
.hero-slide {
  position: relative; width: 100%; aspect-ratio: 21 / 9; min-height: 180px; overflow: hidden;
}
.hero-slide img { width: 100%; height: 100%; object-fit: cover; }
.hero-slide-caption {
  position: absolute; left: 0; bottom: 0; padding: 24px; color: #fff;
  background: linear-gradient(0deg, rgba(0,0,0,.6), transparent);
  width: 100%;
}
.hero-slide-caption h2 { font-size: 1.4rem; font-weight: 800; margin: 0 0 4px; }
.hero-slide-caption p { font-size: .9rem; margin: 0 0 10px; opacity: .9; }
.hero-cta {
  display: inline-block; background: var(--brand); color: #fff; padding: 8px 20px;
  border-radius: 999px; font-weight: 700; font-size: .85rem;
}
.btn-brand {
  background: var(--brand); border: none; color: #fff; font-weight: 700; border-radius: var(--radius-sm);
}
.btn-brand:hover { background: var(--brand-dark); color: #fff; }

/* ---------------- Section heading ---------------- */
.section { padding: 8px 0 28px; }
.section-heading {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.section-heading h3 {
  font-size: 1.1rem; font-weight: 800; margin: 0; padding-left: 12px; position: relative;
}
.section-heading h3::before {
  content: ''; position: absolute; left: 0; top: 2px; bottom: 2px; width: 5px;
  background: var(--brand); border-radius: 3px;
}

/* ---------------- Categories ---------------- */
.category-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory;
  -ms-overflow-style: none; scrollbar-width: none;
}
.category-scroll::-webkit-scrollbar { display: none; }
.category-card {
  scroll-snap-align: start; flex-shrink: 0; width: 92px; text-align: center; cursor: pointer;
}
.category-card-img {
  width: 72px; height: 72px; border-radius: 20px; overflow: hidden; margin: 0 auto 6px;
  box-shadow: var(--shadow); border: 2px solid transparent; transition: all .2s ease; background: var(--surface);
}
.category-card.active .category-card-img { border-color: var(--brand); transform: scale(1.05); }
.category-card-img img { width: 100%; height: 100%; object-fit: cover; }
.category-card-name { font-size: .75rem; font-weight: 600; color: var(--text); }

/* ---------------- Promo banners ---------------- */
.promo-banner {
  border-radius: var(--radius-lg); overflow: hidden; position: relative; box-shadow: var(--shadow);
}
.promo-banner img { width: 100%; height: 140px; object-fit: cover; }

/* ---------------- Product grid ---------------- */
.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
@media (min-width: 576px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 992px) { .product-grid { grid-template-columns: repeat(5, 1fr); } }

.product-card {
  background: var(--surface); border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; flex-direction: column; transition: transform .15s ease, box-shadow .15s ease;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.product-card.is-out-of-stock .product-card-img { opacity: .45; filter: grayscale(.3); }
.product-card-img-wrap { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--bg); }
.product-card-img { width: 100%; height: 100%; object-fit: cover; }
.pc-badge {
  position: absolute; top: 8px; font-size: .62rem; font-weight: 800; padding: 3px 8px;
  border-radius: 999px; color: #fff; text-transform: uppercase; letter-spacing: .3px;
}
.pc-badge-featured { left: 8px; background: #6366f1; }
.pc-badge-bestseller { left: 8px; top: 30px; background: var(--sale); }
.pc-badge-new { right: 8px; background: #3b82f6; }
.pc-badge-oos { right: 8px; background: #6b7280; }
.product-card-body { padding: 10px 12px 4px; flex: 1; }
.pc-category { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 2px; }
.pc-name {
  font-size: .85rem; font-weight: 600; line-height: 1.3; margin-bottom: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pc-price { font-weight: 800; color: var(--brand-dark); font-size: .95rem; }
.product-card-footer { padding: 8px 12px 12px; }
.btn-order-quick {
  width: 100%; background: var(--brand); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 8px; font-weight: 700; font-size: .8rem; cursor: pointer; transition: background .15s;
}
.btn-order-quick:hover { background: var(--brand-dark); }
.btn-order-quick:disabled { background: #d1d5db; color: #6b7280; cursor: not-allowed; }

/* Primary call-to-action buttons (order / checkout confirm) — brand orange
   for visual consistency; WhatsApp icon inline signals where it leads */
.btn-whatsapp {
  background: var(--brand); border: none; color: #fff; font-weight: 700;
}
.btn-whatsapp:hover { background: var(--brand-dark); color: #fff; }
.btn-whatsapp:disabled { background: #d1d5db; color: #6b7280; }

/* ---------------- Skeleton loaders ---------------- */
.skeleton { background: linear-gradient(90deg, var(--border) 25%, #ddd 37%, var(--border) 63%); background-size: 400% 100%; animation: skeleton-shine 1.4s ease infinite; border-radius: var(--radius-md); }
@keyframes skeleton-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-card { aspect-ratio: .8; }

/* ---------------- Footer ---------------- */
.store-footer { background: #1a1a2e; color: #cbd5e1; padding: 40px 0 24px; margin-top: 32px; }
.store-footer h6 { color: #fff; }
.store-footer .brand-icon { background: rgba(255,255,255,.12); }
.store-footer .brand-text, .store-footer .brand { color: #fff; }
.store-footer hr { border-color: rgba(255,255,255,.12); }
.footer-link { color: #9aa3b5; }
.footer-link:hover { color: var(--brand); }
.store-footer .text-muted { color: #9aa3b5 !important; }

/* ---------------- Recently viewed drawer ---------------- */
.recently-viewed-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface);
  border-top: 1px solid var(--border); padding: 12px 0; box-shadow: 0 -4px 16px rgba(0,0,0,.08); z-index: 700;
}
.recently-viewed-scroll { display: flex; gap: 10px; overflow-x: auto; }
.recently-viewed-scroll .rv-item { flex-shrink: 0; width: 60px; }
.recently-viewed-scroll .rv-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 10px; }
.btn-icon-sm { background: none; border: none; font-size: 1rem; color: var(--text-muted); }

/* ---------------- Container ---------------- */
.container { max-width: 1200px; }

/* ---------------- Offline banner ---------------- */
.offline-banner {
  background: #fef3c7; color: #92400e; text-align: center; font-size: .82rem;
  padding: 8px 12px; position: sticky; top: 60px; z-index: 750;
}
body.dark-mode .offline-banner { background: #3a2f10; color: #fbbf24; }

/* ---------------- Empty state ---------------- */
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-muted); }

/* ---------------- Cart page ---------------- */
.cart-line-img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; background: var(--bg); }
.min-w-0 { min-width: 0; }
.cart-line-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
