/* ===================================================
   استایل‌های ریسپانسیو موبایل کل سایت (Mobile Styles)
   این فایل در تمام صفحات سایت لود می‌شود و مستقل/خودکفاست
   (حتی در صفحاتی که style.css را لود نمی‌کنند کار می‌کند).
   بر اساس ساختار دسکتاپ (1024px به بالا) — موبایل زیر 1024px
=================================================== */

:root {
  --mw-bg-white: #ffffff;
  --mw-bg-darker: #f7f4f0;
  --mw-wood-brown: #af6c54;
  --mw-wood-brown-dark: #8b5a2b;
  --mw-text-color: #333333;
}

/* نوار ناوبری پایینی فقط در موبایل نمایش داده می‌شود */
.mobile-bottom-nav {
  display: none;
}

/* ناوبری بالایی موبایل (زیر هدر) فقط در موبایل نمایش داده می‌شود */
.mobile-top-nav {
  display: none;
}

/* جای‌نگهدار نوار جستجو فقط در موبایل دیده می‌شود؛
   در دسکتاپ نباید داخل چیدمان فلکس header-top قرار بگیرد */
.search-wrapper + .header-spacer {
  display: none;
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none;
  }
}

/* ===================================================
   همه تغییرات موبایل (زیر 1024 پیکسل)
=================================================== */
@media (max-width: 1023.98px) {
  /* فاصله پایین بدنه تا محتوا زیر نوار ناوبری ثابت نرود */
  body {
    padding-bottom: 64px;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* جلوگیری قطعی از اسکرول افقی در همه صفحات موبایل */
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  /* جعبه‌کشی یکسان برای همه المان‌ها (فقط موبایل).
     بدون این، هر المانِ width:100% به‌اضافه padding خودش از لبه صفحه
     بیرون می‌زند (در RTL از سمت چپ) و به لبه می‌چسبد */
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  /* =================== هدر موبایل =================== */
  .desktop-header {
    background: var(--mw-bg-white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  }

  .header-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
  }

  .logo {
    display: flex;
    justify-content: center;
  }

  .logo-image {
    width: 210px;
    max-width: 78vw;
    object-fit: contain;
    mix-blend-mode: multiply;
  }

  /* مخفی کردن اطلاعات تماس/ارسال در موبایل */
  .top-left-actions {
    display: none;
  }

  /* بخش پایینی هدر دسکتاپ (دسته‌بندی، منو، آیکون سبد) در موبایل حذف می‌شود
     چون این امکانات روی نوار ناوبری پایینی پیاده شده‌اند */
  .header-bottom {
    display: none;
  }

  /* ================= نوار جستجو + ناوبری بالایی (موبایل) ================= */
  /* نوار جستجو به همراه دکمه‌های ناوبری زیر هدر، یک واحد چسبان می‌شوند */
  .search-wrapper {
    position: relative;
    width: 100%;
    box-sizing: border-box;
  }

  /* جای‌نگهدار نوار جستجو در موبایل نمایش داده می‌شود */
  .search-wrapper + .header-spacer {
    display: block;
  }

  .search-wrapper.fixed-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--mw-bg-white);
    padding: 8px 14px 8px 14px;
    padding: 8px 14px calc(8px + env(safe-area-inset-top, 0px)) 14px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.07);
    z-index: 950;
    transition:
      transform 0.3s ease,
      box-shadow 0.3s ease;
  }

  .search-wrapper.fixed-nav.nav-hidden {
    transform: translateY(-100%);
  }

  .search-box {
    display: flex;
    align-items: center;
    width: 100%;
    border: 1px solid #e0d8d1;
    border-radius: 30px; /* بیشترین گردی نوار */
    overflow: hidden;
    padding: 4px;
    background: var(--mw-bg-white);
    box-sizing: border-box;
  }

  .search-box input {
    flex: 1;
    border: none;
    padding: 9px 16px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    background: transparent;
    min-width: 0;
  }

  .search-btn {
    background-color: var(--mw-wood-brown);
    color: #ffffff;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%; /* دکمه ذره‌بین کاملاً دایره */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    transition: background-color 0.25s ease;
  }

  .search-btn:active {
    background-color: var(--mw-wood-brown-dark);
  }

  /* ناوبری بالایی موبایل: دکمه‌های «فروشگاه، محصولات سفارشی، درباره ما، تماس با ما»
     زیر نوار جستجو قرار می‌گیرند و همراه آن چسبان می‌شوند.
     هر ۴ دکمه مساوی هستند و کل عرض صفحه را بدون اسکرول افقی پر می‌کنند */
  .mobile-top-nav {
    display: flex;
    align-items: stretch;
    width: 100%;
    gap: 6px;
    margin-top: 10px;
    padding-bottom: 2px;
  }

  .mobile-top-nav a {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.35;
    text-decoration: none;
    color: var(--mw-wood-brown-dark);
    background: var(--mw-bg-darker);
    border: 1px solid #e7ddd3;
    border-radius: 24px;
    /* اندازه فونت و فاصله‌ها سیال: در صفحه باریک کوچک، در صفحه بزرگ بزرگ می‌شوند */
    padding: 8px clamp(4px, 1.5vw, 14px);
    font-size: clamp(10.5px, 2.7vw, 13px);
    font-weight: 600;
    font-family: inherit;
    transition:
      background-color 0.2s ease,
      color 0.2s ease;
  }

  .mobile-top-nav a.is-active {
    background: var(--mw-wood-brown);
    color: #fff;
    border-color: var(--mw-wood-brown);
  }

  .mobile-top-nav a:active {
    background: var(--mw-wood-brown);
    color: #fff;
  }

  /* ================= نوار ناوبری پایینی موبایل ================= */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    background: var(--mw-bg-white);
    border-top: 1px solid #ece5de;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.08);
    z-index: 900;
    padding-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 9px 4px;
    background: none;
    border: none;
    color: #666;
    text-decoration: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
  }

  .mobile-nav-item i {
    font-size: 20px;
    line-height: 1;
  }

  .mobile-nav-item:active {
    color: var(--mw-wood-brown);
  }

  .mobile-nav-item.is-active {
    color: var(--mw-wood-brown);
  }

  .mobile-nav-badge {
    position: absolute;
    top: 4px;
    left: calc(50% - 14px);
    background-color: var(--mw-wood-brown);
    color: #fff;
    font-size: 10px;
    width: 17px;
    height: 17px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 700;
  }
/* ================= سایدبار دسته‌بندی (کشوی موبایل) ================= */
  .sidebar-fixed {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 0;
    height: 100vh;
    background: var(--mw-bg-white);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: none;
    transition:
      width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
      box-shadow 0.35s ease;
  }

  .sidebar-fixed.open {
    width: min(300px, 86vw);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.15);
  }

  .sidebar-toggle-btn {
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    cursor: pointer;
    color: var(--mw-wood-brown);
    font-size: 18px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
  }

  .sidebar-toggle-btn::after {
    content: "دسته‌بندی محصولات";
    font-size: 14px;
    font-weight: 700;
    color: var(--mw-text-color);
    margin-right: 10px;
  }

  .sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .sidebar-menu > li {
    border-bottom: 1px solid #f5f2ee;
  }

  .sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 12px 18px;
    text-decoration: none;
    color: var(--mw-text-color);
    font-size: 14px;
    font-weight: 500;
  }

  .sidebar-menu li a:active {
    background-color: var(--mw-bg-darker);
    color: var(--mw-wood-brown);
  }

  .menu-icon {
    min-width: 22px;
    text-align: center;
    color: var(--mw-wood-brown);
    font-size: 16px;
  }

  .menu-text {
    flex: 1;
  }

  /* زیردسته‌ها در موبایل با کلیک روی دسته باز می‌شوند (تک‌تک و مستقل) */
  .has-submenu > a > .submenu-arrow {
    margin-right: auto;
    font-size: 11px;
    color: #999;
    transition: transform 0.25s ease;
  }

  .has-submenu.open > a > .submenu-arrow {
    transform: rotate(180deg);
  }

  .submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #faf7f4;
    position: static;
    width: 100%;
    border-right: none;
    border-radius: 0;
    box-shadow: none;
    display: none;
  }

  .has-submenu.open > .submenu {
    display: block;
  }

  .submenu li a {
    min-height: 42px;
    padding: 10px 30px;
    font-size: 13px;
    color: #555;
    border-top: 1px solid #f2eeea;
  }
/* ================= صفحه فروشگاه (index) ================= */
  .shop-main-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 18px 16px;
    background-color: var(--mw-bg-darker);
    min-height: 80vh;
  }

  .filters-sidebar {
    width: 100%;
    background: var(--mw-bg-white);
    padding: 20px 18px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  }

  .filter-title {
    font-size: 15px;
    color: var(--mw-wood-brown-dark);
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .filter-group {
    margin-bottom: 16px;
    border-bottom: 1px solid #f2ece6;
    padding-bottom: 14px;
  }

  .filter-group label {
    font-size: 13px;
    color: #555;
    display: block;
    margin-bottom: 10px;
  }

  .filter-group input[type="range"] {
    width: 100%;
    accent-color: var(--mw-wood-brown);
  }

  .price-labels {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
  }

  /* نوار قیمت دوگانه: مثل دسکتاپ دو اسلایدر روی هم قرار می‌گیرند
     تا ظاهر یک اسلایدر دونده را بسازند */
  .dual-range-container {
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
  }

  .dual-range-container input[type="range"] {
    position: absolute;
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: #e5ddd4;
    outline: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
  }

  .dual-range-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5c2c16;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  }

  .dual-range-container input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: #5c2c16;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  }

  .dual-range-container #maxPriceRange {
    background: transparent !important;
  }

  .filter-dropdown-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    padding: 4px 0;
  }

  .filter-dropdown-toggle i {
    transition: transform 0.25s ease;
    color: #888;
  }

  .filter-dropdown-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
    display: none;
  }

  .filter-dropdown-list.show {
    display: block;
  }

  .filter-dropdown-list li {
    margin-bottom: 10px;
    font-size: 13px;
    color: #666;
  }

  .filter-dropdown-list input {
    margin-left: 8px;
    accent-color: var(--mw-wood-brown);
  }

  .shop-content {
    min-width: 0;
  }

  .sorting-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: var(--mw-bg-white);
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    font-size: 12px;
    color: #555;
  }

  .sort-select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    color: #333;
    max-width: 55%;
  }

  /* گرید محصولات: ۲ ستونه در موبایل */
  .products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .product-card {
    background: var(--mw-bg-white);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
  }

  .product-image-container {
    position: relative;
    width: 92%;
    margin: 8px auto 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
  }

  .product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .product-image-container img.secondary-img {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
  }

  .product-info {
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    text-align: center;
    gap: 6px;
  }

  .product-title {
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    min-height: 39px; /* دو خط */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin: 0;
  }

  .product-price {
    font-size: 13px;
    color: var(--mw-wood-brown-dark);
    font-weight: 700;
  }

  .add-to-cart-btn {
    margin-top: auto;
    width: 100%;
    background-color: var(--mw-wood-brown);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 10px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
  }

  .add-to-cart-btn.is-success {
    background-color: #27ae60;
  }

  .no-products-msg,
  .end-of-products-msg {
    grid-column: 1 / -1;
    text-align: center;
    padding: 30px;
    color: #777;
    font-size: 13px;
  }

  .loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px 0;
    color: #777;
    font-size: 13px;
    /* مخفی در حالت عادی اما همچنان در چیدمان صفحه (مثل دسکتاپ)
       تا IntersectionObserver اسکرول بینهایت در موبایل هم فعال بماند
       و محصولات بعد از صفحه اول هم لود شوند */
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  .loading-indicator.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 1;
  }

  .loading-indicator .spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0d6cc;
    border-top-color: var(--mw-wood-brown);
    border-radius: 50%;
    animation: mobile-spin 0.8s linear infinite;
  }

  @keyframes mobile-spin {
    to {
      transform: rotate(360deg);
    }
  }
/* ================= کشوی سبد خرید (موبایل) ================= */
  .cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.35);
    display: none;
    z-index: 999;
  }

  .cart-overlay.active {
    display: block;
  }

  .cart-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(360px, 88vw);
    /* ارتفاع دقیقاً برابر ناحیه قابل مشاهده؛ dvh در مرورگرهای موبایل
       جلوی بیرون زدن کشو از پایین صفحه (اسکرول عمودی) را می‌گیرد */
    height: 100vh;
    height: 100dvh;
    background: #fff;
    border-radius: 0 14px 14px 0;
    box-shadow: 5px 0 25px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
    opacity: 0;
    transform: translateX(-105%);
    visibility: hidden;
    transition:
      transform 0.35s ease,
      opacity 0.35s ease,
      visibility 0.35s ease;
  }

  .cart-drawer.active {
    opacity: 1;
    transform: translateX(0);
    visibility: visible;
  }

  .cart-drawer-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f1f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
  }

  .cart-drawer-header h3 {
    font-size: 1rem;
    color: #2c3e50;
    margin: 0;
  }

  .close-btn {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: #7f8c8d;
    padding: 2px 6px;
  }

  .cart-items-container {
    flex: 1;
    min-height: 0; /* در فلکس ستونی اجازه می‌دهد لیست کوچک شود و فقط خودش اسکرول بخورد */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; /* اسکرول لیست به صفحه پشت سرش منتقل نمی‌شود */
    padding: 16px 20px;
  }

  .cart-item-card {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid #f5f2ee;
  }

  .cart-item-img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .cart-item-details {
    flex: 1;
    min-width: 0;
  }

  .cart-item-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #333;
  }

  .cart-item-price {
    font-size: 0.8rem;
    color: #e67e22;
    margin-top: 4px;
  }

  .cart-item-controls {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .qty-btn {
    background: #f1f2f6;
    border: none;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
    color: #333;
  }

  .qty-display {
    font-size: 0.8rem;
    min-width: 16px;
    text-align: center;
  }

  .trash-btn {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
  }

  .cart-drawer-footer {
    padding: 16px 20px 16px 20px;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)) 20px;
    border-top: 1px solid #f1f1f1;
    background: #faf8f5;
    flex-shrink: 0;
  }

  .cart-total-section {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 12px;
  }

  .cart-drawer-buttons {
    display: flex;
    gap: 8px;
  }

  .cart-drawer-buttons button {
    flex: 1;
    padding: 11px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.85rem;
  }

  .btn-primary {
    background: #2c3e50;
    color: #fff;
    border: none;
  }

  .btn-secondary {
    background: transparent;
    color: #2c3e50;
    border: 1px solid #2c3e50;
  }

  /* ================= دکمه بازگشت به بالا (موبایل) ================= */
  .scroll-to-top {
    position: fixed;
    bottom: 80px;
    left: 14px;
    width: 42px;
    height: 42px;
    background-color: var(--mw-wood-brown);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 16px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 800;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
  }

  .scroll-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* ================= صفحه سبد خرید (موبایل) ================= */
  .cart-page-main {
    padding: 20px 14px 30px 14px;
    padding: 20px 14px calc(30px + env(safe-area-inset-bottom, 0px)) 14px;
  }

  .cart-container {
    padding: 20px 14px;
  }

  .cart-header-actions {
    align-items: flex-start;
  }

  /* کارت هر محصول در صفحه سبد خرید (cart.html):
     ردیف اول = تصویر + نام و قیمت واحد
     ردیف دوم = کنترل تعداد + قیمت کل + دکمه حذف
     (قواعد عمومی .cart-item-card بالا برای کشوی سبد هستند و نباید
      نام محصول را در این صفحه تا چند پیکسل فشرده کنند) */
  .cart-items-list .cart-item-card {
    flex-wrap: wrap;
    padding: 14px;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 10px;
    margin-bottom: 0;
    border-bottom: 1px solid #eaeaea;
  }

  .cart-items-list .cart-item-details {
    flex: 1 1 auto;
    min-width: 150px; /* حداقل عرض نام محصول؛ جلوی عمودی شدن کلمات را می‌گیرد */
  }

  /* در صفحه‌های خیلی باریک، قیمت کل کمی جمع‌تر می‌شود تا ردیف دوم جا شود */
  @media (max-width: 360px) {
    .cart-items-list .cart-item-total-price {
      min-width: 90px;
    }
  }

/* ================= صفحه تسویه حساب (موبایل) ================= */
  .checkout-header {
    background: #fff;
    border-bottom: 1px solid #e2d8ce;
    padding: 16px 0;
    margin-bottom: 20px;
  }

  .checkout-header .container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
  }

  .checkout-logo {
    color: #fff;
    font-size: 15px;
    text-decoration: none;
    background-color: var(--mw-wood-brown);
    padding: 10px 16px;
    border-radius: 10px;
    display: inline-block;
  }

  .checkout-logo:active {
    background-color: #a74230;
  }

  .checkout-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: #888888;
  }

  .checkout-steps .step.active {
    color: #8b5a2b;
    font-weight: 700;
  }

  .step {
    text-decoration: none;
    color: #8b5a2b;
  }

  .checkout-page-main {
    background-color: #faf8f5;
    padding-bottom: 45px;
  }

  .checkout-container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 14px;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .checkout-form-column {
    background: #ffffff;
    border: 1px solid #e8e0d8;
    border-radius: 12px;
    padding: 22px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  }

  .checkout-form-column h2 {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 22px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid #f2ece6;
  }

  .form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 22px;
  }

  .form-group.full-width {
    grid-column: auto;
  }

  .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .form-group label {
    font-size: 14px;
    font-weight: 600;
    color: #333333;
  }

  .form-group .required {
    color: #d9534f;
  }

  .form-control {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #d6d6d6;
    border-radius: 8px;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
  }

  .form-control:focus {
    border-color: #8b5a2b;
    box-shadow: 0 0 0 3px rgba(139, 90, 43, 0.12);
  }

  .payment-method-box {
    background-color: #fdfbf8;
    border: 1px solid #e8e0d8;
    border-radius: 10px;
    padding: 18px 16px;
    margin-bottom: 22px;
  }

  .payment-method-box h3 {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 12px;
  }

  .payment-option {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
  }

  .payment-text strong {
    display: block;
    font-size: 14px;
    color: #333;
  }

  .payment-text small {
    display: block;
    font-size: 12px;
    color: #777;
    margin-top: 2px;
  }

  .checkout-summary-column {
    position: static;
  }

  .summary-card {
    background: #ffffff;
    border: 1px solid #e8e0d8;
    border-radius: 12px;
    padding: 22px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
  }

  .summary-card h3 {
    font-size: 17px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 18px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
  }

  .checkout-items-preview {
    max-height: 240px;
    overflow-y: auto;
    margin-bottom: 15px;
  }

  .preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #555;
    margin-bottom: 12px;
  }

  .preview-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .summary-divider {
    height: 1px;
    background-color: #eee;
    margin: 15px 0;
  }

  .summary-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
  }

  .summary-row.total-row {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed #ccc;
    font-size: 16px;
    font-weight: 700;
    color: #8b5a2b;
  }

  .btn-submit-order {
    width: 100%;
    height: 52px;
    background-color: #27ae60;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s ease;
  }

  .btn-submit-order:active {
    background-color: #219653;
  }

  /* ================= دکمه فیلتر موبایل ================= */
  .mobile-filter-btn {
    display: none; /* پیش‌فرض: در دسکتاپ مخفی */
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--mw-bg-white);
    border: 1.5px solid var(--mw-wood-brown);
    border-radius: 8px;
    color: var(--mw-wood-brown);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
  }

  .mobile-filter-btn:active {
    background: var(--mw-wood-brown);
    color: #fff;
  }

  /* نمایش دکمه فیلتر در موبایل و پنهان کردن سایدبار فیلترها */
  .mobile-filter-btn {
    display: flex;
  }

  .filters-sidebar {
    display: none; /* در موبایل سایدبار فیلترها مخفی است */
  }

  /* ================= کشوی فیلتر موبایل ================= */
  .filter-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .filter-drawer-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  .filter-drawer {
    background: #fff;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
  }

  .filter-drawer-overlay.open .filter-drawer {
    transform: translateY(0);
  }

  .filter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
  }

  .filter-drawer-header h3 {
    font-size: 16px;
    color: var(--mw-wood-brown-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .filter-drawer-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f5f2ee;
    color: #666;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
  }

  .filter-drawer-close:active {
    background: #e8e0d8;
  }

  .filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
  }

  .filter-drawer-body .filter-group {
    margin-bottom: 18px;
    border-bottom: 1px solid #f2ece6;
    padding-bottom: 16px;
  }

  .filter-drawer-body .filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
  }

  .filter-drawer-body .filter-group label {
    font-size: 13px;
    color: #555;
    display: block;
    margin-bottom: 10px;
  }

  .filter-drawer-body .filter-group input[type="range"] {
    width: 100%;
    accent-color: var(--mw-wood-brown);
  }

  .filter-drawer-body .price-labels {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
  }

  .filter-drawer-body .dual-range-container {
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
  }

  .filter-drawer-body .dual-range-container input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    -webkit-appearance: none;
    background: transparent;
  }

  .filter-drawer-body .dual-range-container input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--mw-wood-brown);
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  }

  .filter-drawer-body .filter-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--mw-text-color);
  }

  .filter-drawer-body .filter-dropdown-toggle i {
    transition: transform 0.2s ease;
    font-size: 12px;
    color: #999;
  }

  .filter-drawer-body .filter-dropdown-toggle.open i {
    transform: rotate(180deg);
  }

  .filter-drawer-body .filter-dropdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
  }

  .filter-drawer-body .filter-dropdown-list.open {
    display: block;
  }

  /* هماهنگ با toggleFilterDropdown سایدبار که کلاس show را تاگل می‌کند */
  .filter-drawer-body .filter-dropdown-list.show {
    display: block;
  }

  .filter-drawer-body .filter-dropdown-list li {
    margin-bottom: 10px;
  }

  .filter-drawer-body .filter-dropdown-list label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
  }

  .filter-drawer-body .filter-dropdown-list input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--mw-wood-brown);
    cursor: pointer;
  }

  .filter-drawer-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
  }

  .btn-apply-filter {
    flex: 1;
    padding: 14px 20px;
    background: var(--mw-wood-brown);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease;
  }

  .btn-apply-filter:active {
    background: var(--mw-wood-brown-dark);
  }

  .btn-reset-filter {
    padding: 14px 20px;
    background: transparent;
    color: #666;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .btn-reset-filter:active {
    border-color: #999;
    color: #333;
  }

  /* گوشی‌های خیلی کوچک (≤480px): هدر، جستجو، ناوبری، فروشگاه و کارت‌ها */
  .header-top {
    padding: 10px 10px;
    gap: 8px;
  }

  .logo-image {
    width: 160px;
    max-width: 68vw;
  }

  .search-wrapper.fixed-nav {
    padding: 6px 10px 6px 10px;
    padding: 6px 10px calc(6px + env(safe-area-inset-top, 0px)) 10px;
  }

  .search-box {
    padding: 3px;
  }

  .search-box input {
    padding: 8px 10px;
    font-size: 12px;
  }

  .search-btn {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .search-results-panel {
    max-height: 55vh;
    font-size: 12px;
  }

  .mobile-top-nav {
    gap: 4px;
    margin-top: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .mobile-top-nav::-webkit-scrollbar {
    display: none;
  }

  .mobile-top-nav a {
    flex: 1 0 auto;
    min-width: 72px;
    padding: 7px 8px;
    font-size: 10.5px;
    border-radius: 18px;
    white-space: nowrap;
  }

  .shop-main-container {
    gap: 12px;
    padding: 12px 10px;
  }

  .sorting-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    font-size: 11px;
  }

  .sort-select {
    padding: 7px 8px;
    font-size: 11px;
    max-width: 100%;
    flex: 1 1 130px;
    min-width: 0;
  }

  .mobile-filter-btn {
    padding: 7px 10px;
    font-size: 11px;
  }

  .products-grid {
    gap: 8px;
  }

  .product-card {
    border-radius: 8px;
  }

  .product-image-container {
    width: 94%;
    margin-top: 6px;
    border-radius: 6px;
  }

  .product-info {
    padding: 8px 6px;
    gap: 4px;
  }

  .product-title {
    font-size: 11px;
    line-height: 1.45;
    min-height: 32px;
  }

  .product-price {
    font-size: 11px;
  }

  .product-rating {
    font-size: 10px;
  }

  .add-to-cart-btn {
    padding: 8px 4px;
    font-size: 10.5px;
    gap: 5px;
    border-radius: 7px;
  }

  .no-products-msg,
  .end-of-products-msg {
    padding: 20px 10px;
    font-size: 11.5px;
  }

  /* کشوی فیلتر در صفحه خیلی باریک */
  .filter-drawer {
    max-width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }

  .filter-drawer-header {
    padding: 14px 14px;
  }

  .filter-drawer-header h3 {
    font-size: 14px;
  }

  .filter-drawer-close {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .filter-drawer-body {
    padding: 16px 14px;
  }

  .filter-drawer-footer {
    padding: 12px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .btn-apply-filter,
  .btn-reset-filter {
    padding: 12px 10px;
    font-size: 12.5px;
    border-radius: 8px;
  }

  /* کشوی سبد خرید */
  .cart-drawer {
    width: min(360px, 94vw);
  }

  .cart-items-container {
    padding: 12px 14px;
  }

  .cart-item-card {
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
  }

  .cart-item-img {
    width: 42px;
    height: 42px;
  }

  .cart-item-title {
    font-size: 0.78rem;
  }

  .cart-item-price {
    font-size: 0.72rem;
  }
}

/* ===================================================
   گوشی‌های خیلی باریک (حداکثر 340px: آیفون SE قدیمی،
   حالت بسته تاشوها و...)
   گرید تک‌ستونه + کارت افقی + فشرده‌سازی کلی
=================================================== */
@media (max-width: 340px) {
  /* ایمنی عمومی در برابر سرریز */
  img {
    max-width: 100%;
    height: auto;
  }

  input,
  select,
  textarea {
    max-width: 100%;
  }

  /* هدر فشرده‌تر */
  .header-top {
    padding: 10px 10px;
    gap: 10px;
  }

  .logo-image {
    width: 170px;
  }

  .search-wrapper.fixed-nav {
    padding: 8px 10px calc(8px + env(safe-area-inset-top, 0px)) 10px;
  }

  .search-box input {
    padding: 7px 8px;
    font-size: 12px;
  }

  .search-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  /* ناوبری بالایی موبایل */
  .mobile-top-nav {
    gap: 4px;
    margin-top: 6px;
  }

  .mobile-top-nav a {
    min-width: 60px;
    padding: 6px 6px;
    font-size: 10px;
    border-radius: 16px;
  }

  /* نوار پایینی موبایل */
  .mobile-bottom-nav a {
    padding: 6px 2px;
    font-size: 9px;
    gap: 2px;
  }

  .mobile-bottom-nav i {
    font-size: 16px;
  }

  /* بدنه فروشگاه */
  .shop-main-container {
    padding: 10px 8px;
    gap: 10px;
  }

  /* نوار مرتب‌سازی عمودی و تمام‌عرض */
  .sorting-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    font-size: 11px;
  }

  .sort-select {
    flex: none;
    width: 100%;
    font-size: 11px;
  }

  .mobile-filter-btn {
    width: 100%;
    justify-content: center;
    padding: 8px;
    font-size: 11px;
  }

  /* گرید تک‌ستونه */
  .products-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* کارت افقی: عکس کنار اطلاعات */
  .product-card {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px;
  }

  .product-image-container {
    width: 96px;
    min-width: 96px;
    margin-top: 0;
  }

  .product-info {
    flex: 1;
    min-width: 0;
    padding: 4px 2px;
    gap: 5px;
  }

  .product-title {
    font-size: 12px;
    min-height: 0;
  }

  .product-price {
    font-size: 11.5px;
  }

  .product-rating {
    font-size: 10px;
  }

  .add-to-cart-btn {
    font-size: 11px;
    padding: 7px 6px;
  }

  .loading-indicator {
    padding: 14px 8px;
    font-size: 11px;
  }

  /* کشوی فیلتر تمام‌عرض */
  .filter-drawer {
    width: 100vw;
    max-width: 100vw;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 14px 14px 0 0;
  }

  .filter-drawer-body {
    padding: 14px 12px;
  }

  .filter-drawer-footer {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .btn-apply-filter,
  .btn-reset-filter {
    font-size: 12px;
    padding: 11px 8px;
  }

  /* کشوی سبد خرید تمام‌عرض */
  .cart-drawer {
    width: 100vw;
    max-width: 100vw;
  }

  /* مودال‌ها */
  .ua-modal {
    width: calc(100vw - 24px);
    padding: 20px 14px;
    margin: 12px auto;
  }

  .ua-title {
    font-size: 15px;
  }

  .product-modal-content {
    width: calc(100vw - 20px);
    padding: 16px 12px;
    margin: 10px auto;
  }

  .product-modal-image {
    max-height: 220px;
  }

  .product-modal-title {
    font-size: 15px;
  }

  .product-modal-price {
    font-size: 14px;
  }

  /* پروفایل */
  .profile-wrap {
    margin: 0;
    border-radius: 10px;
  }

  .profile-header {
    padding: 14px;
  }

  .profile-avatar {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }

  .profile-name {
    font-size: 15px;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    font-size: 15px;
  }

  /* تسویه‌حساب و سبد */
  .checkout-container {
    padding: 0 8px;
  }

  .checkout-form-column,
  .checkout-summary-column .summary-card {
    padding: 14px 12px;
  }

  .form-control {
    font-size: 12px;
    padding: 9px 10px;
  }

  .cart-container {
    padding: 0 8px;
  }

  .cart-table th,
  .cart-table td {
    padding: 8px 6px;
    font-size: 11px;
  }

  .cart-product-thumb {
    width: 44px;
    height: 44px;
  }

  /* فوتر */
  .site-footer {
    padding: 24px 12px calc(80px + env(safe-area-inset-bottom, 0px));
  }

  .footer-grid {
    gap: 16px;
  }

  /* دکمه بازگشت به بالا */
  .scroll-to-top {
    width: 38px;
    height: 38px;
    left: 10px;
    bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    font-size: 14px;
  }
}