/* ===============================
    Categories Page Style
    (رنگ‌بندی هماهنگ با home.css)
==================================*/

/* عنوان صفحه */
.categories-page-title {
  width: 98%;
  max-width: 1700px;
  margin: 14px auto 6px;
  padding: 0 20px;
  text-align: center;
}

.categories-page-title h1 {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--c-primary);
  margin: 0;
}

/* هدر دکمه فعال (دسته بندی) در نویگیشن بالای سایت */
.header-btn.active {
  background: var(--c-primary-dark);
}

/* ================= چیدمان کلی: راست = لیست دسته‌ها / چپ و وسط = محصولات =================
   این چیدمان مال دسکتاپه (سایدبار عمودی چسبیده به راست). داخل گوشی
   (پایین‌تر تو @media max-width:900px) این کاملا به یه نوار افقی بالای
   صفحه تبدیل می‌شه. */
.categories-page {
  width: 100%;
  max-width: 1900px;
  margin: 0 auto 40px;
  padding: 0;
  display: flex;
  align-items: flex-start;
  gap: 0;
}

/* ================= سایدبار سمت راست (چسبیده به کناره صفحه) - دسکتاپ ================= */
.categories-sidebar {
  flex: 0 0 220px;
  width: auto;
  background: var(--c-primary-light);
  border-radius: 0;
  border-top-left-radius: 24px;
  border-bottom-left-radius: 24px;
  padding: 24px 20px;
  position: sticky;
  top: 100px;
  z-index: 20;
  box-shadow: 6px 0 24px rgba(0, 0, 0, 0.05);
}

.categories-sidebar h3 {
  color: var(--c-primary);
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--c-primary-soft);
}

.categories-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-btn {
  width: 100%;
  flex-shrink: 0;
  white-space: nowrap;
  text-align: right;
  background: transparent;
  border: none;
  color: var(--c-text);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-size: 1rem;
  font-weight: 500;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: .25s;
}

.cat-btn:hover {
  background: var(--c-primary-light);
  color: var(--c-primary);
}

.cat-btn.active {
  background: var(--c-primary);
  color: #fff;
  font-weight: 700;
}

/* ================= بخش محصولات سمت چپ و وسط - دسکتاپ ================= */
.categories-products {
  flex: 1;
  min-width: 0;
  padding: 26px 26px 26px 22px;
}

/* نوار بالای لیست محصولات: فیلتر مرتب‌سازی */
.products-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.sort-dropdown {
  position: relative;
  display: inline-block;
}

.sort-select {
  background: #ffffff;
  border: 1.5px solid var(--c-primary-soft);
  color: var(--c-primary);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 12px;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-select i {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.sort-dropdown.open .sort-select i {
  transform: rotate(180deg);
}

.sort-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: #ffffff;
  border: 1.5px solid var(--c-primary-soft);
  border-radius: 12px;
  list-style: none;
  margin: 0;
  padding: 6px;
  z-index: 20;
  display: none;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.sort-dropdown.open .sort-menu {
  display: block;
}

.sort-menu li {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  white-space: nowrap;
}

.sort-menu li:hover {
  background: var(--c-primary-light);
  color: var(--c-primary);
}

.sort-menu li.active {
  background: var(--c-accent);
  color: #fff;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 22px;
}

/* کارت‌های محصول تو صفحه دسته‌بندی، کمی بهتر از حالت پیش‌فرض دیده بشن:
   عریض‌تر (چون گرید بالا عرض بیشتری بهشون می‌ده)، سایه‌ی نرم‌تر و
   یه انیمیشن ملایم هنگام هاور */
.products-grid .product-card {
  width: 100%;
  min-width: 0;
  border-radius: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

.products-grid .card-top {
  height: 190px;
}

.no-products {
  text-align: center;
  color: var(--c-text-muted);
  font-size: 1.1rem;
  padding: 60px 0;
}

/* ================= واکنش‌گرا (موبایل) =================
   از اینجا به پایین، سایدبار عمودی کامل تبدیل می‌شه به یه نوار افقی
   بالای صفحه (قابل اسکرول با انگشت)؛ محصولات هم عرض کامل و فضای باز
   می‌گیرن. دسکتاپ (بالای ۹۰۰px) دست‌نخورده، همون سایدبار راست قبلیه. */
@media (max-width: 900px) {
  .categories-page {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .categories-sidebar {
    flex: 0 0 auto;
    width: 100%;
    padding: 10px 12px;
    position: sticky;
    top: 90px;
    border-radius: 16px;
  }

  .categories-sidebar h3 {
    display: none;
  }

  .categories-list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .categories-list::-webkit-scrollbar {
    display: none;
  }

  .cat-btn {
    width: auto;
    text-align: center;
    font-size: 0.85rem;
    padding: 9px 16px;
    border-radius: 999px;
  }

  .categories-products {
    padding: 0 4px;
  }

  .products-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .products-grid .product-card {
    border-radius: 14px;
  }

  .products-grid .card-top {
    height: 100px;
  }

  .products-grid .card-info {
    font-size: 0.74rem;
    line-height: 1.3;
    padding: 8px 6px 4px;
  }

  .products-grid .card-info span {
    font-size: 0.62rem;
  }

  .products-grid .card-bottom {
    padding: 6px 6px 10px;
    gap: 4px;
  }

  .products-grid .plus-btn {
    width: 24px;
    height: 24px;
    font-size: 14px;
  }

  .products-grid .fav-btn {
    width: 24px;
    height: 24px;
    font-size: 12px;
  }

  .products-grid .price {
    font-size: 0.66rem;
    padding: 4px 6px;
  }
}

/* گوشی‌های کوچیک: دو ستونی، تا کارت‌ها به‌جای فشرده‌شدن، واقعاً عریض
   و قابل‌خوندن باشن */
@media (max-width: 560px) {
  .categories-sidebar {
    padding: 8px 10px;
    top: 78px;
  }

  .cat-btn {
    font-size: 0.78rem;
    padding: 8px 14px;
  }

  .categories-products {
    padding: 0 2px;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .products-grid .card-top {
    height: 140px;
  }

  .products-grid .card-info {
    font-size: 0.82rem;
  }

  .products-grid .card-info span {
    font-size: 0.68rem;
  }

  .products-grid .price {
    font-size: 0.72rem;
    padding: 5px 11px;
  }

  .products-grid .plus-btn {
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  .products-grid .fav-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .categories-page-title h1 {
    font-size: 1.4rem;
  }

  .products-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .sort-dropdown,
  .sort-select {
    width: 100%;
    justify-content: center;
  }

  .sort-menu {
    left: auto;
    right: 0;
  }
}

/* دکمه بازگشت از نتایج جستجو به همه محصولات */
.back-to-all-btn {
  display: block;
  margin: 10px auto 0;
  padding: 10px 24px;
  background: var(--c-primary);
  color: #fff;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  font-weight: 700;
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  transition: background .25s;
}

.back-to-all-btn:hover {
  background: var(--c-primary-dark);
}
