/* ============ متغیرها و رنگ‌بندی ============ */
:root {
  --primary-color: #ef394e;       /* رنگ قرمز دیجی‌کالایی */
  --primary-soft: #fdebed;
  --link-color: #008eb2;          /* فیروزه‌ای لینک‌ها */
  --text-main: #232931;
  --text-muted: #62666d;
  --text-light: #81858b;
  --border-light: #f0f0f2;
  --border-dark: #e0e0e2;
  --bg-sidebar: #f5f5f7;
  --bg-sidebar-active: #ffffff;
  --max-width: 1320px;
}

body {
  margin: 0;
  background-color: #fcfcfc;
  color: var(--text-main);
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app-category-wrapper {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
}

/* ================= هدر بالای صفحه ================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 58px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.back-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-main);
  cursor: pointer;
  transition: background 0.15s ease;
}
.back-btn:hover { background: #f0f2f5; }
.back-btn svg { width: 22px; height: 22px; }

.topbar-icon {
  display: flex;
  align-items: center;
  color: var(--text-muted);
}
.topbar-icon svg { width: 22px; height: 22px; }

.breadcrumb-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

/* ================= چیدمان اصلی ================= */
.category-main-layout {
  display: flex;
  flex-direction: row-reverse; /* قرار دادن سایدبار در سمت راست در RTL */
  min-height: calc(100vh - 58px);
  background: #ffffff;
}

/* ================= سایدبار (پیش‌فرض موبایل) ================= */
.sidebar-panel {
  flex: 0 0 92px;
  background-color: var(--bg-sidebar);
  border-left: 1px solid var(--border-light);
}

.sidebar-sticky {
  position: sticky;
  top: 58px;
  max-height: calc(100vh - 58px);
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar-sticky::-webkit-scrollbar { display: none; }

.side-item {
  width: 100%;
  border: none;
  background-color: transparent;
  border-bottom: 1px solid var(--border-light);
  padding: 14px 4px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  color: var(--text-muted);
  text-align: center;
  transition: all 0.15s ease;
  position: relative;
}

.side-icon-box {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.side-icon-box svg { width: 24px; height: 24px; }
.side-icon { width: 24px; height: 24px; object-fit: contain; }

.side-text {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.3;
}

.desktop-side-arrow {
  display: none; /* فقط در دسکتاپ ظاهر می‌شود */
}

/* حالت انتخاب‌شده سایدبار */
.side-item.active {
  background-color: var(--bg-sidebar-active);
  color: var(--primary-color);
  font-weight: 700;
}
.side-item.active .side-icon-box svg {
  stroke: var(--primary-color);
}

/* ================= پنل محتوا (پیش‌فرض موبایل) ================= */
.content-panel {
  flex: 1;
  min-width: 0;
  background: #ffffff;
}

.cat-content-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cat-group-title {
  display: none; /* در موبایل پنهان است تا مینیمال باشد */
}

.all-products-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--link-color);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
}
.all-products-link svg { width: 16px; height: 16px; stroke: var(--link-color); }

/* ================= لیست آکاردئونی در موبایل ================= */
.accordion-list {
  display: flex;
  flex-direction: column;
}

.cat-accordion-item {
  border-bottom: 1px solid var(--border-light);
}

.cat-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: right;
}

.cat-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.chev {
  width: 18px;
  height: 18px;
  color: var(--text-light);
  transition: transform 0.25s ease;
  flex-shrink: 0;
}

.cat-accordion-item.open .chev {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.cat-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.25s ease;
}
.cat-accordion-item.open .cat-body {
  grid-template-rows: 1fr;
}
.cat-body-in {
  overflow: hidden;
}

/* نمایش چیپسی در موبایل */
.subcat-list {
  list-style: none;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 18px 16px;
  background-color: #fafbfc;
}

.subcat-link {
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border-dark);
  border-radius: 20px;
  padding: 6px 12px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.subcat-link.main-link {
  color: var(--link-color);
  background: #f0f9fb;
  border-color: #bfe5ee;
}


/* ==========================================================================
   ======================= استایل اختصاصی دسکتاپ (UI/UX) =======================
   ========================================================================== */
@media (min-width: 992px) {

  .app-category-wrapper {
    padding: 24px 20px 60px;
  }

  .topbar {
    display: none; /* در دسکتاپ نیاز به تاپ‌بار موبایلی نیست */
  }

  .category-main-layout {
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    min-height: 680px;
  }

  /* --- سایدبار دسکتاپ --- */
  .sidebar-panel {
    flex: 0 0 250px;
    background-color: #f7f7f9;
    border-left: 1px solid var(--border-light);
  }

  .side-item {
    flex-direction: row;
    justify-content: flex-start;
    padding: 14px 20px;
    gap: 12px;
    text-align: right;
    border-bottom: 1px solid #ececed;
  }

  .side-item:hover {
    background-color: #ededf0;
    color: var(--text-main);
  }

  .side-item.active {
    background-color: #ffffff;
    color: var(--primary-color);
    box-shadow: -3px 0 10px rgba(0, 0, 0, 0.02);
  }

  /* خط نشانگر قرمز سمت راست دسته فعال */
  .side-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--primary-color);
    border-radius: 4px 0 0 4px;
  }

  .side-text {
    font-size: 13.5px;
    font-weight: 600;
    flex: 1;
  }

  .desktop-side-arrow {
    display: block;
    width: 16px;
    height: 16px;
    color: var(--text-light);
    opacity: 0.5;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .side-item.active .desktop-side-arrow {
    opacity: 1;
    color: var(--primary-color);
  }

  /* --- محتوای اصلی دسکتاپ --- */
  .content-panel {
    padding: 24px 32px 40px;
  }

  .cat-content-header {
    padding: 0 0 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-light);
  }

  .cat-group-title {
    display: block;
    font-size: 18px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
  }

  .all-products-link {
    font-size: 14px;
    background-color: #f0f9fb;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
  }
  .all-products-link:hover {
    background-color: #e0f4f8;
  }

  /* --- چیدمان شبکه‌ای (Grid) به جای آکاردئون --- */
  .accordion-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* ۳ ستون یکدست */
    gap: 28px 24px;
  }

  .cat-accordion-item {
    border: none;
    background: transparent;
  }

  /* تبدیل هدر آکاردئون به تیتر ستون */
  .cat-head {
    padding: 0 0 10px;
    cursor: default;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 12px;
  }

  .cat-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
    position: relative;
  }

  /* خط شاخص زیر عنوان هر ستون */
  .cat-title::after {
    content: '';
    position: absolute;
    bottom: -11px;
    right: 0;
    width: 32px;
    height: 2px;
    background-color: var(--primary-color);
  }

  /* مخفی کردن آیکون فلش آکاردئون در دسکتاپ */
  .chev {
    display: none;
  }

  /* باز بودن همیشگی تمام بخش‌ها بدون نیاز به کلیک */
  .cat-body {
    display: block !important;
    grid-template-rows: unset !important;
  }

  /* تبدیل لیست چیپس‌ها به لیست عمودی شیک و تمیز */
  .subcat-list {
    background: transparent;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .subcat-item {
    margin: 0;
  }

  .subcat-link {
    display: block;
    background: transparent;
    border: none;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.15s ease;
  }

  .subcat-link:hover {
    color: var(--primary-color);
    background-color: var(--primary-soft);
    padding-right: 12px; /* افکت حرکت نرم به سمت چپ هنگام هاور */
  }

  .subcat-link.main-link {
    color: var(--link-color);
    font-weight: 600;
    background: transparent;
    border: none;
  }
  .subcat-link.main-link:hover {
    background-color: #f0f9fb;
  }
}

/* مانیتورهای بسیار بزرگ (Ultra-wide) */
@media (min-width: 1240px) {
  .accordion-list {
    grid-template-columns: repeat(4, 1fr); /* ۴ ستون در مانیتورهای عریض */
  }
}