/* ══════════════════════════════════════════════════════════════════
   THEME SYSTEM — Car Option Store
   Single source of truth for tokens, component classes and fixes.
   MUST be loaded last (after tailwind.css / premium-theme.css /
   animations.css / tailwind-custom.css).
   ══════════════════════════════════════════════════════════════════ */

/* ============================================================
   0. MISSING UTILITY BRIDGE
   (classes referenced in markup but absent from compiled tailwind)
   ============================================================ */
.bg-card-hover { background-color: var(--bg-card-hover, #23262A); }
.hover\:bg-card-hover:hover { background-color: var(--bg-card-hover, #23262A) !important; }

.divide-white\/5 > :not([hidden]) ~ :not([hidden]) { border-color: rgba(255, 255, 255, 0.05); }
.max-h-72 { max-height: 288px; }
.min-h-\[44px\] { min-height: 44px; }
.min-h-\[48px\] { min-height: 48px; }
.h-\[42px\] { height: 42px; }

/* Native controls (selects, scrollbars) should render dark */
:root { color-scheme: dark; }
select.input-dark option,
select option {
  background: #17181B;
  color: #fff;
}

/* ============================================================
   1. LAYOUT — unified container
   ============================================================ */
.container-store {
  width: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 16px;
}
@media (min-width: 640px)  { .container-store { padding-inline: 24px; } }
@media (min-width: 1024px) { .container-store { padding-inline: 32px; } }

/* Neutralize legacy `container mx-auto px-4` gutters mismatch:
   keep them working but with the same rhythm as container-store. */
main .container.mx-auto { max-width: 1440px; }

/* ============================================================
   2. COMPONENT PRIMITIVES
   ============================================================ */

/* ── Surfaces ── */
.surface-card {
  background: linear-gradient(145deg, #1D1F22 0%, #17181B 100%);
  border: 1px solid var(--border-card);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}
.surface-inset {
  background: rgba(11, 11, 12, 0.5);
  border: 1px solid var(--border-card);
  border-radius: 14px;
}

/* ── Inputs (dark) ── */
.input-dark,
.input-dark:focus {
  background: rgba(11, 11, 12, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-radius: 12px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input-dark::placeholder { color: #6B6B6B; }
.input-dark:focus {
  outline: none;
  border-color: rgba(255, 138, 0, 0.55) !important;
  box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.12) !important;
}

/* ── Buttons ── */
.btn-accent {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, #FF8A00 0%, #FF6B00 100%);
  color: #000; font-weight: 700;
  border: none; border-radius: 12px;
  min-height: 44px; padding: 0 20px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 138, 0, 0.3);
  transition: filter 180ms ease, transform 120ms ease, box-shadow 180ms ease;
}
.btn-accent:hover  { filter: brightness(1.08); box-shadow: 0 6px 24px rgba(255, 138, 0, 0.4); }
.btn-accent:active { transform: scale(0.98); }
.btn-accent:disabled {
  opacity: 0.45; cursor: not-allowed; filter: grayscale(0.4);
  transform: none !important; box-shadow: none !important;
}

.btn-outline-dark {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: #E7E7E7; font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  min-height: 44px; padding: 0 20px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn-outline-dark:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 138, 0, 0.45);
  color: #fff;
}
.btn-outline-dark:active { transform: scale(0.98); }

/* ── Chips / badges ── */
.chip-dark {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 10px; border-radius: 10px;
  font-size: 12px; font-weight: 500;
  background: rgba(29, 31, 34, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #B8B8B8;
}

/* ============================================================
   3. ACCESSIBILITY — focus & selection
   ============================================================ */
:focus-visible {
  outline: 2px solid rgba(255, 138, 0, 0.75);
  outline-offset: 2px;
  border-radius: 6px;
}
::selection { background: rgba(255, 138, 0, 0.35); color: #fff; }

/* Screen-reader only helper */
.sr-only-x {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ============================================================
   4. HERO — responsive grid fix
   (replaces broken inline `grid-template-columns:46% 1fr`)
   ============================================================ */
[data-hero] .hero-grid {
  position: relative;
  z-index: 3;
  height: 100%;
  max-width: 1440px;
  margin-inline: auto;
  padding-inline: 16px;
  display: grid;
  grid-template-columns: 1fr;           /* mobile: single column */
  align-items: center;
}
@media (min-width: 640px)  { [data-hero] .hero-grid { padding-inline: 24px; } }
@media (min-width: 1024px) {
  [data-hero] .hero-grid {
    grid-template-columns: 46% 1fr;     /* desktop: content | car visual */
    padding-inline: 40px;
  }
}

/* Hero heights per breakpoint (mobile no longer forces 660px) */
[data-hero] { min-height: 520px; height: 88vh; }
@media (max-width: 639px) {
  [data-hero] { min-height: 480px; height: auto; }
  [data-hero] .hero-content-col { padding-top: 56px !important; padding-bottom: 48px !important; }
}
@media (min-width: 640px)  { [data-hero] { height: 80vh; } }
@media (min-width: 1024px) { [data-hero] { height: 92vh; max-height: 900px; } }

/* Mobile hero readability: strengthen right-side scrim so text stays legible
   when content stacks over the car image */
@media (max-width: 1023px) {
  [data-hero] .hero-scrim {
    background: linear-gradient(to bottom,
      rgba(0,0,0,0.30) 0%,
      rgba(0,0,0,0.45) 40%,
      rgba(0,0,0,0.78) 78%,
      rgba(0,0,0,0.92) 100%) !important;
  }
}

/* ============================================================
   5. HEADER — mini cart dropdown + active nav state
   ============================================================ */
.nav-link.active { color: #fff !important; }
.nav-link.active::after { width: 100% !important; }

/* ── Cart count badge — header: small floating number at top-left of icon ── */
#cart_items_count.cart-badge-count {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  min-width: auto;
  height: auto;
  padding: 0;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  color: #FF8A00;
  background: none !important;
  border: none;
  border-radius: 0;
  text-shadow: 0 0 6px rgba(255, 138, 0, 0.6), 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: none;
  animation: none;
}

/* ── Cart count badge — bottom nav: keeps pill style ── */
.bottom-nav .bn-badge {
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 9px;
  font-weight: 800;
  border-radius: 999px;
  border: 1.5px solid #0B0B0C;
  background: linear-gradient(135deg, #FFA020, #FF8A00) !important;
  color: #000;
  box-shadow:
    0 0 6px rgba(255, 138, 0, 0.35),
    0 2px 5px rgba(0, 0, 0, 0.45);
  animation: badgeGlow 3s ease-in-out infinite;
}
@keyframes badgeGlow {
  0%, 100% {
    box-shadow:
      0 0 5px rgba(255, 138, 0, 0.30),
      0 2px 5px rgba(0, 0, 0, 0.45);
  }
  50% {
    box-shadow:
      0 0 10px rgba(255, 138, 0, 0.50),
      0 0 16px rgba(255, 138, 0, 0.22),
      0 2px 5px rgba(0, 0, 0, 0.45);
  }
}
.bottom-nav .bn-badge {
  top: 0;
  left: calc(50% + 4px);
}

/* Pop feedback on count change (triggered from site.js via WAAPI) */
@keyframes badgePop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* ── Cart + Mini-cart ── */
.cart-wrapper { position: relative; }

.mini-cart {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: rgba(17, 18, 20, 0.98);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255,138,0,0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease, visibility 200ms;
  z-index: 60;
}
.cart-wrapper:hover .mini-cart,
.cart-wrapper:focus-within .mini-cart,
.mini-cart.open {
  opacity: 1; visibility: visible; transform: translateY(0);
}
.mini-cart-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 0;
}
.mini-cart-item + .mini-cart-item { border-top: 1px solid rgba(255,255,255,0.06); }
.mini-cart-thumb {
  width: 56px; height: 56px; flex-shrink: 0;
  border-radius: 10px; overflow: hidden;
  background: #fff; /* product photos are white-background assets */
  border: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
}
.mini-cart-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ============================================================
   6. MOBILE BOTTOM NAVIGATION (Digikala-style)
   ============================================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  background: rgba(13, 14, 15, 0.96);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px;
  font-size: 10.5px; font-weight: 600;
  color: #8A8D91;
  position: relative;
  transition: color 150ms ease;
}
.bottom-nav a:hover, .bottom-nav a.active { color: #FF8A00; }
.bottom-nav a .material-symbols-outlined { font-size: 23px; }
.bottom-nav .bn-badge {
  position: absolute; top: 4px; left: calc(50% - 4px);
  min-width: 17px; height: 17px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border-radius: 999px;
  background: #FF8A00; color: #000;
  font-size: 10px; font-weight: 800;
  box-shadow: 0 0 10px rgba(255,138,0,0.5);
}
body { padding-bottom: 58px; }             /* room for bottom nav on mobile */
@media (min-width: 768px) { body { padding-bottom: 0; } .bottom-nav { display: none; } }

/* Scroll-to-top must clear the bottom nav on mobile */
@media (max-width: 767px) {
  #scroll-top-btn { bottom: 74px !important; }
}

/* ============================================================
   7. DARK FIXES for animations.css remnants
   (this file loads after animations.css → same-specificity wins)
   ============================================================ */

/* Skeletons: light → dark glass */
.skeleton,
.skeleton-line,
.skeleton-avatar,
.skeleton-product-card,
.skeleton-image,
.skeleton-text,
.skeleton-title,
.skeleton-price,
.skeleton-button,
.skeleton-specs {
  background: linear-gradient(90deg, #17181B 25%, #212327 50%, #17181B 75%) !important;
  background-size: 200% 100% !important;
}
.loading-overlay { background: rgba(11, 11, 12, 0.72) !important; }

/* Thumbnail active: blue fallback → accent */
.thumbnail-btn.active,
.thumbnail-btn[style*="var(--accent)"] {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.15) !important;
}

/* Product-card hover glow that leaked blue */
.product-card:hover {
  box-shadow: 0 0 28px rgba(255, 138, 0, 0.14), 0 16px 48px rgba(0, 0, 0, 0.55) !important;
}

/* Kill micro-jitter: global button scale from animations.css */
button[type="button"]:hover { transform: none; }
.btn-micro:hover,
.add-to-cart-btn:hover,
.btn-glow:hover { transform: translateY(-1px); }

/* Toast: dark glass instead of bootstrap palette */
.toast-notification,
.site-toast {
  background: rgba(23, 24, 27, 0.97) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #F2F2F2 !important;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6) !important;
  border-radius: 14px !important;
}
.site-toast.toast-success { border-right: 3px solid #22C55E !important; }
.site-toast.toast-error   { border-right: 3px solid #EF4444 !important; }
.site-toast.toast-info    { border-right: 3px solid #FF8A00 !important; }

/* ============================================================
   8. MISC POLISH
   ============================================================ */

/* Product photo wells stay white on purpose (white-background photos),
   but soften them inside dark cards */
.img-well-light {
  background: #fff;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Consistent thin divider */
.hr-fade {
  height: 1px; width: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.09), transparent);
  border: none;
}

/* Sticky mobile add-to-cart bar (product page) */
.sticky-buy-bar {
  position: fixed;
  bottom: 58px;                    /* above bottom nav */
  left: 0; right: 0;
  z-index: 45;
  background: rgba(17, 18, 20, 0.97);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5);
  padding: 10px 16px;
  transform: translateY(110%);
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1);
}
.sticky-buy-bar.visible { transform: translateY(0); }
@media (min-width: 992px) { .sticky-buy-bar { display: none; } }

/* Orders table wrapper on small screens gets momentum scroll hint */
.table-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Reduced motion: respect globally */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
