/*
  Aft Store Custom CSS
  Luxury e-commerce store
  Tailwind + Custom Styles
*/

/* ==========================================================================
   1. VARIABLES & THEMING
   ========================================================================== */
:root {
  /* Light Mode */
  --bg: #FAFAF7;
  --bg2: #F0EDE8;
  --fg: #1C1C1C;
  --fg-muted: #7A756D;
  --accent: #B8945F;
  --accent-dark: #9A7A4A;
  --card: #FFFFFF;
  --border: #E2DDD5;
  --glass: rgba(255, 255, 255, 0.88);
  --shadow: rgba(0, 0, 0, 0.06);
}

html.dark {
  /* Dark Mode */
  --bg: #0F0F0F;
  --bg2: #1A1A1A;
  --fg: #E5E0D8;
  --fg-muted: #9A9590;
  --accent: #D4B87A;
  --accent-dark: #B89A5E;
  --card: #1C1C1C;
  --border: #333333;
  --glass: rgba(28, 28, 28, 0.88);
  --shadow: rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   2. RESET & BASE
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Tajawal', sans-serif;
  background-color: var(--bg);
  color: var(--fg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fg-muted);
}

/* ==========================================================================
   3. TYPOGRAPHY
   ========================================================================== */
.luxury-title {
  font-family: 'Playfair Display', serif;
  letter-spacing: 0.3px;
}

.gold-text {
  background: linear-gradient(to right, var(--accent), var(--accent-dark));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */
/* Cards */
.prod-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
  border-radius: 8px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
}
.prod-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px var(--shadow);
}

.prod-img {
  transition: transform 0.4s ease;
  display: block;
}
.prod-card:hover .prod-img {
  transform: scale(1.05);
}

/* Buttons & Effects */
.shimmer-btn {
  position: relative;
  overflow: hidden;
}
.shimmer-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
}
.shimmer-btn:hover::after {
  left: 150%;
}

.glow-hover {
  position: relative;
  overflow: hidden;
}
.glow-hover::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.6s ease;
}
.glow-hover:hover::before {
  left: 150%;
}

/* Loader */
#loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  z-index: 99999;
  transition: opacity .6s, visibility .6s;
}
.loader-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Layout & Pages */
.page {
  display: none;
  padding-top: 84px;
  animation: fadeInPage 0.4s ease forwards;
}
.page.active {
  display: block;
}
@keyframes fadeInPage {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Horizontal Scroll (Best Sellers) */
.best-seller-scroll {
  display: flex;
  overflow-x: auto;
  gap: 16px;
  padding-bottom: 16px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Firefox */
}
.best-seller-scroll::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}
.best-seller-card {
  min-width: 220px;
  flex-shrink: 0;
  scroll-snap-align: start;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: transform 0.3s ease;
}
.best-seller-card:hover {
  transform: translateY(-4px);
}


/* Modals & Overlays */
#overlay-bg {
  position: fixed;
  inset: 0;
  background: var(--glass);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
}
#overlay-bg.active {
  display: block;
}

#modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 8500;
  display: none;
}


/* Mobile Menu */
#mobile-menu {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 300px;
  background-color: var(--card);
  z-index: 3000;
  transition: transform 0.3s ease;
  overflow-y: auto;
  border-inline-end: 1px solid var(--border);
}
[dir="ltr"] #mobile-menu {
  left: 0;
  transform: translateX(-100%);
}
[dir="ltr"] #mobile-menu.active {
  transform: translateX(0);
}
[dir="rtl"] #mobile-menu {
  right: 0;
  transform: translateX(100%);
}
[dir="rtl"] #mobile-menu.active {
  transform: translateX(0);
}

/* Forms & Inputs */
.order-input {
  width: 100%;
  padding: 12px 16px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.order-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 148, 95, 0.2);
}

/* Decorative Orbs */
.deco-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.5;
}
html.dark .deco-orb {
  opacity: 0.15;
}

/* Product Gallery */
.gallery-main {
  height: 520px;
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  cursor: zoom-in;
  background-color: var(--bg2);
}
.gallery-thumbs {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  margin-top: 16px;
  padding-bottom: 8px;
  scrollbar-width: thin;
}
.thumb {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  flex-shrink: 0;
}
.thumb.active, .thumb:hover {
  border-color: var(--accent);
}


/* Back to Top */
#back-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background-color: var(--accent);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow);
  z-index: 500;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
}
#back-top.visible {
  opacity: 1;
  visibility: visible;
}
#back-top:hover {
  transform: translateY(-4px);
}
[dir="rtl"] #back-top {
  right: auto;
  left: 32px;
}

/* Search Results */
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: var(--card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 5000;
  max-height: 400px;
  overflow-y: auto;
  display: none;
}
.search-results.active {
  display: block;
}
.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  text-decoration: none;
  transition: background-color 0.2s;
}
.search-result-item:last-child {
  border-bottom: none;
}
.search-result-item:hover {
  background-color: var(--bg2);
}

/* Toast Notification */
#toast.show {
  transform: translateX(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* Language Select */
.lang-select {
  appearance: none;
  background-color: var(--bg2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 32px 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231C1C1C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}
[dir="rtl"] .lang-select {
  padding: 8px 16px 8px 32px;
  background-position: left 8px center;
}
html.dark .lang-select {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23E5E0D8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* Tabs */
.detail-tab {
  padding: 12px 24px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}
.detail-tab.active, .detail-tab:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.detail-tab-content {
  display: none;
  padding: 24px 0;
}
.detail-tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* Categories/Filters */
.sub-cat-btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  background-color: var(--card);
  color: var(--fg);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.sub-cat-btn:hover, .sub-cat-btn.active {
  background-color: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

[dir='ltr'] .filter-btn {
  text-align: left;
}

/* Z-Index Layouts (Explicit Overrides) */
#lightbox { z-index: 99999 !important; }
#navbar { z-index: 1000; position: relative; }
#sticky-buy-bar { z-index: 600; }

/* Utilities */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==========================================================================
   5. RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
    width: 100%;
  }
  .gallery-main {
    height: 320px;
  }
  .thumb {
    width: 56px;
    height: 56px;
  }
  .best-seller-card {
    min-width: 160px;
  }
  #back-top {
    bottom: 120px;
  }

  .page {
    padding-top: 72px;
  }
  .loader-spinner {
    width: 36px;
    height: 36px;
    border-width: 3px;
  }
  #lightbox img {
    max-width: 95vw !important;
    max-height: 70vh !important;
  }
}

/* ==========================================================================
   6. REDUCED MOTION
   ========================================================================== */
@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;
  }
  .page {
    animation: none !important;
  }
}
.order-input.error { border-color: #ef4444 !important; background-color: #fef2f2 !important; } .dark .order-input.error { background-color: rgba(239,68,68,0.1) !important; }
