/* ---------- Themes ----------
   Every colour below comes from these variables. <html data-theme="..."> picks the palette (light is the default);
   the Dark theme also sets data-bs-theme="dark" so Bootstrap's own components (forms, menus, tables, alerts) follow.
   --bs-body-bg is the card colour, so inputs, menus and tables blend into the panels they sit on. */
:root {
  --shop-radius: 12px;

  --shop-accent: #1f5f8b;
  --shop-accent-rgb: 31, 95, 139;
  --shop-accent-dark: #174a6c;
  --shop-on-accent: #ffffff;

  --shop-bg: #ffffff;            /* page background */
  --shop-card: #ffffff;          /* panels, cards, tiles */
  --shop-surface: #f6f7f9;       /* soft fills: category bar, footer, summaries, image wells */
  --shop-border: #e3e6ea;
  --shop-text: #1f2937;
  --shop-text-soft: #4b5563;
  --shop-text-muted: #6b7280;
  --shop-nav-text: #374151;

  --shop-header-bg: #ffffff;
  --shop-header-border: #e3e6ea;
  --shop-header-text: #111827;
  --shop-header-muted: #4b5563;

  --shop-hero-from: #e8f1f7;
  --shop-hero-to: #f5f0e8;
  --shop-placeholder-from: #eef2f6;
  --shop-placeholder-to: #e2e8ef;
  --shop-placeholder-text: #9aa8b5;
  --shop-shadow: rgba(0, 0, 0, 0.08);
}

html[data-theme="dark"] {
  --shop-accent: #5aa9e6;
  --shop-accent-rgb: 90, 169, 230;
  --shop-accent-dark: #7dbcee;
  --shop-on-accent: #0b1520;

  --shop-bg: #0f141a;
  --shop-card: #171e27;
  --shop-surface: #1d2631;
  --shop-border: #2c3744;
  --shop-text: #e6eaef;
  --shop-text-soft: #c3ccd6;
  --shop-text-muted: #9aa6b2;
  --shop-nav-text: #cfd6de;

  --shop-header-bg: #131a22;
  --shop-header-border: #2c3744;
  --shop-header-text: #f3f5f8;
  --shop-header-muted: #b9c3cd;

  --shop-hero-from: #17283a;
  --shop-hero-to: #2a2219;
  --shop-placeholder-from: #1f2934;
  --shop-placeholder-to: #26323f;
  --shop-placeholder-text: #6f8193;
  --shop-shadow: rgba(0, 0, 0, 0.45);
}

html[data-theme="blue"] {
  --shop-accent: #1d5fd1;
  --shop-accent-rgb: 29, 95, 209;
  --shop-accent-dark: #174ba6;
  --shop-on-accent: #ffffff;

  --shop-bg: #f2f7fd;
  --shop-card: #ffffff;
  --shop-surface: #e4eef9;
  --shop-border: #c9daee;
  --shop-text: #102a43;
  --shop-text-soft: #334e68;
  --shop-text-muted: #55708c;
  --shop-nav-text: #1f3a5a;

  --shop-header-bg: #0d2f5f;
  --shop-header-border: #0d2f5f;
  --shop-header-text: #ffffff;
  --shop-header-muted: #c7d8f0;

  --shop-hero-from: #d6e6fb;
  --shop-hero-to: #eef4fd;
  --shop-placeholder-from: #e6eefa;
  --shop-placeholder-to: #d3e1f4;
  --shop-placeholder-text: #8aa3c2;
  --shop-shadow: rgba(13, 47, 95, 0.12);
}

html[data-theme="gray"] {
  --shop-accent: #4a5561;
  --shop-accent-rgb: 74, 85, 97;
  --shop-accent-dark: #343c45;
  --shop-on-accent: #ffffff;

  --shop-bg: #f1f2f4;
  --shop-card: #fbfbfc;
  --shop-surface: #e5e7ea;
  --shop-border: #d2d6db;
  --shop-text: #1e2226;
  --shop-text-soft: #444b53;
  --shop-text-muted: #636a73;
  --shop-nav-text: #343a41;

  --shop-header-bg: #2f353c;
  --shop-header-border: #2f353c;
  --shop-header-text: #f4f5f6;
  --shop-header-muted: #c9ced4;

  --shop-hero-from: #e2e5e9;
  --shop-hero-to: #f3f4f5;
  --shop-placeholder-from: #e8eaed;
  --shop-placeholder-to: #d9dde1;
  --shop-placeholder-text: #8e959d;
  --shop-shadow: rgba(0, 0, 0, 0.1);
}

/* Bootstrap reads its own variables; point them at the active palette. (:root ties with Bootstrap's own rule and
   wins by coming later; the dark selector out-ranks Bootstrap's [data-bs-theme=dark].) */
:root, :root[data-bs-theme="dark"] {
  --bs-body-bg: var(--shop-card);
  --bs-body-color: var(--shop-text);
  --bs-emphasis-color: var(--shop-text);
  --bs-secondary-color: var(--shop-text-muted);
  --bs-tertiary-bg: var(--shop-surface);
  --bs-secondary-bg: var(--shop-surface);
  --bs-border-color: var(--shop-border);
  --bs-primary: var(--shop-accent);
  --bs-primary-rgb: var(--shop-accent-rgb);
  --bs-link-color: var(--shop-accent);
  --bs-link-color-rgb: var(--shop-accent-rgb);
  --bs-link-hover-color: var(--shop-accent-dark);
  --bs-link-hover-color-rgb: var(--shop-accent-rgb);
  color-scheme: light;
}
:root[data-bs-theme="dark"] { color-scheme: dark; }

html { font-size: 15px; }
@media (min-width: 768px) { html { font-size: 16px; } }

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--shop-bg);
  color: var(--shop-text);
}
main { flex: 1 0 auto; }
.table { --bs-table-bg: transparent; }

.btn-primary {
  --bs-btn-color: var(--shop-on-accent);
  --bs-btn-hover-color: var(--shop-on-accent);
  --bs-btn-active-color: var(--shop-on-accent);
  --bs-btn-disabled-color: var(--shop-on-accent);
  --bs-btn-bg: var(--shop-accent);
  --bs-btn-border-color: var(--shop-accent);
  --bs-btn-hover-bg: var(--shop-accent-dark);
  --bs-btn-hover-border-color: var(--shop-accent-dark);
  --bs-btn-active-bg: var(--shop-accent-dark);
  --bs-btn-active-border-color: var(--shop-accent-dark);
  --bs-btn-disabled-bg: var(--shop-accent);
  --bs-btn-disabled-border-color: var(--shop-accent);
}
.btn-outline-primary {
  --bs-btn-color: var(--shop-accent);
  --bs-btn-border-color: var(--shop-accent);
  --bs-btn-hover-bg: var(--shop-accent);
  --bs-btn-hover-border-color: var(--shop-accent);
  --bs-btn-hover-color: var(--shop-on-accent);
  --bs-btn-active-bg: var(--shop-accent-dark);
  --bs-btn-active-color: var(--shop-on-accent);
}
.pagination { --bs-pagination-active-color: var(--shop-on-accent); --bs-pagination-active-bg: var(--shop-accent); --bs-pagination-active-border-color: var(--shop-accent); --bs-pagination-color: var(--shop-accent); }
.text-bg-primary { background-color: var(--shop-accent) !important; color: var(--shop-on-accent) !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus, .btn:focus-visible {
  border-color: var(--shop-accent);
  box-shadow: 0 0 0 0.2rem rgba(var(--shop-accent-rgb), 0.25);
}
.form-check-input:checked { background-color: var(--shop-accent); border-color: var(--shop-accent); }

/* ---------- Header ---------- */
.site-navbar {
  background: var(--shop-header-bg);
  border-bottom: 1px solid var(--shop-header-border);
  --bs-navbar-color: var(--shop-header-muted);
  --bs-navbar-hover-color: var(--shop-header-text);
  --bs-navbar-active-color: var(--shop-header-text);
  --bs-navbar-brand-color: var(--shop-header-text);
  --bs-navbar-brand-hover-color: var(--shop-header-text);
  --bs-navbar-toggler-border-color: var(--shop-header-border);
}
.site-navbar .nav-link { color: var(--shop-header-muted); }
.site-navbar .nav-link:hover, .site-navbar .nav-link:focus-visible { color: var(--shop-header-text); }
/* Dark headers (Dark, Blue, Gray) need the light version of Bootstrap's menu icon. */
html[data-theme="dark"] .site-navbar, html[data-theme="blue"] .site-navbar, html[data-theme="gray"] .site-navbar {
  --bs-navbar-toggler-icon-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}
html[data-theme="blue"] .site-navbar .brand-mark, html[data-theme="gray"] .site-navbar .brand-mark {
  background: #ffffff; color: var(--shop-header-bg);
}
html[data-theme="blue"] .site-navbar .header-search .btn-primary, html[data-theme="gray"] .site-navbar .header-search .btn-primary {
  --bs-btn-bg: #ffffff; --bs-btn-border-color: #ffffff; --bs-btn-color: var(--shop-header-bg);
  --bs-btn-hover-bg: var(--shop-surface); --bs-btn-hover-border-color: var(--shop-surface); --bs-btn-hover-color: var(--shop-header-bg);
  --bs-btn-active-bg: var(--shop-surface); --bs-btn-active-color: var(--shop-header-bg);
}

/* Theme picker */
.theme-swatch {
  display: inline-block; width: 1rem; height: 1rem; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2); vertical-align: -0.15rem;
}
.theme-swatch-light { background: linear-gradient(135deg, #ffffff 50%, #1f5f8b 50%); }
.theme-swatch-dark { background: linear-gradient(135deg, #0f141a 50%, #5aa9e6 50%); }
.theme-swatch-blue { background: linear-gradient(135deg, #0d2f5f 50%, #e4eef9 50%); }
.theme-swatch-gray { background: linear-gradient(135deg, #2f353c 50%, #e5e7ea 50%); }
.theme-menu .dropdown-item { display: flex; align-items: center; gap: 0.6rem; }
.theme-menu .theme-check { margin-left: auto; visibility: hidden; color: var(--shop-accent); }
.theme-menu [aria-checked="true"] .theme-check { visibility: visible; }
.brand { font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem; border-radius: 8px;
  background: var(--shop-accent); color: var(--shop-on-accent); font-size: 1rem;
}
.header-search { max-width: 34rem; }
.cart-link { display: flex; align-items: center; white-space: nowrap; }
.category-bar { background: var(--shop-surface); border-bottom: 1px solid var(--shop-border); }
/* Wraps rather than scrolls on narrow screens: a scrolling container would clip the dropdown menus. */
.category-bar .nav-link { color: var(--shop-nav-text); padding: 0.6rem 0.9rem; white-space: nowrap; font-size: 0.95rem; }
.category-bar .nav-link:hover { color: var(--shop-accent); }
@media (max-width: 575.98px) { .category-bar .nav-link { padding: 0.45rem 0.6rem; } }

/* ---------- Footer ---------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--shop-border);
  background: var(--shop-surface);
  color: var(--shop-text-muted);
  padding: 1.25rem 0;
  font-size: 0.9rem;
}

/* ---------- WhatsApp chat button ---------- */
/* WhatsApp green, darkened enough for white text to stay readable (about 5:1) in every theme. */
.whatsapp-button {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 1030;
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem; border-radius: 999px;
  background: #128048; color: #ffffff; font-weight: 600; text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.whatsapp-button:hover, .whatsapp-button:focus-visible { background: #0d6638; color: #ffffff; transform: translateY(-2px); }
.whatsapp-button:focus-visible { outline: 3px solid var(--shop-accent); outline-offset: 3px; }
.whatsapp-button svg { width: 1.9rem; height: 1.9rem; flex: none; }
.whatsapp-label { display: none; }
@media (min-width: 768px) {
  .whatsapp-button { right: 1.5rem; bottom: 1.5rem; padding: 0.6rem 1.1rem 0.6rem 0.7rem; }
  .whatsapp-label { display: inline; }
}
@media (prefers-reduced-motion: reduce) { .whatsapp-button { transition: none; } .whatsapp-button:hover, .whatsapp-button:focus-visible { transform: none; } }
@media print { .whatsapp-button { display: none; } }

/* ---------- Home ---------- */
.hero {
  border-radius: var(--shop-radius);
  padding: 3rem 2rem;
  background: linear-gradient(120deg, var(--shop-hero-from) 0%, var(--shop-hero-to) 100%);
}
.hero h1 { font-weight: 700; font-size: clamp(1.8rem, 4vw, 2.75rem); max-width: 22ch; }
.hero .lead { max-width: 46ch; color: var(--shop-text-soft); }
.section-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 1rem; }
.category-tile {
  display: flex; flex-direction: column; justify-content: center; gap: 0.25rem;
  height: 100%; min-height: 6rem; padding: 1rem 1.25rem;
  border: 1px solid var(--shop-border); border-radius: var(--shop-radius);
  text-decoration: none; color: inherit; background: var(--shop-card);
  transition: border-color .15s, box-shadow .15s;
}
.category-tile:hover { border-color: var(--shop-accent); box-shadow: 0 4px 14px var(--shop-shadow); }
.category-name { font-weight: 600; font-size: 1.05rem; }
.category-children { font-size: 0.85rem; color: var(--shop-text-muted); }

/* ---------- Product cards ---------- */
.product-card { border: 1px solid var(--shop-border); border-radius: var(--shop-radius); overflow: hidden; background: var(--shop-card); transition: box-shadow .15s, transform .15s; }
.product-card:hover { box-shadow: 0 6px 20px var(--shop-shadow); transform: translateY(-2px); }
.product-card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.product-media { position: relative; aspect-ratio: 1 / 1; background: var(--shop-surface); }
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.product-flag { position: absolute; top: 0.6rem; left: 0.6rem; }
.product-body { padding: 0.85rem 1rem 1rem; }
.product-meta { font-size: 0.8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--shop-text-muted); }
.product-name { font-size: 1rem; font-weight: 600; margin: 0.2rem 0 0.4rem; line-height: 1.3; }
.product-price { font-weight: 700; }

/* Promotion: the list price struck through after the price customers pay. */
.price-was { margin-left: .4em; font-size: .85em; font-weight: 400; color: var(--bs-secondary-color); }
.product-placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: 2.25rem; font-weight: 700; letter-spacing: .05em;
  color: var(--shop-placeholder-text);
  background: linear-gradient(135deg, var(--shop-placeholder-from), var(--shop-placeholder-to));
}
.product-placeholder-lg { font-size: 4rem; }

/* ---------- Listing filters ---------- */
.filter-panel { border: 1px solid var(--shop-border); border-radius: var(--shop-radius); padding: 1.25rem; position: sticky; top: 1rem; }
.filter-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--shop-text-muted); margin-bottom: 0.6rem; }
.category-tree a { display: block; padding: 0.2rem 0; color: var(--shop-nav-text); text-decoration: none; }
.category-tree a:hover { color: var(--shop-accent); }
.category-tree a.active { color: var(--shop-accent); font-weight: 600; }

/* ---------- Product details ---------- */
.gallery-main { aspect-ratio: 1 / 1; border-radius: var(--shop-radius); overflow: hidden; background: var(--shop-surface); }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.gallery-thumb { width: 4.5rem; height: 4.5rem; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--shop-surface); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumb.active { border-color: var(--shop-accent); }
.product-price-lg { font-size: 1.6rem; font-weight: 700; }
.buy-box { max-width: 28rem; }
.quantity-input { width: 6rem; }
.product-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; font-size: 0.95rem; }
.product-facts dt { color: var(--shop-text-muted); font-weight: 500; }
.product-facts dd { margin: 0; }

/* ---------- Cart, checkout, account ---------- */
.panel { border: 1px solid var(--shop-border); border-radius: var(--shop-radius); padding: 1.25rem 1.5rem; background: var(--shop-card); }
.summary-panel { background: var(--shop-surface); position: sticky; top: 1rem; }
.summary-row { display: flex; justify-content: space-between; padding: 0.3rem 0; }
.summary-total { border-top: 1px solid var(--shop-border); margin-top: 0.5rem; padding-top: 0.75rem; font-weight: 700; font-size: 1.1rem; }
.line-item { display: grid; grid-template-columns: 5rem 1fr auto; gap: 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--shop-border); }
.line-item:last-child { border-bottom: 0; }
.line-thumb { width: 5rem; height: 5rem; border-radius: 8px; overflow: hidden; background: var(--shop-surface); }
.line-thumb .product-placeholder { font-size: 1.25rem; }
.line-title { font-weight: 600; color: inherit; text-decoration: none; }
.line-title:hover { color: var(--shop-accent); }
.line-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.line-actions .form-control { width: 5rem; }
@media (max-width: 575.98px) {
  .line-item { grid-template-columns: 4rem 1fr; }
  .line-thumb { width: 4rem; height: 4rem; }
  .line-total { grid-column: 2; }
}
.address-option { display: block; border: 1px solid var(--shop-border); border-radius: 10px; padding: 0.85rem 1rem; cursor: pointer; height: 100%; }
.address-option:has(input:checked) { border-color: var(--shop-accent); box-shadow: 0 0 0 1px var(--shop-accent); }
.auth-card { max-width: 28rem; margin: 1rem auto; }
.status-badge { font-weight: 600; }
.empty-state { text-align: center; padding: 3.5rem 1rem; border: 1px dashed var(--shop-border); border-radius: var(--shop-radius); }
.account-nav .nav-link { color: var(--shop-nav-text); border-radius: 8px; }
.account-nav .nav-link.active { background: var(--shop-surface); color: var(--shop-accent); font-weight: 600; }

/* ---------- Catalog management (Admin/Staff) ---------- */
.manage-header { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.manage-header .account-nav { flex-direction: row; }
.manage-thumb { width: 3rem; height: 3rem; }
.manage-thumb .product-placeholder { font-size: 0.9rem; }
.manage-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 0.75rem; }
.manage-image { display: flex; flex-direction: column; gap: 0.35rem; cursor: pointer; }
.manage-image img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--shop-border); background: var(--shop-surface); }
.manage-image:has(input:not(:checked)) img { opacity: 0.35; }
.variant-input { min-width: 6rem; }
.variant-price { width: 6.5rem; }
.variant-stock { width: 6.5rem; }

/* ---------- Order management (Admin/Staff) ---------- */
.order-tabs { --bs-nav-pills-link-active-bg: var(--shop-accent); }
.order-tabs .nav-link { color: var(--shop-nav-text); }
.order-tabs .nav-link.active { color: var(--shop-on-accent); }
.order-steps { display: flex; list-style: none; padding: 0; margin: 0; counter-reset: step; }
.order-steps li {
  flex: 1; position: relative; text-align: center; font-size: 0.85rem; color: var(--shop-text-muted);
  padding-top: 2.1rem; counter-increment: step;
}
.order-steps li::before {
  content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); z-index: 1;
  width: 1.75rem; height: 1.75rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--shop-card); border: 2px solid var(--shop-border); font-weight: 600;
}
.order-steps li + li::after {
  content: ""; position: absolute; top: 0.85rem; left: -50%; width: 100%; height: 2px; background: var(--shop-border);
}
.order-steps li.done, .order-steps li.current { color: var(--shop-text); font-weight: 600; }
.order-steps li.done::before { content: "\2713"; background: var(--shop-accent); border-color: var(--shop-accent); color: var(--shop-on-accent); }
.order-steps li.current::before { border-color: var(--shop-accent); color: var(--shop-accent); }
.order-steps li.done + li::after, .order-steps li.done + li.current::after { background: var(--shop-accent); }
