/* =========================
   Popup
========================= */
#popupOverlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
}

#welcomePopup {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  background: white;
  padding: 20px 25px;
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  z-index: 10000;
  width: 90%;
  max-width: 400px;
  text-align: center;
  font-family: sans-serif;
}

#closePopup {
  position: absolute;
  top: 10px;
  right: 10px;
  background: #ff4d4f;
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-weight: bold;
  cursor: pointer;
}

/* =========================
   Variables
========================= */
:root {
  --primary: #1F4E78;
  --muted: #666;
  --card-bg: #fff;
  --badge-bg: #eef;
  --border: #e6eef8;
}

/* =========================
   Global
========================= */
body {
  font-family: Tahoma, Arial, Helvetica, sans-serif;
  background: #f7f9fb;
  color: #222;
  margin: 0;
  padding: 0;
  direction: rtl;
}

/* پدینگ برای دسکتاپ تا کارت‌ها زیر هدر نروند */
@media (min-width: 901px) {
  body {
    padding-top: 100px; /* مقداری بیشتر از ارتفاع هدر */
  }
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* =========================
   Header
========================= */
/* ===== HEADER (DIWAR STYLE) ===== */
.top-header{
  position: fixed; /* ثابت در بالای صفحه */
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 99999; /* روی همه چیز */
  background: #ffffff;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.08),
    0 6px 16px rgba(0,0,0,0.12);
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out; /* اضافه کردن opacity برای محو شدن */
}

/* کلاس مخفی کننده هدر */
.top-header.hidden {
  transform: translateY(-100%);
  opacity: 0; /* محو شدن کامل */
  pointer-events: none; /* غیرفعال کردن کلیک روی هدر مخفی شده */
}

.top-header::after{
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: linear-gradient(
    to left,
    rgba(0,0,0,0),
    rgba(0,0,0,0.25),
    rgba(0,0,0,0)
  );
}
.header-inner{
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px 24px;
}
/* لوگو */
.header-logo{
  flex: 0 0 auto;
}
.header-logo img{
  height: 40px;
  width: auto;
  display: block;
}
/* درصد همکاری */
.header-percent{
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 14px;
}
.header-percent input{
  width: 60px;
  height: 34px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 6px;
}
/* سرچ */
.header-search{
  flex: 1;
}
.header-search input{
  width: 100%;
  max-width: 420px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #f5f5f5;
}
/* تماس */
.header-actions{
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  font-size: 14px;
}
.header-actions a{
  text-decoration: none;
  color: #333;
}

/* ===== MOBILE ===== */
@media (max-width: 900px){
  /* پدینگ برای موبایل */
  body {
    padding-top: 80px; 
  }
  
  .header-inner{
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
  }
  
  .header-logo img {
    height: 35px;
  }
  .header-search{
    width: 100%;
    order: 3;
  }
  .header-search input{
    max-width: none;
    height: 36px;
  }
  
  .header-percent {
    display: none; 
  }
}
/* =========================
   Global
========================= */
body {
  font-family: Tahoma, Arial, Helvetica, sans-serif;
  background: #f7f9fb;
  color: #222;
  margin: 0;
  padding: 0;
  direction: rtl;
}

/* پدینگ برای دسکتاپ تا کارت‌ها زیر هدر نروند */
@media (min-width: 901px) {
  body {
    padding-top: 100px; /* مقداری بیشتر از ارتفاع هدر */
  }
}

.container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* =========================
   Header
========================= */
/* ===== HEADER (DIWAR STYLE) ===== */
.top-header{
  position: fixed; /* ثابت در بالای صفحه */
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 99999; /* روی همه چیز */
  background: #ffffff;
  box-shadow:
    0 1px 0 rgba(0,0,0,0.08),
    0 6px 16px rgba(0,0,0,0.12);
  transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

/* کلاس مخفی کننده هدر */
.top-header.hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.top-header::after{
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: linear-gradient(
    to left,
    rgba(0,0,0,0),
    rgba(0,0,0,0.25),
    rgba(0,0,0,0)
  );
}
.header-inner{
  max-width: 1360px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 16px 24px;
}
/* لوگو */
.header-logo{
  flex: 0 0 auto;
}
.header-logo img{
  height: 40px;
  width: auto;
  display: block;
}
/* درصد همکاری */
.header-percent{
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 14px;
}
.header-percent input{
  width: 60px;
  height: 34px;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 6px;
}
/* سرچ */
.header-search{
  flex: 1;
}
.header-search input{
  width: 100%;
  max-width: 420px;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #ccc;
  background: #f5f5f5;
}
/* تماس */
.header-actions{
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  font-size: 14px;
}
.header-actions a{
  text-decoration: none;
  color: #333;
}

/* ===== MOBILE ===== */
@media (max-width: 900px){
  body {
    padding-top: 80px; 
  }
  
  .header-inner{
    flex-wrap: nowrap; /* جلوگیری از شکستن خط */
    gap: 10px;
    padding: 10px 16px;
    justify-content: center; /* وسط چین کردن المان‌ها */
  }
  
  /* مخفی کردن لوگو در موبایل */
  .header-logo {
    display: none;
  }
  
  /* مخفی کردن دکمه‌های تماس در موبایل */
  .header-actions {
    display: none;
  }

  /* نمایش درصد همکاری در موبایل */
  .header-percent {
    display: flex; /* مطمئن شویم نمایش داده می‌شود */
    order: 1; /* قرار دادن در اولویت اول */
  }

  .header-search{
    width: 100%;
    order: 2; /* قرار دادن در اولویت دوم */
    max-width: 300px; /* محدود کردن عرض جستجو */
  }
  .header-search input{
    max-width: none;
    height: 36px;
  }
}
/* =========================
   Grid & Cards
========================= */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  flex-direction: column;
}

.thumb {
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  position: relative;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.info {
  flex: 1;
  min-width: 0;
  margin-top: 8px;
}

.name {
  font-weight: 700;
  margin-bottom: 6px;
  display: block;
  word-break: break-word;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.badge {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 999px;
  background: #f1f6ff;
  color: var(--primary);
  border: 1px solid #e0ecff;
}

.meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.price-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.consumer {
  font-size: 14px;
  color: black;
  font-weight: 700;
}

.coop {
  font-size: 14px;
  color: red;
  font-weight: 700;
}

.more-btn {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 10px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
}

.footer-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.special-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #ff4d4f;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
}

/* Out of stock */
.out-of-stock {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  border: 2px solid #ff4d4f;
  color: #ff4d4f;
  font-weight: 700;
  font-size: 20px;
  padding: 6px 12px;
  text-align: center;
  background: rgba(255,255,255,0.3);
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(255,0,0,0.5);
  border-radius: 4px;
}

/* =========================
   Layout / Sidebar / Main
========================= */

.layout {
  display: flex;
  gap: 16px;
}

/* سایدبار sticky */
.sidebar {
  position: sticky;
  top: 130px; /* فاصله از بالای هدر */
  width: 260px; /* همان پهنای قبلی */
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  height: fit-content; /* ارتفاع خودکار */
}

/* لیست گروه‌ها داخل سایدبار */
#groupCheckboxes {
  display: flex;
  flex-direction: column; /* هر label روی یک خط جدا */
}

.sidebar label {
  display: flex;         /* چک‌باکس و متن کنار هم */
  flex-direction: row;   /* افقی بودن محتوا */
  align-items: center;   /* وسط چین عمودی */
  gap: 8px;              /* فاصله بین چک‌باکس و متن */
  font-size: 14px;
  margin-bottom: 12px;   /* فاصله بین ردیف‌ها */
  cursor: pointer;
}

/* main-content فاصله از سایدبار */
.main-content {
  flex: 1;
}

@media (max-width: 768px) {
  .header-logo { order: 1; }
}

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .banner { height: 120px; }
  .header { padding: 8px 0; }
  .controls { flex-direction: column; align-items: flex-start; }
}
<style>
/* کانتینر منو */
#groupCheckboxes {
  margin-bottom: 20px;
  padding: 10px;
  border-radius: 8px;
  background-color: #f9f9f9;
  width: fit-content;
  font-family: 'Vazir', cursive; /* فونت دست‌نویس یا دلخواه */
}

/* عنوان منو */
#groupCheckboxes h3 {
  margin: 0 0 15px 0;
  font-size: 20px;
  font-weight: bold;
  font-family: 'Cursive', sans-serif;
}

/* دکمه‌های گروه اصلی */
.group-main-btn {
  display: block;
  margin: 10px 0;
  padding: 10px 15px;
  border: none;
  background-color: transparent;
  font-size: 18px;
  font-family: 'Cursive', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: right;
}

/* هاور دکمه */
.group-main-btn:hover {
  font-weight: bold;
  color: #d32f2f;
}

/* زیرگروه‌ها (چک‌باکس‌ها) */
#groupCheckboxes label {
  display: block;
  margin: 15px 0;
  font-size: 18px;
  font-family: 'Cursive', sans-serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* زمانی که موس روی متن می‌رود */
#groupCheckboxes label:hover {
  font-weight: bold;
  color: #d32f2f;
}

/* چک‌باکس خود را کمی بزرگتر */
#groupCheckboxes input[type="checkbox"] {
  transform: scale(1.3);
  margin-right: 10px;
}

/* دکمه بازگشت */
#groupCheckboxes button {
  margin: 15px 0;
  padding: 8px 12px;
  border: none;
  background-color: #e0e0e0;
  border-radius: 5px;
  cursor: pointer;
  font-family: 'Cursive', sans-serif;
  font-size: 16px;
  transition: all 0.2s ease;
}

#groupCheckboxes button:hover {
  background-color: #d32f2f;
  color: #fff;
  font-weight: bold;
}
</style>
/* زیرمنو داهوا */
.sub-group-item {
  margin-right: 1cm;       /* جلو آمدن به چپ */
  cursor: pointer;
  font-size: 17px;
  padding: 6px 0;
  transition: all 0.2s ease;
}

.sub-group-item:hover {
  font-weight: bold;
  color: #000;
}

/* خط جداکننده */
.sub-divider {
  border-bottom: 1px solid #ddd;
  margin: 8px 0 12px;
}

/* درصد همکاری */
.coop-percent {
  font-size: 14px;
  color: #b30000;
  margin-top: 8px;
  font-weight: bold;
}

<button id="mobileFilterBtn" class="mobile-filter-btn">☰ فیلتر و دسته‌بندی</button>

<aside class="sidebar">
  <div class="sidebar-title">دسته ها</div>
  <div id="groupCheckboxes"></div>
</aside>

/ --- تنظیمات موبایل --- /
.mobile-filter-btn {
  display: none;
}

@media screen and (max-width: 900px) {
  .mobile-filter-btn {
    display: block; width: 100%; background: #1F4E78; color: #fff;
    padding: 15px; border: none; border-radius: 8px; margin-bottom: 15px;
    font-family: inherit; font-weight: bold; cursor: pointer;
  }

  .layout { display: block !important; }

  .sidebar {
    display: none; width: 100% !important; position: static !important;
    margin-bottom: 20px !important; border: 1px solid #ddd;
  }

  .sidebar.open { display: block !important; }

  .main-content { width: 100% !important; }

  .grid { grid-template-columns: 1fr !important; gap: 15px !important; }

  .header-inner { flex-direction: column; gap: 10px; }

  .header-search { width: 100%; }
}
