/* تعریف متغیرهای پالت رنگی اختصاصی */
:root {
  --primary-bg: #110b11; /* بادمجانی بسیار تیره (زغال سرد) */
  --secondary-text: #d35400; /* نارنجی گداخته */
  --accent-cta: #e74c3c; /* قرمز آتشین */
  --light-bg: #1c121c; /* بادمجانی ملایم تر */
  --main-text: #eaeaea;
  --hover-color: #f39c12; /* زرد گداخته */
  --card-bg: #1a121a;
}

/* شخصی‌سازی اسکرول‌بار مرورگر */
::-webkit-scrollbar {
  width: 10px;
}
::-webkit-scrollbar-track {
  background: var(--primary-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--secondary-text);
  border-radius: 5px;
  border: 2px solid var(--primary-bg);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cta);
}

/* تنظیمات پایه */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Vazirmatn", sans-serif;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

body {
  background-color: var(--primary-bg);
  color: #ffffff;
  overflow-x: hidden;
  padding-top: 140px; /* فضا برای هدر فیکس دسکتاپ */
}

/* --- ساختار هدر یکپارچه و مدرن --- */
.main-header {
  position: fixed;
  top: 20px;
  left: 5%;
  right: 5%;
  background: rgba(27, 18, 27, 0.9);
  backdrop-filter: blur(15px);
  border: 1px solid rgba(211, 84, 0, 0.25);
  border-radius: 30px;
  padding: 15px 30px;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* ردیف اصلی هدر در دسکتاپ */
.header-desktop-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-area img {
  height: 45px;
  width: auto;
  filter: drop-shadow(0 0 5px var(--secondary-text));
}
.logo-text {
  font-weight: 900;
  font-size: 1.2rem;
  color: #ffffff;
  text-decoration: none;
}

/* ناوبری دسکتاپ */
.nav-menu {
  display: flex;
  list-style: none;
  gap: 30px;
}
.nav-menu a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
}
.nav-menu a:hover {
  color: var(--secondary-text);
}

/* دکمه و باکس جستجو دسکتاپ */
.header-left-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* باکس جستجوی مدرن */
.search-box {
  position: relative;
  width: 220px;
  display: flex;
  align-items: center;
}
.search-box input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(211, 84, 0, 0.3);
  padding: 8px 35px 8px 15px;
  border-radius: 20px;
  color: white;
  font-size: 0.85rem;
  outline: none;
}
.search-box input:focus {
  border-color: var(--secondary-text);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 10px rgba(211, 84, 0, 0.3);
}
.search-box svg {
  position: absolute;
  right: 12px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #aaa;
}

/* دکمه سبد خرید */
.cart-btn {
  background: linear-gradient(135deg, var(--accent-cta), var(--secondary-text));
  border: none;
  color: white;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}
.cart-btn:hover {
  background: var(--hover-color);
  transform: scale(1.05);
}
.cart-badge {
  background-color: white;
  color: var(--accent-cta);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

/* هدر موبایل (پیش‌فرض غیر فعال) */
.header-mobile-layout {
  display: none;
}

/* --- پنل کشویی سبد خرید (Cart Drawer) --- */
.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 1999;
  display: none;
}
.cart-overlay.open {
  display: block;
}

.cart-drawer {
  position: fixed;
  top: 0;
  left: -380px;
  width: 350px;
  height: 100vh;
  background: #181018;
  border-right: 2px solid var(--secondary-text);
  z-index: 2000;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  padding: 25px;
}
.cart-drawer.open {
  left: 0;
}

.cart-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 15px;
}
.close-cart-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}
.cart-items-container {
  flex-grow: 1;
  overflow-y: auto;
}
.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  padding: 12px 15px;
  border-radius: 10px;
  margin-bottom: 10px;
  border: 1px solid rgba(211, 84, 0, 0.1);
}
.cart-item-details {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cart-item-title {
  font-weight: bold;
  font-size: 0.95rem;
}
.cart-item-price {
  color: var(--secondary-text);
  font-size: 0.85rem;
}
.remove-item-btn {
  background: transparent;
  border: none;
  color: #e74c3c;
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
}
.remove-item-btn:hover {
  background: rgba(231, 76, 60, 0.1);
}
.remove-item-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}
.checkout-btn {
  background: linear-gradient(135deg, var(--accent-cta), var(--secondary-text));
  color: white;
  border: none;
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
}

/* --- ساختار صفحه محصولات --- */
.page-container {
  display: flex;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 5%;
  gap: 30px;
}

/* بخش فیلترها (سایدبار) */
.filter-sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--light-bg);
  border: 1px solid rgba(211, 84, 0, 0.15);
  border-radius: 20px;
  padding: 25px;
  height: fit-content;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.filter-group {
  margin-bottom: 30px;
}

.filter-title {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--secondary-text);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 10px;
}

.filter-title svg {
  width: 18px;
  height: 18px;
  stroke: var(--secondary-text);
}

.category-list {
  list-style: none;
}
.category-list li {
  margin-bottom: 15px;
}
.category-list label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-size: 0.95rem;
  position: relative;
  user-select: none;
}
.category-list input[type="checkbox"] {
  display: none;
}
.custom-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(211, 84, 0, 0.4);
  border-radius: 50%;
  display: inline-block;
  position: relative;
  background: rgba(255, 255, 255, 0.03);
}
.category-list input[type="checkbox"]:checked + .custom-checkbox {
  border-color: var(--secondary-text);
  background: var(--secondary-text);
  box-shadow: 0 0 8px rgba(211, 84, 0, 0.6);
}
.category-list input[type="checkbox"]:checked + .custom-checkbox::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  background-color: white;
  border-radius: 50%;
}

.price-range-wrapper {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.price-range-wrapper input[type="range"] {
  accent-color: var(--secondary-text);
  width: 100%;
  cursor: pointer;
}
.price-values {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #bbb;
}

/* گرید محصولات */
.products-area {
  flex-grow: 1;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 25px;
  perspective: 1000px;
}

/* کارت محصول ۳ بعدی */
.product-card {
  background-color: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  transform-style: preserve-3d;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}
.product-card:hover {
  border-color: rgba(211, 84, 0, 0.4);
  box-shadow: 0 20px 40px rgba(211, 84, 0, 0.15);
}

.product-img-wrapper {
  width: 100%;
  height: 220px;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.product-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info {
  padding: 20px;
  position: relative;
  z-index: 2;
  background: var(--card-bg);
}
.product-name {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.product-desc {
  font-size: 0.85rem;
  color: #aaa;
  margin-bottom: 15px;
  line-height: 1.6;
  height: 50px;
  overflow: hidden;
}
.price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}
.new-price {
  color: var(--secondary-text);
  font-weight: bold;
  font-size: 1.2rem;
}

.add-to-cart-btn {
  width: 100%;
  background: transparent;
  border: 2px solid var(--accent-cta);
  color: #ffffff;
  padding: 10px;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.add-to-cart-btn:hover {
  background: var(--accent-cta);
  box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}

/* سیستم نوتیفیکیشن Toast */
#toast-container {
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: rgba(17, 11, 17, 0.95);
  border-left: 5px solid var(--accent-cta);
  color: #ffffff;
  padding: 15px 25px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 12px;
  transform: translateX(-120%);
  animation: slideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.toast.hide {
  animation: slideOut 0.5s ease forwards;
}

@keyframes slideIn {
  to {
    transform: translateX(0);
  }
}
@keyframes slideOut {
  to {
    transform: translateX(-150%);
    opacity: 0;
  }
}

/* واکنش‌گرایی صفحه */
@media (max-width: 992px) {
  .page-container {
    flex-direction: column;
  }
  .filter-sidebar {
    width: 100%;
  }
}

/* --- استایل دهی مجدد و دقیق هدر در موبایل به سبک عکس دوم --- */
@media (max-width: 768px) {
  /* مخفی کردن چیدمان دسکتاپ و فعال کردن موبایل */
  .header-desktop-row {
    display: none;
  }
  .header-mobile-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* هدر کمی فشرده‌تر در موبایل */
  .main-header {
    top: 10px;
    left: 3%;
    right: 3%;
    padding: 12px 15px;
    border-radius: 20px;
  }

  /* ردیف اول: لوگو وسط */
  .mobile-brand-row {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  /* تنظیم ابعاد تصویر لوگو در موبایل تا از هدر بیرون نزند */
  .mobile-brand-row img {
    height: 40px; /* ابعاد هماهنگ با طراحی ظریف موبایل */
    width: auto;
    filter: drop-shadow(0 0 5px var(--secondary-text));
    transition: transform 0.3s ease;
  }
  .mobile-brand-row .logo-text {
    font-size: 1.1rem;
    font-weight: 900;
  }

  /* ردیف دوم: منوی افقی وسط */
  .mobile-nav-row {
    width: 100%;
  }
  .mobile-nav-menu {
    display: flex;
    list-style: none;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
  }
  .mobile-nav-menu a {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
  }
  .mobile-nav-menu a:hover {
    color: var(--secondary-text);
  }

  /* ردیف سوم: سبد (راست) + جستجو (چپ) کنار هم */
  .mobile-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 10px;
  }
  .mobile-actions-row .cart-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: 15px;
  }

  /* اصلاح باکس جستجو در موبایل تا از هدر بیرون نزنه */
  .mobile-search-row {
    flex-grow: 1;
    width: auto;
    min-width: 0; /* مهم: جلوگیری از سرریز در flex */
  }
  .mobile-search-row input {
    width: 100%;
    min-width: 0;
  }

  /* بدنه: کم کردن فاصله بالا چون هدر سه‌ردیفه بلندتره */
  body {
    padding-top: 170px;
  }
}
