:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: 'Vazirmatn', sans-serif; background-color: var(--bg-color); color: var(--text-main); overflow-x: hidden; font-size: clamp(0.875rem, 4vw, 1rem); line-height: 1.6; }
.mobile-only { display: none; }

/* حذف outline آبی پیش‌فرض مرورگر از همه input ها و استایل focus یکپارچه */
input:focus, select:focus, textarea:focus, button:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15) !important;
    border-color: var(--primary) !important;
}
/* search-bar input: بدون border-box، فقط تغییر رنگ subtly */
.search-bar input:focus { box-shadow: none !important; }
.search-bar:focus-within {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
}
/* sort-select: همان استایل search-bar */
.sort-select:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important; }
/* checkbox ها: بدون box-shadow */
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none !important; }
/* دکمه‌های inside grid که نباید outline بگیرند */
.list-qty-btn:focus, .row-add-btn:focus, .view-btn:focus, .btn-primary:focus, .btn-outline:focus {
    box-shadow: none !important;
}

/* Header - Two-row layout (top: logo+search+login / bottom: mega menu) */
.store-header {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--surface);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Row 1: logo + search + login */
.store-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 40px;
    gap: 20px;
}
.header-right, .header-left { display: flex; align-items: center; gap: 20px; }
.header-center { flex: 0 1 auto; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: bold; font-size: 1.2rem; }
.search-bar { display: flex; align-items: center; background: var(--bg-color); border-radius: 8px; padding: 5px 15px; border: 1px solid var(--border); position: relative; }
.search-bar input { border: none; background: transparent; padding: 8px; width: 250px; min-width: 0; flex: 1; font-family: inherit; }
.search-bar button { background: none; border: none; color: var(--text-muted); cursor: pointer; }

/* ===== Category Search Dropdown (Autocomplete) ===== */
.category-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
    z-index: 1100;
    max-height: 360px;
    overflow-y: auto;
    padding: 6px;
    animation: cat-dropdown-fade 0.15s ease;
}
@keyframes cat-dropdown-fade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.cat-search-item {
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    transition: background 0.15s ease;
    border-bottom: 1px solid #f1f5f9;
}
.cat-search-item:last-child { border-bottom: none; }
.cat-search-item:hover,
.cat-search-item.selected {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}
.cat-search-item.selected {
    box-shadow: inset 3px 0 0 var(--primary);
}
.cat-search-path {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}
.cat-search-name {
    font-size: 0.88rem;
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.4;
}
.cat-search-item.selected .cat-search-name {
    color: var(--primary);
}
.cat-search-empty {
    padding: 14px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* ===== ⚚ v99 — UX جستجو: هدر / فوتر / حالت خالی / راهنما ===== */
/* هدر dropdown: مشخص می‌کند نتایج، «دسته‌بندی» هستند */
.cat-search-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
}
.cat-search-header-icon { font-size: 0.9rem; flex-shrink: 0; }
.cat-search-header-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}
.cat-search-header-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-inline-start: auto;
    white-space: nowrap;
}

/* فوتر dropdown: دکمه «جستجوی عبارت در محصولات» — معادل کلیکیِ Enter */
.cat-search-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-top: 2px;
    border-top: 1px dashed var(--border);
    border-radius: 0 0 8px 8px;
    cursor: pointer;
    background: #fff;
    position: sticky;
    bottom: 0;
    transition: background 0.15s ease;
    user-select: none;
}
.cat-search-footer:hover { background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.cat-search-footer:hover .cat-search-footer-text { color: var(--primary); }
.cat-search-footer-icon { font-size: 0.85rem; flex-shrink: 0; }
.cat-search-footer-text {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
}

/* چیپ کلید (Enter / +) */
.cat-search-kbd {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 0.7rem;
    font-family: inherit;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.6;
}

/* حالت «دسته‌بندی یافت نشد»: عنوان + توضیح + دکمهٔ CTA */
.cat-search-empty-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.6;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.cat-search-empty-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 340px;
}
.cat-search-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    max-width: 100%;
    transition: opacity 0.15s ease, transform 0.1s ease;
}
.cat-search-cta:hover { opacity: 0.92; }
.cat-search-cta:active { transform: scale(0.98); }
.cat-search-cta-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 260px;
}
.cat-search-cta .cat-search-kbd {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

/* راهنمای استفاده از جستجو (focus با ورودی خالی) */
.search-guide { padding: 4px 2px; }
.search-guide-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.search-guide-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.76rem;
    color: var(--text-muted);
    line-height: 1.9;
    padding: 2px 10px;
}
.search-guide-row strong { color: var(--text-main); font-weight: 600; }
.search-guide-bullet { color: var(--primary); font-weight: 700; flex-shrink: 0; }
.search-guide-ltr { direction: ltr; unicode-bidi: embed; color: var(--text-main); font-weight: 600; }
.search-guide-globe, .search-guide-btn-icon { font-size: 0.85rem; }

/* موبایل: فشرده‌سازی عناصر جدید dropdown */
@media (max-width: 768px) {
    .cat-search-header-hint { display: none; }
    .cat-search-empty-hint { max-width: 100%; }
    .cat-search-cta-text { max-width: 180px; }
    .cat-search-footer-text { font-size: 0.76rem; }
    .search-guide-row { font-size: 0.72rem; line-height: 1.8; }
}

/* scrollbar استایل */
.category-search-dropdown::-webkit-scrollbar { width: 6px; }
.category-search-dropdown::-webkit-scrollbar-track { background: transparent; }
.category-search-dropdown::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.category-search-dropdown::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Row 2: mega menu (full width) */
.store-header-bottom {
    border-top: 1px solid var(--border);
    background: var(--surface);
}
.mega-menu-nav {
    width: 100%;
    padding: 0 40px;
}
.mega-menu-root {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    margin: 0;
    padding: 0;
    height: 44px;
}
.mega-menu-item {
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    border-bottom: 3px solid transparent;
    position: relative;
}
.mega-menu-item:hover {
    background: #F8FAFC;
}
.mega-menu-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 700;
}
.mega-menu-title { font-size: 0.9rem; color: var(--text-main); }
.mega-menu-item.active .mega-menu-title { color: var(--primary); }

/* Infinite scroll UI */
.infinite-scroll-sentinel {
    height: 1px;
    width: 100%;
    visibility: hidden;
}
.infinite-scroll-loading {
    text-align: center;
    padding: 20px;
}
.infinite-scroll-loading .loading-state {
    color: var(--text-muted);
    font-size: 0.85rem;
}
.infinite-scroll-end {
    text-align: center;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px dashed var(--border);
}
.infinite-scroll-end .loading-state {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Buttons */
.btn-primary { background: var(--primary); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: bold; transition: 0.2s; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border: 2px solid var(--primary); color: var(--primary); padding: 8px 16px; border-radius: 8px; text-decoration: none; font-weight: bold; }
.full-width { width: 100%; margin-top: 10px; }
.cart-btn { background: none; border: none; position: relative; cursor: pointer; color: var(--text-main); padding: 8px; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.cart-badge { position: absolute; top: -8px; right: -8px; background: var(--danger); color: white; font-size: 0.75rem; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: bold; }

/* Layout */
.store-layout { display: flex; padding: 30px 40px; gap: 30px; max-width: 1400px; margin: 0 auto; }
.filters-sidebar { width: 250px; flex-shrink: 0; background: var(--surface); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border); height: fit-content; position: sticky; top: 130px; max-height: calc(100vh - 150px); overflow-y: auto; display: flex; flex-direction: column; }
.filters-sidebar-body { flex: 1; overflow-y: auto; }
.filters-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 998; display: none; }
.filters-overlay.open { display: block; }
.filters-sidebar-header { display: none; padding: 15px 20px; border-bottom: 1px solid var(--border); justify-content: space-between; align-items: center; }
.filters-sidebar-header h3 { font-size: 1.1rem; }
.filters-sidebar-footer { display: none; padding: 15px; border-top: 1px solid var(--border); background: var(--surface); }
.open-filters-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: var(--bg-color); border: 1px solid var(--border); border-radius: 8px; color: var(--text-main); font-weight: bold; font-family: inherit; cursor: pointer; min-height: 40px; }
.brand-filters-list { display: flex; flex-direction: column; gap: 8px; font-size: 0.85rem; max-height: 250px; overflow-y: auto; }
.brand-search-wrapper { margin-bottom: 10px; }
.brand-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.brand-search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    outline: none;
}
.brand-show-more { margin-top: 8px; padding: 6px 10px; background: var(--bg-color); border: 1px dashed var(--border); border-radius: 6px; text-align: center; color: var(--primary); font-size: 0.8rem; cursor: pointer; font-weight: bold; }
.brand-filters-list .brand-checkbox-label.hidden-extra { display: none; }
.brand-filters-list.expanded .brand-checkbox-label.hidden-extra { display: flex; }
.filter-list { list-style: none; margin-top: 15px; }
.filter-list li { padding: 10px; cursor: pointer; border-radius: 8px; color: var(--text-muted); transition: 0.2s; }
.filter-list li:hover { background: var(--bg-color); }
.filter-list li.active { background: #eff6ff; color: var(--primary); font-weight: bold; }

/* === Sidebar Sub-Categories Navigation (پشتیبانی عمق نامحدود) === */
.sidebar-sub-header {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding: 4px 0;
    line-height: 1.4;
}
.sidebar-sub-header strong {
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 700;
}
.sidebar-sub-back {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 10px;
    margin-bottom: 8px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.2s;
}
.sidebar-sub-back:hover { background: #e0e7ff; color: var(--primary); }
.sidebar-sub-back .back-arrow {
    color: var(--primary);
    font-weight: bold;
    font-size: 0.95rem;
}
.sidebar-sub-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.sidebar-sub-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    transition: background 0.2s, color 0.2s;
    font-size: 0.85rem;
}
.sidebar-sub-item:hover { background: #f8fafc; color: var(--primary); }
.sidebar-sub-item.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 700;
}
.sidebar-sub-item .bullet {
    color: var(--primary);
    font-size: 0.7rem;
    flex-shrink: 0;
}
.sidebar-sub-item .name { flex: 1; line-height: 1.4; }
.sidebar-sub-item .has-children {
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
    transform: rotate(180deg); /* فلش به سمت چپ (در RTL یعنی جلو) */
}
.sidebar-sub-item:hover .has-children { color: var(--primary); }
.sidebar-sub-empty {
    padding: 12px 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    background: #f8fafc;
    border-radius: 6px;
    border: 1px dashed var(--border);
}

.products-section { flex: 1; }
.products-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 15px; flex-wrap: wrap; }
.products-header-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.products-header-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sort-select { padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border); font-family: inherit; }

/* ===== Global Search Toggle (تیک جستجو در کل سایت) ===== */
/* نسخه inline داخل باکس سرچ — آیکون کوچک سمت چپ باکس */
.global-search-inline {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    margin-right: 4px;
    margin-left: 2px;
    flex-shrink: 0;
    width: 26px;
    height: 26px;
}
.global-search-inline input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.global-search-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 14px;
    color: var(--text-muted);
    background: transparent;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}
.global-search-inline:hover .global-search-icon {
    color: var(--primary);
    background: #eff6ff;
}
/* وقتی checkbox خاموش است: آیکون کمرنگ + strikethrough */
.global-search-inline:not(:has(input:checked)) .global-search-icon {
    opacity: 0.45;
    text-decoration: line-through;
}
.global-search-inline:has(input:checked) .global-search-icon {
    color: var(--primary);
}
/* tooltip که در hover نمایش داده می‌شود */
.global-search-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    right: 50%;
    transform: translateX(50%);
    background: #1e293b;
    color: #fff;
    font-size: 0.72rem;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    z-index: 1200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
}
.global-search-tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    right: 50%;
    transform: translateX(50%);
    border: 5px solid transparent;
    border-bottom-color: #1e293b;
}
.global-search-inline:hover .global-search-tooltip {
    opacity: 1;
    visibility: visible;
}

/* موبایل: متن tooltip کوتاه‌تر */
@media (max-width: 768px) {
    .global-search-tooltip {
        font-size: 0.68rem;
        padding: 5px 8px;
        max-width: 160px;
        white-space: normal;
        text-align: center;
        line-height: 1.4;
    }
}

/* نسخه قدیمی (badge-like) — حفظ شده برای backward compat ولی استفاده نمی‌شود */
.global-search-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    white-space: nowrap;
    font-weight: 500;
}
.global-search-toggle:hover {
    background: #e0e7ff;
    border-color: var(--primary);
    color: var(--primary);
}
.global-search-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    margin: 0;
}
.global-search-toggle:has(input:checked) {
    background: #eff6ff;
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}
.global-search-toggle .toggle-label {
    line-height: 1;
}

/* Product Grid - Modern Design */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.product-card { background: #fff; border-radius: 16px; border: 1px solid #E2E8F0; padding: 0; display: flex; flex-direction: column; transition: all 0.25s ease; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.product-card:hover { transform: translateY(-6px); box-shadow: 0 12px 30px -8px rgba(0,0,0,0.15); border-color: #C7D2FE; }
.product-card-header { position: relative; background: #F8FAFC; padding: 12px; display: flex; align-items: center; justify-content: center; }
.product-img { width: 100%; height: 180px; object-fit: contain; border-radius: 10px; background: transparent; cursor: pointer; transition: transform 0.3s ease; }
.product-card:hover .product-img { transform: scale(1.05); }
.product-info-block { padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-category { font-size: 0.72rem; color: #6366F1; font-weight: 600; margin-bottom: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.product-name { font-size: 0.9rem; font-weight: 600; margin: 0; line-height: 1.5; color: #1E293B; word-break: break-word; hyphens: auto; cursor: pointer; transition: color 0.2s ease; }
.product-name:hover { color: #6366F1; }
.product-price { font-size: 1.15rem; color: #1E293B; font-weight: 700; margin: 0; }
/* Desktop grid mode - price wrapper with subtle background */
.products-view-container.grid-mode .product-price-wrapper {
    padding: 10px 14px;
    margin-top: auto;
    background: linear-gradient(135deg, #FAFBFF, #F8FAFC);
    border-top: 1px solid #F1F5F9;
    text-align: center;
}
.products-view-container.grid-mode .product-price {
    font-size: 1.2rem;
    font-weight: 800;
    color: #1E293B;
    text-align: center;
    margin: 0;
}
.products-view-container.grid-mode .product-price-original {
    text-align: center;
    font-size: 0.85rem;
    margin-bottom: 2px;
}
.products-view-container.grid-mode .grid-qty-row {
    padding: 0 14px 14px;
    gap: 10px;
    display: flex;
}
.products-view-container.grid-mode .grid-qty-row .list-qty-selector {
    flex: 1;
    height: 42px;
}
.products-view-container.grid-mode .grid-qty-row .row-add-btn {
    flex: 1;
    min-height: 42px;
}
.product-price-wrapper { padding: 0 16px 14px; margin-top: auto; }
.product-price-original { font-size: 0.8rem; color: #94A3B8; text-decoration: line-through; margin-bottom: 2px; }
.product-stock { font-size: 0.78rem; color: #059669; margin-bottom: 8px; display: flex; align-items: center; gap: 4px; }
.out-of-stock { color: var(--danger); }
.discount-badge-grid { position: absolute; top: 8px; right: 8px; background: linear-gradient(135deg, #EF4444, #DC2626); color: #fff; font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }
.b2c-link-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    padding: 6px 8px;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.b2c-link-btn:hover {
    background: #6366F1;
    color: #fff !important;
    border-color: #6366F1;
    transform: scale(1.05);
}

.grid-qty-row { display: flex; gap: 8px; align-items: center; padding: 0 16px 14px; }
.list-qty-selector { display: flex; align-items: center; border: 1px solid #E2E8F0; border-radius: 10px; overflow: hidden; flex: 1; background: #F8FAFC; }
.list-qty-btn { width: 36px; height: 38px; background: transparent; border: none; font-size: 1.2rem; color: #475569; cursor: pointer; transition: all 0.15s ease; display: flex; align-items: center; justify-content: center; font-weight: 600; }
.list-qty-btn:hover { background: #E2E8F0; color: #6366F1; }
.list-qty-input { width: 40px; height: 38px; text-align: center; border: none; border-left: 1px solid #E2E8F0; border-right: 1px solid #E2E8F0; font-size: 0.9rem; font-weight: 600; color: #1E293B; background: #fff; outline: none; -moz-appearance: textfield; }
.list-qty-input::-webkit-inner-spin-button, .list-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.row-add-btn { background: linear-gradient(135deg, #6366F1, #8B5CF6); color: #fff; border: none; padding: 10px 18px; border-radius: 10px; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease; white-space: nowrap; box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25); }
.row-add-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4); }
.discount-badge-inline { display: inline-block; background: #FEE2E2; color: #DC2626; font-size: 0.72rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-right: 4px; }
.discount-badge-block { display: inline-block; background: linear-gradient(135deg, #EF4444, #DC2626); color: #fff; font-size: 0.78rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; margin-bottom: 6px; box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3); text-align: center; }
/* Desktop list mode - price wrapper vertical layout: discount, old price, new price */
.products-view-container.list-mode .product-price-wrapper { align-items: center !important; text-align: center; }
.products-view-container.list-mode .product-price-original { text-decoration: line-through; color: #94A3B8; font-size: 0.82rem; margin-bottom: 4px; }
/* Grid mode - price wrapper vertical layout */
.products-view-container.grid-mode .product-price-wrapper { flex-direction: column; align-items: center; text-align: center; }
.products-view-container.grid-mode .product-price-original { text-decoration: line-through; color: #94A3B8; font-size: 0.82rem; margin-bottom: 4px; }

/* Cart Sidebar */
.overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 999; display: none; }
.cart-body { flex: 1; overflow-y: auto; padding: 20px; }
.finance-info-box { background:#f1f5f9; padding:15px; border-radius:8px; margin-bottom:20px; font-size:0.9rem; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.finance-info-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.finance-credit { color: var(--primary); }
.mixed-cart-warning { font-size:0.85rem; color:var(--danger); background:var(--danger-bg); padding:10px; border-radius:8px; margin-bottom:20px; display: none; }
.mixed-cart-warning[style*="display: block"] { display: block; }
.checkout-form-group { display:flex; flex-direction:column; gap:15px; }
.checkout-field { display: flex; flex-direction: column; gap: 5px; }
.checkout-label { font-weight:bold; font-size:0.9rem; display:block; }
.checkout-checkbox { background:#f8fafc; padding:10px; border-radius:8px; border:1px solid var(--border); cursor: pointer; }
.checkout-input { resize: none !important; font-family: inherit; font-size: 16px; }
.cart-footer-step2 { display: none; gap: 10px; margin-top: 10px; }
.cart-back-btn { flex: 1; text-align:center; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.cart-submit-btn { flex: 2; min-height: 44px; }
.cart-sidebar { position: fixed; top: 0; left: -400px; width: 400px; height: 100%; background: var(--surface); z-index: 1000; transition: 0.3s; display: flex; flex-direction: column; box-shadow: 2px 0 15px rgba(0,0,0,0.1); }
.cart-sidebar.open { left: 0; }
.cart-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.close-btn { font-size: 1.5rem; background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 6px 10px; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; line-height: 1; }
.cart-items { flex: 1; overflow-y: auto; padding: 20px; }
.cart-item { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 15px; margin-bottom: 15px; }
.cart-item-info h4 { font-size: 0.9rem; margin-bottom: 5px; }
.cart-item-price { color: var(--primary); font-weight: bold; font-size: 0.9rem; }
.cart-controls { display: flex; align-items: center; gap: 10px; }
.qty-btn { width: 32px; height: 32px; background: var(--bg-color); border: 1px solid var(--border); border-radius: 4px; cursor: pointer; font-weight: bold; display: inline-flex; align-items: center; justify-content: center; }
.cart-footer { padding: 20px; border-top: 1px solid var(--border); background: var(--bg-color); }
.cart-total { display: flex; justify-content: space-between; font-weight: bold; font-size: 1.1rem; margin-bottom: 15px; }
.checkout-section { background: var(--surface); padding: 15px; border-radius: 8px; margin-bottom: 10px; border: 1px solid var(--border); }
.checkout-input { width: 100%; padding: 10px; margin-top: 5px; margin-bottom: 15px; border-radius: 8px; border: 1px solid var(--border); font-family: inherit; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; cursor: pointer; }

.toast-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 2000; }
.toast { background: #333; color: white; padding: 12px 24px; border-radius: 8px; margin-bottom: 10px; }

/* Mega Menu Overlay (mobile backdrop that closes menu when clicked) */
.mega-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999998;
    display: none;
    -webkit-tap-highlight-color: transparent;
}
.mega-menu-overlay.open { display: block; }

/* === Mobile-only helpers (hidden on desktop) === */
@media (max-width: 767px) {
    .mobile-only { display: block; }
    .open-filters-btn.mobile-only { display: inline-flex; }
    .filters-sidebar-header.mobile-only { display: flex; }
    .filters-sidebar-footer.mobile-only { display: block; }
}

@media (max-width: 768px) {
    /* Mobile header height for fixed positioning of mega menu (matches compact 2-row header: ~100px) */
    :root { --mobile-header-h: 100px; }
    .store-layout { flex-direction: column; padding: 15px; gap: 15px; }
    .filters-sidebar { position: fixed; top: 0; right: -100%; width: 85%; max-width: 320px; height: 100%; z-index: 999; border-radius: 0; padding: 0; max-height: 100vh; overflow-y: auto; transition: right 0.3s ease; display: flex; flex-direction: column; }
    .filters-sidebar.open { right: 0; }
    .filters-sidebar-body { padding: 20px; flex: 1; }
    .cart-sidebar { width: 100%; left: -100%; max-width: 100%; }
    /* Mobile: 2-row header.
       Row 1: hamburger + logo ........ panel/login + cart
       Row 2: search (full width) */
    .store-header-top {
        flex-wrap: wrap;
        padding: 8px 12px;
        gap: 8px;
    }
    .store-header-bottom { display: none; }
    .store-header { padding: 0; }
    .header-right, .header-left {
        gap: 6px;
        flex-wrap: nowrap;
        align-items: center;
        flex-shrink: 0;
        min-width: 0;
    }
    /* Row 1: header-right (logo+hamburger) takes left half, header-left (login) takes right half */
    .header-right { flex: 1 1 auto; min-width: 0; }
    .header-left { flex: 0 0 auto; justify-content: flex-end; }
    /* Row 2: search bar full width */
    .header-center {
        flex: 1 1 100%;
        width: 100%;
        order: 3;
        min-width: 0;
    }
    .header-center .search-bar {
        width: 100%;
        max-width: 100%;
    }
    .brand { font-size: 1rem; gap: 4px; flex-shrink: 0; }
    .brand span { display: inline; }
    .btn-outline { padding: 6px 10px; font-size: 0.8rem; min-height: 40px; align-items: center; justify-content: center; white-space: nowrap; flex-shrink: 0; }
    .header-left .btn-outline { padding: 8px 12px; font-size: 0.8rem; min-height: 40px; }
    .search-bar { flex: 1 1 auto; padding: 4px 10px; min-width: 0; }
    .search-bar input { width: 100%; font-size: 16px; padding: 6px; min-width: 0; }
    .cart-btn { flex-shrink: 0; }
    .mega-menu-toggle { flex-shrink: 0; }
    /* mega-menu-nav (desktop dropdown) is hidden on mobile - mobile uses mega-menu-nav-mobile */
    .mega-menu-nav { display: none !important; }
    .mega-menu-toggle { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: none; color: var(--text-main); cursor: pointer; min-width: 40px; min-height: 40px; padding: 6px; border-radius: 8px; }
    .mega-menu-toggle:hover { background: var(--bg-color); }
    .mega-menu-overlay { z-index: 999998; }
    .mega-menu-root { flex-direction: column; gap: 0; }
    .mega-menu-item { padding: 12px 8px; border-bottom: 1px solid var(--border); }
    .mega-menu-item.active { border-bottom: 2px solid var(--primary); border-left: none; }
    .mega-menu-dropdown { position: static; width: 100%; box-shadow: none; border: none; border-radius: 0; flex-direction: column; min-height: 0; padding-right: 10px; }
    .mega-menu-l2 { width: 100%; border-left: none; border-bottom: 1px solid var(--border); background: transparent; }
    .mega-menu-l3-container { display: block !important; padding: 8px 12px; background: var(--bg-color); }
    /* F5 ISSUE 2: Improved grid view for mobile - 2 columns, compact card */
    .products-grid, .products-view-container.grid-mode {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    /* Mobile grid mode - full product name, bigger price, balanced qty row */
    .products-view-container.grid-mode .product-card {
        padding: 0 !important;
        border-radius: 14px !important;
    }
    .products-view-container.grid-mode .product-card-header {
        padding: 14px !important;
    }
    .products-view-container.grid-mode .product-img {
        height: 160px !important;
        margin: 0 !important;
        border-radius: 10px !important;
    }
    .products-view-container.grid-mode .product-category {
        font-size: 0.72rem !important;
        margin-bottom: 4px !important;
        line-height: 1.4 !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    .products-view-container.grid-mode .product-name {
        font-size: 0.88rem !important;
        height: auto !important;
        margin: 0 0 8px 0 !important;
        line-height: 1.55 !important;
        overflow: visible !important;
        display: block !important;
        -webkit-line-clamp: unset !important;
        -webkit-box-orient: unset !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    .products-view-container.grid-mode .product-info-block {
        padding: 12px 14px !important;
    }
    .products-view-container.grid-mode .product-price-wrapper {
        padding: 0 14px 10px !important;
        background: linear-gradient(135deg, #FAFBFF, #F8FAFC);
        margin: 0 !important;
        border-top: 1px solid #F1F5F9;
        padding-top: 10px !important;
    }
    .products-view-container.grid-mode .product-price {
        font-size: 1.15rem !important;
        margin: 0 !important;
        font-weight: 800 !important;
        color: #1E293B !important;
        text-align: center !important;
    }
    .products-view-container.grid-mode .product-price-original {
        text-align: center !important;
        font-size: 0.85rem !important;
    }
    .products-view-container.grid-mode .grid-qty-row {
        padding: 0 14px 14px !important;
        gap: 10px !important;
        display: flex !important;
    }
    .products-view-container.grid-mode .grid-qty-row .list-qty-selector {
        flex: 1 !important;
        height: 44px !important;
    }
    .products-view-container.grid-mode .grid-qty-row .row-add-btn {
        flex: 1 !important;
        min-height: 44px !important;
        padding: 10px 14px !important;
        font-size: 0.9rem !important;
    }
    .products-view-container.grid-mode .btn-primary {
        padding: 10px 14px !important;
        font-size: 0.9rem !important;
        min-height: 44px !important;
    }
    /* Grid mode b2c link - inline, not overlapping */
    .products-view-container.grid-mode .b2c-link-btn {
        top: 6px !important;
        left: 6px !important;
    }
    .products-view-container.grid-mode .discount-badge-grid {
        top: 6px !important;
        right: 6px !important;
    }
    .product-img { height: 130px; }
    .modal-wrapper { width: 95%; padding: 15px; max-height: 90vh; overflow-y: auto; }
    .main-preview-container { height: 250px; }
    .thumb-img { width: 55px; height: 55px; }
    .cart-header { padding: 15px; }
    .cart-items { padding: 15px; }
    .cart-body { padding: 15px; }
    .cart-footer { padding: 15px; }
    .checkout-input { font-size: 16px; }
    .products-header { flex-wrap: wrap; gap: 10px; }
    .products-header-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
    /* F4 ISSUE 2: On mobile, swap hamburger and logo so hamburger is rightmost (RTL start).
       In RTL with flex-direction: row, order:1 = rightmost, order:2 = to its left. */
    .header-right .mega-menu-toggle { order: 1; }
    .header-right .brand { order: 2; }
    .header-right .mega-menu-nav { order: 3; }
}

/* Hide hamburger on desktop */
@media (min-width: 769px) {
    .mega-menu-toggle { display: none; }
}

/* دکمه‌های تغییر حالت ویو */
.view-toggle-buttons { display: flex; background: #e2e8f0; padding: 4px; border-radius: 8px; gap: 2px; }
.view-btn { background: transparent; border: none; padding: 8px 12px; border-radius: 6px; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; transition: 0.2s; min-height: 36px; }
.view-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-success { background: #10b981; color: white; border: none; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-family: inherit; font-weight: bold; font-size: 0.9rem; transition: 0.2s; }
.btn-success:hover { background: #059669; }

/* ساختار داینامیک ویوها */
.products-view-container.grid-mode { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }

/* استایل‌های اختصاصی حالت لیستی (سطری) - مدرن و بهینه */
.products-view-container.list-mode { display: flex; flex-direction: column; gap: 12px; padding: 0; }
.products-view-container.list-mode .product-card {
    flex-direction: row; align-items: stretch;
    border: 1px solid #E2E8F0; border-radius: 14px;
    padding: 0; gap: 0; overflow: hidden;
    background: #fff;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.products-view-container.list-mode .product-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px -6px rgba(0,0,0,0.12); border-color: #C7D2FE; }
/* Image section - bigger thumbnail */
.products-view-container.list-mode .product-card-header { flex-shrink: 0; width: 130px; padding: 14px; background: #F8FAFC; display: flex; align-items: center; justify-content: center; border-left: 1px solid #E2E8F0; }
.products-view-container.list-mode .product-img { width: 100px; height: 100px; margin: 0; cursor: pointer; border-radius: 8px; padding: 0; border: none; background: transparent; object-fit: contain; transition: transform 0.3s ease; }
.products-view-container.list-mode .product-card:hover .product-img { transform: scale(1.08); }
/* Info section - full product name, b2c link inline */
.products-view-container.list-mode .product-info-block { flex: 1; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; justify-content: center; min-width: 0; }
.products-view-container.list-mode .product-name { height: auto; font-size: 0.92rem; margin: 0; white-space: normal; overflow: visible; text-overflow: clip; max-width: none; line-height: 1.5; word-break: break-word; }
.products-view-container.list-mode .product-tags-row { margin-top: 4px; display: flex; }
/* b2c link - styled as small inline button (not absolute) in list mode */
.products-view-container.list-mode .b2c-link-btn { position: static !important; display: inline-flex !important; align-items: center; gap: 4px; padding: 5px 10px; font-size: 0.72rem; border-radius: 8px; background: #F1F5F9; color: #475569; border: 1px solid #E2E8F0; text-decoration: none; transition: all 0.2s ease; }
.products-view-container.list-mode .b2c-link-btn:hover { background: #6366F1; color: #fff; border-color: #6366F1; }
/* Price section - prominent, with gradient background */
.products-view-container.list-mode .product-price-wrapper { flex-shrink: 0; padding: 14px 20px; margin: 0; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; min-width: 150px; border-right: 1px solid #E2E8F0; background: linear-gradient(135deg, #FAFBFF, #F8FAFC); }
.products-view-container.list-mode .product-price { margin: 0; font-size: 1.15rem; font-weight: 800; min-width: 0; text-align: left; white-space: nowrap; color: #1E293B; }
.products-view-container.list-mode .product-price-original { font-size: 0.82rem; margin-bottom: 2px; }
.products-view-container.list-mode .discount-badge-inline { margin-right: 0; margin-top: 4px; align-self: center; }
/* Actions section - qty + add button, well-spaced */
.products-view-container.list-mode .product-actions-row { flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 14px 18px; }
.products-view-container.list-mode .product-stock { display: none !important; }
.products-view-container.list-mode .discount-badge-grid { position: static; margin: 4px 0; }
.products-view-container.list-mode .out-of-stock-tag { font-size: 1rem; font-weight: 700; color: #DC2626; min-width: 150px; text-align: center; padding: 14px 20px; display: flex; align-items: center; justify-content: center; background: #FEF2F2; }

/* باکس تغییر تعداد ردیف‌ها در حالت لیستی */
.list-qty-selector { display: flex; align-items: center; background: var(--bg-color); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: 110px; height: 38px; }
.list-qty-btn { width: 32px; height: 100%; background: transparent; border: none; font-size: 1.2rem; cursor: pointer; transition: 0.2s; color: var(--text-main); }
.list-qty-btn:hover { background: #e2e8f0; }
.list-qty-input { width: 46px; height: 100%; border: none; background: transparent; text-align: center; font-family: inherit; font-weight: bold; font-size: 0.95rem; -moz-appearance: textfield; }
.list-qty-input::-webkit-outer-spin-button, .list-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* استایل‌های اختصاصی مودال تصاویر کالا */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.75); z-index: 2500; display: none; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
.modal-overlay.open { display: flex; opacity: 1; }
/* Desktop: 800x800 gallery image */
.modal-wrapper { background: var(--surface); border-radius: var(--radius); width: 90%; max-width: 900px; padding: 25px; position: relative; box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3); }
.modal-close { position: absolute; top: 15px; left: 15px; font-size: 2rem; background: none; border: none; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 4px 8px; min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
.modal-close:hover { color: var(--danger); }
.main-preview-container { width: 100%; height: 800px; max-height: 80vh; background: var(--bg-color); border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 15px; border: 1px solid var(--border); }
.main-preview-container img { max-width: 100%; max-height: 100%; object-fit: contain; }
.thumbnails-grid { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 5px; }
.thumb-img { width: 90px; height: 90px; object-fit: contain; border: 2px solid var(--border); border-radius: 6px; cursor: pointer; background: var(--bg-color); transition: 0.2s; }
.thumb-img.active, .thumb-img:hover { border-color: var(--primary); }

@media (max-width: 768px) {
    /* F4 ISSUE 3: Mobile list view redesigned — image + info side by side (image on right in RTL),
       price as a prominent full-width row, qty selector + add-to-cart as a full-width action row.
       Uses CSS Grid so the existing HTML structure (no wrapper div) can be repositioned cleanly.
       Desktop layout (flex-direction: row) is untouched — only applies at ≤768px. */
    /* Mobile list mode - horizontal card using CSS Grid:
       Image on the right (column 1), content stacked in column 2.
       This keeps price/actions properly positioned under the info block. */
    .products-view-container.list-mode { background: transparent; border: none; padding: 0; gap: 10px; }
    .products-view-container.list-mode .product-card {
        display: grid !important;
        grid-template-columns: 110px 1fr !important;
        grid-template-rows: auto auto auto !important;
        padding: 0 !important;
        border-radius: 14px !important;
        overflow: hidden;
        flex-direction: unset !important;
    }
    /* Image - column 1, spans all rows */
    .products-view-container.list-mode .product-card-header {
        grid-column: 1 !important;
        grid-row: 1 / 4 !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 10px !important;
        background: #F8FAFC !important;
        border-left: 1px solid #E2E8F0 !important;
        border-bottom: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    .products-view-container.list-mode .product-img {
        width: 90px !important;
        max-width: 90px !important;
        height: 90px !important;
        margin: 0 !important;
        object-fit: contain !important;
    }
    /* b2c link and discount badge - hide on mobile list mode to save space */
    .products-view-container.list-mode .b2c-link-btn {
        display: none !important;
    }
    .products-view-container.list-mode .discount-badge-grid {
        top: 4px !important;
        right: auto !important;
        left: 4px !important;
        font-size: 0.65rem !important;
        padding: 2px 6px !important;
    }
    /* Info block - column 2, row 1 */
    .products-view-container.list-mode .product-info-block {
        grid-column: 2 !important;
        grid-row: 1 !important;
        padding: 10px 12px !important;
        text-align: right !important;
        min-width: 0 !important;
        gap: 4px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
    }
    .products-view-container.list-mode .product-name {
        font-size: 0.82rem !important;
        line-height: 1.45 !important;
        white-space: normal !important;
        word-break: break-word !important;
        max-width: 100% !important;
        text-align: right !important;
        margin: 0 !important;
    }
    .products-view-container.list-mode .product-category {
        font-size: 0.68rem !important;
        line-height: 1.3 !important;
        white-space: normal !important;
        justify-content: flex-start !important;
        text-align: right !important;
    }
    .products-view-container.list-mode .product-tags-row {
        display: none !important;
    }
    /* Price - column 2, row 1 (inside info area, right-aligned)
       OR column 2, row 2 (below info) - depends on stock/price status.
       For products WITH price: price goes in the info column area (row 1), actions below.
       For products WITHOUT price (login required): price message spans column 2.
       For out-of-stock: tag spans column 2. */
    .products-view-container.list-mode .product-price-wrapper {
        grid-column: 2 !important;
        grid-row: 2 !important;
        align-self: center !important;
        width: 100% !important;
        min-width: 0 !important;
        border-right: none !important;
        border-top: 1px dashed #E2E8F0 !important;
        background: #FAFBFF !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: flex-start !important;
        padding: 6px 12px !important;
        text-align: right !important;
    }
    .products-view-container.list-mode .discount-badge-block {
        font-size: 0.65rem !important;
        padding: 2px 8px !important;
        margin-bottom: 4px !important;
        align-self: flex-start !important;
    }
    .products-view-container.list-mode .product-price {
        font-size: 1.05rem !important;
        text-align: right !important;
        font-weight: 800 !important;
        color: #1E293B !important;
        white-space: nowrap !important;
    }
    .products-view-container.list-mode .product-price-original {
        text-align: right !important;
        font-size: 0.72rem !important;
        margin-bottom: 2px !important;
    }
    /* Actions row - column 2, row 3 (below info+price) */
    .products-view-container.list-mode .product-actions-row {
        grid-column: 2 !important;
        grid-row: 3 !important;
        width: 100% !important;
        padding: 0 12px 10px !important;
        gap: 8px !important;
        justify-content: stretch !important;
        display: flex !important;
    }
    .products-view-container.list-mode .list-qty-selector {
        flex: 1 !important;
        width: auto !important;
        height: 38px !important;
    }
    .products-view-container.list-mode .row-add-btn {
        flex: 1 !important;
        min-height: 38px !important;
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }
    /* Out-of-stock tag: column 2, rows 2-3 (below info) */
    .products-view-container.list-mode .out-of-stock-tag {
        grid-column: 2 !important;
        grid-row: 2 / 4 !important;
        align-self: center !important;
        width: 100% !important;
        min-width: 0 !important;
        padding: 10px 12px !important;
        font-size: 0.9rem !important;
        justify-content: center !important;
        text-align: center !important;
    }
    /* Grid mode qty row on mobile */
    .grid-qty-row { padding: 0 16px 14px !important; gap: 10px !important; }
    .grid-qty-row .list-qty-selector { flex: 1; height: 44px; }
    .grid-qty-row .row-add-btn { flex: 1; min-height: 44px; }
}

@media (max-width: 480px) {
    /* Small mobile - keep horizontal layout but more compact */
    .products-view-container.list-mode .product-card-header {
        width: 90px !important;
        min-width: 90px !important;
        padding: 8px !important;
    }
    .products-view-container.list-mode .product-img {
        width: 74px !important;
        max-width: 74px !important;
        height: 74px !important;
    }
    .products-view-container.list-mode .product-name {
        font-size: 0.76rem !important;
    }
    .products-view-container.list-mode .product-category {
        font-size: 0.62rem !important;
    }
    .products-view-container.list-mode .product-price {
        font-size: 0.95rem !important;
    }
    .products-view-container.list-mode .product-price-original {
        font-size: 0.65rem !important;
    }
    .products-view-container.list-mode .discount-badge-block {
        font-size: 0.58rem !important;
        padding: 1px 6px !important;
    }
    /* Grid mode - stack qty and button vertically on very small screens */
    .grid-qty-row { flex-direction: column !important; }
    .grid-qty-row .list-qty-selector { width: 100% !important; }
    .grid-qty-row .row-add-btn { width: 100% !important; }
}
/* Mega Menu Nav — Desktop default (mobile overrides inside @media (max-width: 768px) below).
   Wrapped in min-width: 769px so the desktop rule does NOT cascade over the mobile rule
   (which previously caused the mega menu to be always visible on mobile). */
.mega-menu-nav {
    /* Mobile-first default: hidden, shown via .open class (see media query below) */
    display: none;
    flex-direction: column;
}
@media (min-width: 769px) {
    .mega-menu-nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        margin-right: 20px;
    }
}
.mega-menu-root {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 15px;
    height: 100%;
}
.mega-menu-item {
    position: relative;
    cursor: pointer;
    padding: 10px 5px;
    color: var(--text-main);
    font-weight: bold;
    transition: color 0.3s;
}
.mega-menu-item:hover {
    color: var(--primary);
}
.mega-menu-item.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}
.mega-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 600px;
    background: white;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-radius: 8px;
    display: none;
    z-index: 1000;
    border: 1px solid var(--border);
    flex-direction: row;
    padding: 0;
    /* کل dropdown حداکثر تا ارتفاع صفحه باز می‌شود */
    overflow: hidden;
    min-height: auto;
    max-height: calc(100vh - 140px);
}
.mega-menu-item:hover .mega-menu-dropdown {
    display: flex;
}
.mega-menu-l2 {
    width: 200px;
    background: #f8fafc;
    border-left: 1px solid var(--border);
    list-style: none;
    padding: 0;
    margin: 0;
    /* اسکرول مستقل برای لیست سطح ۲ */
    overflow-y: auto;
    max-height: 100%;
    flex-shrink: 0;
}
.mega-menu-l2-item {
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}
.mega-menu-l2-item:hover, .mega-menu-l2-item.active-hover {
    background: white;
    color: var(--primary);
}
.mega-menu-l3-container {
    flex: 1;
    padding: 20px;
    background: white;
    display: none;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    align-content: start;
    /* اسکرول مستقل برای محتوای سطح ۳ و ۴ */
    overflow-y: auto;
    max-height: 100%;
    min-height: 0;
    /* اسکرول‌بار ظریف در سمت چپ (RTL) */
    direction: rtl;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
/* اسکرول‌بار ظریف برای l3-container (Chrome/Safari/Edge) */
.mega-menu-l3-container::-webkit-scrollbar { width: 6px; }
.mega-menu-l3-container::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.mega-menu-l3-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.mega-menu-l3-container::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* بلاک لول ۳ که شامل عنوان (لول ۳) و زیرمجموعه‌هایش (لول ۴) می‌شود */
.mega-menu-l3-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px;
}
.mega-menu-l3-item {
    cursor: pointer;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 700;
    transition: color 0.2s, background 0.2s;
    padding: 6px 8px;
    border-radius: 4px;
    border-bottom: 1px solid #e2e8f0;
}
.mega-menu-l3-item:hover {
    color: var(--primary-hover);
    background: #eff6ff;
}

/* لول ۴: لیست عمودی زیر هر لول ۳ */
.mega-menu-l4 {
    list-style: none;
    padding: 4px 8px 8px 12px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    border-right: 2px solid #e2e8f0;
}
.mega-menu-l4-item {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 400;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}
.mega-menu-l4-item:hover {
    color: var(--primary);
    background: #f8fafc;
}

/* Breadcrumb in sidebar */
.category-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    margin-bottom: 16px;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.82rem;
    line-height: 1.4;
}
.category-breadcrumb .breadcrumb-item {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
    padding: 2px 4px;
    border-radius: 4px;
}
.category-breadcrumb .breadcrumb-item:hover {
    color: var(--primary-hover);
    background: #e0e7ff;
}
.category-breadcrumb .breadcrumb-item:last-child {
    color: var(--text-main);
    font-weight: 700;
    cursor: default;
    background: transparent;
}
.category-breadcrumb .breadcrumb-item:last-child:hover {
    background: transparent;
    color: var(--text-main);
}
.category-breadcrumb .breadcrumb-sep {
    color: var(--text-muted);
    font-weight: 300;
    user-select: none;
}

/* ===== بنر وضعیت جستجو ===== */
/* این بنر بالای لیست محصولات نمایش داده می‌شود وقتی کاربر متنی را جستجو کرده،
   تا نشان دهد در حالت جستجو است، چه عبارتی جستجو شده و دامنه جستجو (کل سایت / دسته فعلی). */
.search-status-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    border: 1px solid #bfdbfe;
    border-right: 4px solid var(--primary);
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.08);
    animation: searchBannerSlideIn 0.25s ease-out;
    flex-wrap: wrap;
}
@keyframes searchBannerSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.search-status-banner .search-status-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}
.search-status-banner .search-status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    flex-shrink: 0;
}
.search-status-banner .search-status-text {
    font-size: 0.92rem;
    color: var(--text-main);
    line-height: 1.5;
    word-break: break-word;
}
.search-status-banner .search-status-text strong {
    color: var(--primary);
    font-weight: 700;
    background: #fff;
    padding: 2px 8px;
    border-radius: 6px;
    margin: 0 2px;
    direction: ltr;
    display: inline-block;
    unicode-bidi: embed;
}
.search-status-banner .clear-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.search-status-banner .clear-search-btn:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.search-status-banner .clear-search-btn:active {
    transform: scale(0.96);
}
/* Mobile: بنر روی صفحه‌های کوچک بهینه می‌شود */
@media (max-width: 480px) {
    .search-status-banner {
        padding: 10px 12px;
        gap: 8px;
    }
    .search-status-banner .search-status-icon {
        width: 28px;
        height: 28px;
    }
    .search-status-banner .search-status-text {
        font-size: 0.85rem;
    }
    .search-status-banner .clear-search-btn {
        padding: 5px 10px;
        font-size: 0.78rem;
    }
    .search-status-banner .clear-search-btn span {
        display: none; /* فقط آیکون نمایش داده شود */
    }
}

/* Checkbox specific styles */
.brand-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}
.brand-checkbox-label:hover {
    color: var(--primary);
}
.brand-name-fa { font-weight: 600; }
.brand-name-en { font-size: 0.78rem; color: var(--text-muted); margin-right: 4px; }
.brand-checkbox-label:hover .brand-name-en { color: var(--primary); }
/* === Responsive Fixes === */
@media (max-width: 1024px) {
    .mega-menu-dropdown { width: min(600px, calc(100vw - 40px)); }
}

@media (max-width: 480px) {
    /* F4 ISSUE 1: At ≤480px the header is 2-row (~124px tall per agent-browser measurement in F3).
       Update the CSS variable so the fixed mega menu sits just below the header. */
    :root { --mobile-header-h: 124px; }
    /* On very small screens, use a 2-row header: brand+controls on row 1, search on row 2.
       This keeps the header compact (~100px) while still showing brand text and a usable search bar. */
    .store-header { padding: 8px 10px; flex-wrap: wrap; gap: 6px; }
    .header-right, .header-left { gap: 6px; flex-wrap: nowrap; }
    .header-left { flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
    .brand { font-size: 1rem; gap: 6px; }
    .brand span { display: inline; font-size: 0.9rem; }
    .search-bar { flex: 1 1 100%; order: 3; margin-top: 4px; padding: 4px 10px; }
    .btn-outline { padding: 6px 10px; font-size: 0.8rem; min-height: 40px; align-items: center; justify-content: center; white-space: nowrap; }
    .products-grid, .products-view-container.grid-mode { grid-template-columns: 1fr !important; }
    .product-img { height: 130px; margin-bottom: 10px; }
    .product-name { font-size: 0.85rem; height: auto; }
    .product-price { font-size: 1rem; }
    .modal-wrapper { width: 100%; padding: 12px; border-radius: 0; min-height: 100vh; max-height: 100vh; }
    .modal-overlay { align-items: flex-start; padding: 0; }
    .main-preview-container { height: 200px; }
    .thumb-img { width: 48px; height: 48px; }
    .list-qty-selector { width: 90px; }
    .products-view-container.list-mode .product-price { min-width: 100px; font-size: 0.95rem; }
    .products-section .products-header { flex-wrap: wrap; gap: 10px; }
    .filters-sidebar { width: 92%; }
}


/* ===== F4: Mobile Mega Menu (outside header for proper z-index) ===== */
/* Hidden on desktop */
.mega-menu-nav-mobile {
    display: none;
}

/* Mobile-only: fixed drawer below header */
@media (max-width: 768px) {
    .mega-menu-nav-mobile {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--surface);
        padding: 0;
        z-index: 1000000;
        max-height: 100vh;
        overflow-y: auto;
    }
    .mega-menu-nav-mobile.open {
        display: flex;
    }
    .mega-menu-nav-mobile .mega-menu-root {
        flex-direction: column;
        gap: 0;
        list-style: none;
        padding: 15px;
        margin: 0;
    }
    .mega-menu-nav-mobile .mega-menu-item {
        padding: 16px 12px;
        border-bottom: 1px solid var(--border);
        position: relative;
        cursor: pointer;
        font-weight: bold;
        color: var(--text-main);
        font-size: 1rem;
    }
    .mega-menu-nav-mobile .mega-menu-item.active {
        color: var(--primary);
        border-left: 3px solid var(--primary);
        padding-right: 8px;
    }
    .mega-menu-nav-mobile .mobile-menu-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 15px;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
        position: sticky;
        top: 0;
        z-index: 10;
        gap: 10px;
    }
    .mega-menu-nav-mobile .mobile-menu-header h3 {
        font-size: 1.05rem;
        margin: 0;
        color: var(--text-main);
        flex: 1;
        text-align: center;
        font-weight: bold;
    }
    .mega-menu-nav-mobile .mobile-menu-back-btn {
        background: var(--bg-color);
        border: none;
        cursor: pointer;
        color: var(--primary);
        padding: 6px;
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        flex-shrink: 0;
    }
    .mega-menu-nav-mobile .mobile-menu-back-btn:hover {
        background: var(--primary-light);
    }
    .mega-menu-nav-mobile #mobile-menu-close {
        background: none;
        border: none;
        font-size: 1.8rem;
        cursor: pointer;
        color: var(--text-muted);
        padding: 4px 10px;
        min-width: 40px;
        min-height: 40px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        line-height: 1;
        flex-shrink: 0;
    }
    .mega-menu-nav-mobile #mobile-menu-close:hover {
        color: var(--danger);
        background: var(--danger-bg);
        border-radius: 8px;
    }
    /* محتوای منو (drill-down levels) */
    .mega-menu-nav-mobile .mobile-menu-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
    .mega-menu-nav-mobile .mobile-menu-content.slide-in {
        animation: mobileMenuSlideIn 0.25s ease-out;
    }
    @keyframes mobileMenuSlideIn {
        from { opacity: 0; transform: translateX(-20px); }
        to { opacity: 1; transform: translateX(0); }
    }
    /* لیست آیتم‌های هر سطح */
    .mega-menu-nav-mobile .mobile-menu-list {
        list-style: none;
        padding: 8px 0;
        margin: 0;
    }
    .mega-menu-nav-mobile .mobile-menu-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 18px;
        border-bottom: 1px solid var(--border);
        cursor: pointer;
        transition: background 0.15s;
        gap: 10px;
    }
    .mega-menu-nav-mobile .mobile-menu-item:active {
        background: var(--bg-color);
    }
    .mega-menu-nav-mobile .mobile-menu-item.select-parent {
        background: var(--primary-light);
        border-bottom: 2px solid var(--primary);
    }
    .mega-menu-nav-mobile .mobile-menu-item.active-all {
        background: var(--primary);
        color: white;
    }
    .mega-menu-nav-mobile .mobile-menu-item-name {
        flex: 1;
        font-size: 1rem;
        font-weight: 600;
        color: inherit;
        line-height: 1.4;
    }
    .mega-menu-nav-mobile .mobile-menu-item-badge {
        font-size: 0.75rem;
        color: var(--primary);
        background: var(--surface);
        padding: 4px 10px;
        border-radius: 12px;
        font-weight: bold;
    }
    .mega-menu-nav-mobile .mobile-menu-item.active-all .mobile-menu-item-name {
        color: white;
    }
    .mega-menu-nav-mobile .mobile-menu-item-arrow {
        background: var(--bg-color);
        border: none;
        cursor: pointer;
        color: var(--text-muted);
        padding: 6px;
        min-width: 36px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        flex-shrink: 0;
        transition: all 0.2s;
    }
    .mega-menu-nav-mobile .mobile-menu-item-arrow:hover {
        background: var(--primary);
        color: white;
    }

    .mega-menu-nav-mobile .mega-menu-title {
        display: block;
        font-size: 1rem;
    }
    /* Dropdown داخل موبایل: به صورت زیرمجموعه نمایش داده شود */
    .mega-menu-nav-mobile .mega-menu-dropdown {
        position: static;
        width: 100%;
        box-shadow: none;
        border: none;
        border-radius: 0;
        flex-direction: column;
        min-height: 0;
        padding-right: 10px;
        display: none;
        margin-top: 8px;
    }
    .mega-menu-nav-mobile .mega-menu-item.expanded .mega-menu-dropdown {
        display: flex;
    }
    .mega-menu-nav-mobile .mega-menu-l2 {
        width: 100%;
        border-left: none;
        border-bottom: 1px solid var(--border);
        background: var(--bg-color);
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .mega-menu-nav-mobile .mega-menu-l2-item {
        padding: 12px 15px;
        cursor: pointer;
        border-bottom: 1px solid #e2e8f0;
        font-size: 0.9rem;
        font-weight: 500;
        color: var(--text-main);
    }
    .mega-menu-nav-mobile .mega-menu-l3-container {
        display: block !important;
        padding: 8px 12px;
        background: var(--bg-color);
    }
    .mega-menu-nav-mobile .mega-menu-l3-item {
        padding: 8px 5px;
        font-size: 0.85rem;
        color: var(--text-muted);
        cursor: pointer;
    }
}

/* ===== F4: Header layout - hamburger first (RTL rightmost), logo second ===== */
@media (max-width: 768px) {
    /* هدر: همبرگری راست‌ترین، بعد لوگو */
    .header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .header-right .mega-menu-toggle {
        order: 1; /* راست‌ترین در RTL */
    }
    .header-right .brand {
        order: 2;
    }
    /* منوی دسکتاپ داخل هدر در موبایل مخفی است */
    .header-right .mega-menu-nav {
        display: none !important;
    }
    /* پنل کاربری در موبایل - بدون !important تا JS بتواند hide کند */
    .header-left .btn-outline {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-height: 40px;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ===== F4: Improved product list card for mobile ===== */
@media (max-width: 768px) {
    .products-view-container.list-mode .product-card {
        display: grid !important;
        grid-template-columns: 100px 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 12px !important;
        padding: 14px !important;
        background: white !important;
        border: 1px solid var(--border) !important;
        border-radius: 14px !important;
        margin-bottom: 12px !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.06) !important;
        align-items: start !important;
    }
    .products-view-container.list-mode .product-card > .product-img {
        grid-column: 1 !important;
        grid-row: 1 !important;
        width: 100px !important;
        height: 100px !important;
        align-self: start !important;
        margin: 0 !important;
        border: 1px solid var(--border) !important;
        border-radius: 10px !important;
        padding: 2px !important;
        background: var(--bg-color) !important;
        object-fit: contain !important;
    }
    .products-view-container.list-mode .product-card > .product-info-block {
        grid-column: 2 !important;
        grid-row: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        min-width: 0 !important;
    }
    .products-view-container.list-mode .product-card > .product-info-block .product-name {
        font-size: 0.95rem !important;
        font-weight: bold !important;
        line-height: 1.4 !important;
        height: auto !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: clip !important;
        margin: 0 !important;
        color: var(--text-main) !important;
    }
    .products-view-container.list-mode .product-card > .product-info-block .product-category {
        font-size: 0.75rem !important;
        color: var(--text-muted) !important;
        line-height: 1.3 !important;
    }
    .products-view-container.list-mode .product-card > .product-price {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        text-align: right !important;
        min-width: 0 !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
        color: var(--primary) !important;
        margin: 0 !important;
        padding: 10px 0 !important;
        border-top: 1px dashed var(--border) !important;
    }
    .products-view-container.list-mode .product-card > .product-actions-row {
        grid-column: 1 / -1 !important;
        grid-row: 3 !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        flex-wrap: nowrap !important;
    }
    .products-view-container.list-mode .product-card > .out-of-stock-tag {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        color: var(--danger) !important;
        background: var(--danger-bg) !important;
        padding: 10px 12px !important;
        border-radius: 8px !important;
        text-align: center !important;
        font-size: 1rem !important;
        font-weight: bold !important;
        min-width: 0 !important;
        border-top: none !important;
    }
    .list-qty-selector {
        width: 120px !important;
        height: 44px !important;
    }
    .list-qty-btn {
        width: 38px !important;
    }
    .row-add-btn {
        flex: 1 !important;
        min-height: 44px !important;
        padding: 10px 14px !important;
        font-size: 0.95rem !important;
    }
}

@media (max-width: 480px) {
    .products-view-container.list-mode .product-card {
        padding: 12px !important;
        gap: 10px !important;
    }
    .products-view-container.list-mode .product-card > .product-img {
        width: 85px !important;
        height: 85px !important;
    }
}




/* ==========================================
   CLEAN MEGA-MENU CSS (replaces all F4-F7 attempts)
   ========================================== */

/* Desktop mega-menu (>= 769px) */
@media (min-width: 769px) {
    /* Hide hamburger on desktop */
    .mega-menu-toggle { display: none !important; }

    /* Menu item with dropdown - position relative for dropdown positioning */
    .mega-menu-item {
        position: relative !important;
    }

    /* Dropdown: fixed position, full width, below header with 8px gap */
    .mega-menu-dropdown {
        position: fixed !important;
        top: 108px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 1400px !important;
        margin: 0 auto !important;
        border-radius: 0 0 12px 12px !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
        /* ارتفاع حداکثر تا ارتفاع صفحه، بدون اسکرول کل dropdown */
        min-height: auto !important;
        max-height: calc(100vh - 130px) !important;
        overflow: hidden !important;
        /* Use visibility for show/hide so mouse events work */
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        transition: opacity 0.2s ease !important;
        display: flex !important;
        z-index: 1000 !important;
    }

    /* Show dropdown when JS adds .js-open class */
    .mega-menu-dropdown.js-open {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Sub-menu styling - L2 (در 卡ت بین کار بود، دست نخورده) */
    .mega-menu-l2 {
        width: 250px !important;
        padding: 10px 0 !important;
        /* اسکرول مستقل برای لیست سطح ۲ */
        overflow-y: auto !important;
        max-height: 100% !important;
        flex-shrink: 0 !important;
    }
    .mega-menu-l2-item {
        padding: 14px 20px !important;
        font-size: 0.95rem !important;
    }
    /* L3-container: اسکرول مستقل از L2
       نکته مهم: نباید height: 100% بگذاریم چون parent (dropdown) فقط max-height دارد
       و height: 100% در این حالت resolve نمی‌شود و overflow-y: auto کار نمی‌کند.
       فقط overflow-y: auto + max-height کافی است (مثل L2).
       direction: rtl در base rule (خط 1111) قبلاً تعیین شده پس اسکرول‌بار در سمت چپ است. */
    .mega-menu-l3-container {
        padding: 25px 30px !important;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)) !important;
        gap: 12px 20px !important;
        align-content: start !important;
        overflow-y: auto !important;
        max-height: 100% !important;
        scrollbar-width: thin !important;
        scrollbar-color: #cbd5e1 transparent !important;
    }
    /* اسکرول‌بار ظریف برای l3-container */
    .mega-menu-l3-container::-webkit-scrollbar { width: 6px; }
    .mega-menu-l3-container::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
    .mega-menu-l3-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
    .mega-menu-l3-container::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
    /* اسکرول‌بار ظریف برای l2 */
    .mega-menu-l2::-webkit-scrollbar { width: 6px; }
    .mega-menu-l2::-webkit-scrollbar-track { background: transparent; }
    .mega-menu-l2::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
    .mega-menu-l2::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
    .mega-menu-l3-item {
        font-size: 0.9rem !important;
        padding: 8px 12px !important;
        border-radius: 8px !important;
        transition: all 0.2s !important;
    }
    .mega-menu-l3-item:hover {
        background: var(--primary-light) !important;
        /* No transform to prevent layout shift */
    }

    /* استایل اسکرول‌بار برای dropdown */
    .mega-menu-l2::-webkit-scrollbar,
    .mega-menu-l3-container::-webkit-scrollbar {
        width: 6px;
    }
    .mega-menu-l2::-webkit-scrollbar-track,
    .mega-menu-l3-container::-webkit-scrollbar-track {
        background: transparent;
    }
    .mega-menu-l2::-webkit-scrollbar-thumb,
    .mega-menu-l3-container::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 3px;
    }
    .mega-menu-l2::-webkit-scrollbar-thumb:hover,
    .mega-menu-l3-container::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

    /* Arrow indicator for items with dropdown */
    .mega-menu-item:has(.mega-menu-dropdown) > .mega-menu-title::after {
        content: '▾' !important;
        font-size: 0.7rem !important;
        margin-right: 5px !important;
        color: var(--text-muted) !important;
    }

    /* Scrollbar styling for dropdown */
    .mega-menu-dropdown::-webkit-scrollbar {
        width: 8px;
    }
    .mega-menu-dropdown::-webkit-scrollbar-track {
        background: #f1f5f9;
    }
    .mega-menu-dropdown::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }
    .mega-menu-dropdown::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }

    /* Search bar - shorter and moved to left */
    .store-header {
        gap: 15px !important;
    }
    .header-center {
        flex: 0 0 auto !important;
        margin-right: auto !important;
    }
    .header-center .search-bar {
        width: 280px !important;
        max-width: 280px !important;
    }
    .header-center .search-bar input {
        width: 100% !important;
        min-width: 0 !important;
    }
}

/* Mobile mega-menu (<= 768px) - hide desktop dropdown */
@media (max-width: 768px) {
    .mega-menu-nav {
        display: none !important;
    }
}

/* F5-F7 fixes that are still needed */

/* F6: Header - new two-row layout (top: logo+search+login / bottom: mega menu) */
.store-header {
    display: flex !important;
    flex-direction: column !important;
    gap: 0 !important;
}
.header-center {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    min-width: 0;
}
.header-center .search-bar {
    flex: 1;
    max-width: 500px;
}

@media (max-width: 768px) {
    .store-header {
        flex-wrap: nowrap !important;
        gap: 0 !important;
    }
    .header-right {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    .header-right .mega-menu-toggle {
        order: 1;
    }
    .header-right .brand {
        order: 2;
    }
    .header-left {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    .header-left .btn-outline {
        padding: 8px 12px !important;
        font-size: 0.8rem !important;
        min-height: 40px !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
    .header-center {
        flex: 1 1 100% !important;
        order: 3 !important;
        margin-top: 4px !important;
    }
    .header-center .search-bar {
        max-width: 100% !important;
    }
}

/* F6: Products header - title on right, controls on left */
.products-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 15px !important;
    flex-wrap: wrap !important;
}
.products-header-title {
    flex: 0 0 auto;
}
.products-header-title h2 {
    margin: 0;
    font-size: 1.2rem;
}
.products-header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .products-header {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 10px !important;
    }
    .products-header-title {
        flex: 0 0 auto !important;
    }
    .products-header-title h2 {
        font-size: 1.1rem !important;
    }
    .products-header-controls {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }
    .products-header-controls .open-filters-btn {
        flex-shrink: 0 !important;
    }
    .products-header-controls .view-toggle-buttons {
        flex-shrink: 0 !important;
    }
    .products-header-controls .sort-select {
        min-height: 40px !important;
        font-size: 0.85rem !important;
        max-width: 120px !important;
    }
}

/* F7: Grid view qty selector */
.grid-qty-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    margin-top: auto !important;
    margin-bottom: 10px !important;
    width: 100% !important;
}
.grid-qty-row .list-qty-selector {
    width: 110px !important;
    height: 38px !important;
    display: flex !important;
    align-items: center !important;
    background: var(--bg-color) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    overflow: hidden !important;
}
.grid-qty-row .list-qty-btn {
    width: 32px !important;
    height: 100% !important;
    background: transparent !important;
    border: none !important;
    font-size: 1.2rem !important;
    cursor: pointer !important;
    color: var(--text-main) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.grid-qty-row .list-qty-input {
    width: 46px !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
    font-family: inherit !important;
    font-weight: bold !important;
    font-size: 0.95rem !important;
    -moz-appearance: textfield !important;
}
.grid-qty-row .list-qty-input::-webkit-outer-spin-button,
.grid-qty-row .list-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}
.grid-qty-row .row-add-btn {
    width: 100% !important;
    min-height: 40px !important;
    padding: 8px !important;
    font-size: 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* F5: Mobile grid view - 2 columns */
@media (max-width: 768px) {
    .products-grid, .products-view-container.grid-mode {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .products-view-container.grid-mode .product-card {
        padding: 10px !important;
        border-radius: 12px !important;
    }
    .products-view-container.grid-mode .product-img {
        height: 130px !important;
        margin-bottom: 10px !important;
        border-radius: 8px !important;
    }
    .products-view-container.grid-mode .product-category {
        font-size: 0.7rem !important;
        margin-bottom: 4px !important;
        line-height: 1.3 !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    .products-view-container.grid-mode .product-name {
        font-size: 0.88rem !important;
        height: auto !important;
        margin: 0 0 8px 0 !important;
        line-height: 1.55 !important;
        overflow: visible !important;
        display: block !important;
        -webkit-line-clamp: unset !important;
        -webkit-box-orient: unset !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    .products-view-container.grid-mode .product-price {
        font-size: 0.95rem !important;
        margin-bottom: 10px !important;
        margin-top: auto !important;
    }
    .products-view-container.grid-mode .btn-primary {
        padding: 8px !important;
        font-size: 0.85rem !important;
        min-height: 40px !important;
    }
    .product-img { height: 130px; }
}

/* F5: Hide mobile filter button on desktop */
@media (min-width: 769px) {
    .open-filters-btn.mobile-only {
        display: none !important;
    }
}

/* F6: Desktop products-header layout */
@media (min-width: 769px) {
    .products-header {
        flex-wrap: nowrap !important;
    }
    .products-header-left {
        flex: 0 0 auto !important;
    }
    .products-header-right {
        margin-right: auto !important;
    }
}


/* ===== F8: Gallery modal mobile optimization ===== */
@media (max-width: 768px) {
    /* Modal overlay: center the modal, don't stretch to full screen */
    #gallery-modal.modal-overlay {
        align-items: center !important;
        justify-content: center !important;
        padding: 20px !important;
    }

    /* Modal wrapper: not full screen, centered, max-width */
    #gallery-modal .modal-wrapper {
        width: 100% !important;
        max-width: 350px !important;
        max-height: 85vh !important;
        min-height: auto !important;
        padding: 15px !important;
        border-radius: 16px !important;
        margin: 0 auto !important;
        position: relative !important;
        overflow-y: auto !important;
    }

    /* Modal body content: center everything */
    #gallery-modal .modal-body-content {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
    }

    /* Main preview container: bigger, centered */
    #gallery-modal .main-preview-container {
        width: 100% !important;
        height: 280px !important;
        margin: 0 auto 15px auto !important;
        border-radius: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Main preview image: fit properly */
    #gallery-modal .main-preview-container img {
        max-width: 95% !important;
        max-height: 95% !important;
        object-fit: contain !important;
    }

    /* Thumbnails grid: horizontal scroll, centered, proper height */
    #gallery-modal .thumbnails-grid {
        display: flex !important;
        flex-direction: row !important;
        gap: 10px !important;
        overflow-x: auto !important;
        padding: 10px 0 !important;
        width: 100% !important;
        justify-content: center !important;
        align-items: center !important;
        min-height: 70px !important;
    }

    /* Thumbnail images: bigger, properly sized */
    #gallery-modal .thumb-img {
        width: 60px !important;
        height: 60px !important;
        object-fit: contain !important;
        border: 2px solid var(--border) !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        background: var(--bg-color) !important;
        flex-shrink: 0 !important;
        transition: all 0.2s !important;
    }

    #gallery-modal .thumb-img.active,
    #gallery-modal .thumb-img:hover {
        border-color: var(--primary) !important;
        transform: scale(1.05) !important;
    }

    /* Close button: properly positioned */
    #gallery-modal .modal-close {
        top: 10px !important;
        left: 10px !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        font-size: 1.5rem !important;
        background: rgba(255, 255, 255, 0.9) !important;
        border-radius: 50% !important;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
        z-index: 10 !important;
    }
}

/* Extra small screens (<= 480px) */
@media (max-width: 480px) {
    #gallery-modal.modal-overlay {
        padding: 15px !important;
    }

    #gallery-modal .modal-wrapper {
        max-width: 100% !important;
        padding: 12px !important;
    }

    #gallery-modal .main-preview-container {
        height: 220px !important;
    }

    #gallery-modal .thumb-img {
        width: 50px !important;
        height: 50px !important;
    }
}

/* Extra small screens (<= 360px) */
@media (max-width: 360px) {
    #gallery-modal .main-preview-container {
        height: 180px !important;
    }

    #gallery-modal .thumb-img {
        width: 45px !important;
        height: 45px !important;
    }
}








/* ===== Discount and B2C link styles ===== */

/* هدر کارت محصول */
.product-card-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* بج تخفیف در حالت جدولی (بالا راست روی عکس) */
.discount-badge-grid {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #dc2626;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 3px 8px;
    border-radius: 8px;
    z-index: 5;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4);
}

/* بج تخفیف inline (کنار قیمت در حالت لیستی) */
.discount-badge-inline {
    display: inline-block;
    background: #dc2626;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 6px;
    margin-right: 4px;
    vertical-align: middle;
}

/* ردیف تگ‌ها (B2C link) در حالت لیستی */
.product-tags-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}



/* wrapper قیمت */
.product-price-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
    margin-top: auto;
}

/* قیمت اصلی (خط‌خورده) */
.product-price-original {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--danger);
}

/* ===== GRID VIEW: qty centered, compact card ===== */

/* کارت در حالت جدولی - عرض و ارتفاع کنترل شده */
.products-view-container.grid-mode .product-card {
    padding: 10px !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* عکس در حالت جدولی */
.products-view-container.grid-mode .product-img {
    height: 120px !important;
    margin-bottom: 8px !important;
    border-radius: 8px !important;
}

/* نام محصول در حالت جدولی */
.products-view-container.grid-mode .product-name {
        font-size: 0.88rem !important;
        height: auto !important;
        margin: 0 0 8px 0 !important;
        line-height: 1.55 !important;
        overflow: visible !important;
        display: block !important;
        -webkit-line-clamp: unset !important;
        -webkit-box-orient: unset !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

/* دسته‌بندی در حالت جدولی */
.products-view-container.grid-mode .product-category {
    font-size: 0.7rem !important;
    margin-bottom: 3px !important;
}

/* قیمت‌ها در حالت جدولی - وسط‌چین */
.products-view-container.grid-mode .product-price-wrapper {
    align-items: center;
    text-align: center;
    margin-bottom: 8px;
}

.products-view-container.grid-mode .product-price-original {
    text-align: center;
    font-size: 0.75rem;
}

.products-view-container.grid-mode .product-price {
    font-size: 0.95rem !important;
    text-align: center;
}

/* grid-qty-row: عرض کامل، وسط‌چین */
.products-view-container.grid-mode .grid-qty-row {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 6px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    margin-top: auto;
}

/* qty selector در grid - وسط‌چین، عرض 50% */
.products-view-container.grid-mode .grid-qty-row .list-qty-selector {
    width: 50% !important;
    max-width: 50% !important;
    box-sizing: border-box !important;
    justify-content: center;
    height: 36px;
    margin: 0 auto;
}

/* دکمه افزودن در grid - عرض کامل */
.products-view-container.grid-mode .grid-qty-row .row-add-btn {
    width: 100% !important;
    box-sizing: border-box !important;
    min-height: 36px !important;
    font-size: 0.85rem !important;
    padding: 6px !important;
}

/* list-qty-input در grid - وسط‌چین */
.products-view-container.grid-mode .list-qty-input {
    text-align: center;
    font-size: 0.85rem !important;
}

/* list-qty-btn در grid */
.products-view-container.grid-mode .list-qty-btn {
    width: 30px !important;
    font-size: 1rem !important;
}

/* ===== LIST VIEW ===== */

/* در حالت لیستی، قیمت‌ها روبه‌روی باکس تعداد */
.products-view-container.list-mode .product-price-wrapper {
    align-items: flex-end;
    min-width: 140px;
    text-align: left;
    justify-content: center;
}

/* قیمت اصلی - خط‌خورده با رنگ قرمز، بزرگ‌تر */
.products-view-container.list-mode .product-price-original {
    font-size: 0.9rem;
    text-align: left;
    color: #ef4444;
    text-decoration: line-through;
    text-decoration-color: #dc2626;
    text-decoration-thickness: 2px;
    font-weight: 600;
    margin-bottom: 2px;
}

/* قیمت نهایی - برجسته */
.products-view-container.list-mode .product-price {
    text-align: left;
    font-size: 1.1rem;
    font-weight: 800;
    color: #059669;
}

/* actions row در list view */
.products-view-container.list-mode .product-actions-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
    flex-shrink: 0;
}

.products-view-container.list-mode .product-actions-row .list-qty-selector {
    flex-shrink: 0;
}

.products-view-container.list-mode .product-actions-row .row-add-btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .products-view-container.grid-mode .product-img {
        height: 100px !important;
    }
    
    .products-view-container.grid-mode .product-name {
        font-size: 0.75rem !important;
    }
    
    .products-view-container.grid-mode .product-price {
        font-size: 0.85rem !important;
    }
    
    .products-view-container.grid-mode .grid-qty-row .list-qty-selector {
        height: 32px;
    }
    
    .products-view-container.grid-mode .list-qty-btn {
        width: 26px !important;
    }
    
    .products-view-container.grid-mode .list-qty-input {
        font-size: 0.8rem !important;
    }
    
    .discount-badge-grid {
        font-size: 0.7rem !important;
        padding: 2px 6px !important;
    }
    

}

@media (max-width: 360px) {
    .products-view-container.grid-mode .product-img {
        height: 90px !important;
    }
    
    .products-view-container.grid-mode .product-name {
        font-size: 0.7rem !important;
        -webkit-line-clamp: 1 !important;
    }
}


/* ===== FIX: Prevent mega-menu layout shift on hover ===== */
@media (min-width: 769px) {
    /* Ensure dropdown items don't change size on hover */
    .mega-menu-l2-item,
    .mega-menu-l3-item {
        box-sizing: border-box !important;
        border: 1px solid transparent !important;
    }
    
    .mega-menu-l2-item:hover,
    .mega-menu-l2-item.active-hover {
        border-color: var(--border) !important;
    }
    
    .mega-menu-l3-item:hover {
        border-color: var(--primary) !important;
    }
    
    /* Prevent any transition that changes size */
    .mega-menu-dropdown,
    .mega-menu-l2,
    .mega-menu-l3-container {
        transition: none !important;
    }
    
    /* Ensure l2 items have fixed width to prevent reflow */
    .mega-menu-l2 {
        flex-shrink: 0 !important;
    }
    
    /* l3-container: فقط flex می‌خواهیم.
       ❌ هرگز overflow: hidden !important اینجا نگذاریم چون override می‌کند
       روی overflow-y: auto !important که در rule بالاتر (خط ~1714) تنظیم شده.
       این قبلاً باعث شده بود اسکرول L3/L4 کاملاً غیرفعال شود. */
    .mega-menu-l3-container {
        flex: 1 !important;
    }
}


/* ===== Mobile grid view: 1 column, VERTICAL card, UNIFORM sizes ===== */
@media (max-width: 768px) {
    /* Grid: 1 column, center items */
    .products-view-container.grid-mode {
        justify-items: center !important;
        gap: 12px !important;
    }
    
    /* Card: uniform width, vertical layout */
    .products-view-container.grid-mode .product-card {
        flex-direction: column !important;
        padding: 14px !important;
        width: 100% !important;
        max-width: 320px !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
    }
    
    /* Image: uniform size */
    .products-view-container.grid-mode .product-card-header {
        width: 100% !important;
        height: 160px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .products-view-container.grid-mode .product-img {
        width: auto !important;
        max-width: 100% !important;
        height: 160px !important;
        object-fit: contain !important;
    }
    
    /* Info block */
    .products-view-container.grid-mode .product-info-block {
        width: 100% !important;
    }
    
    .products-view-container.grid-mode .product-name {
        font-size: 0.88rem !important;
        height: auto !important;
        margin: 0 0 8px 0 !important;
        line-height: 1.55 !important;
        overflow: visible !important;
        display: block !important;
        -webkit-line-clamp: unset !important;
        -webkit-box-orient: unset !important;
        white-space: normal !important;
        word-break: break-word !important;
    }
    
    /* Prices centered */
    .products-view-container.grid-mode .product-price-wrapper {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
        gap: 2px !important;
        margin-bottom: 8px !important;
    }
    
    .products-view-container.grid-mode .product-price-original {
        text-align: center !important;
        font-size: 0.78rem !important;
    }
    
    .products-view-container.grid-mode .product-price {
        font-size: 0.98rem !important;
        text-align: center !important;
    }
    
    /* Qty row: vertical */
    .products-view-container.grid-mode .grid-qty-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 6px !important;
        width: 100% !important;
    }
    
    .products-view-container.grid-mode .grid-qty-row .list-qty-selector {
        width: 100% !important;
        max-width: 100% !important;
        height: 38px !important;
    }
    
    .products-view-container.grid-mode .grid-qty-row .row-add-btn {
        width: 100% !important;
        min-height: 38px !important;
    }
}

@media (max-width: 480px) {
    .products-view-container.grid-mode .product-card {
        max-width: 100% !important;
    }
    
    .products-view-container.grid-mode .product-card-header {
        height: 140px !important;
    }
    
    .products-view-container.grid-mode .product-img {
        height: 140px !important;
    }
    
    .products-view-container.grid-mode .product-name {
        font-size: 0.8rem !important;
    }
}


/* Old list-mode mobile rules removed - using new design above */

/* Old 480px list-mode rules removed - using new design above */


/* ===== Payment Type Badges (نقدی / عرف) ===== */
.pay-badges-row { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.pay-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: help;
    transition: all 0.2s ease;
}
.pay-badge-cash {
    background: #DBEAFE;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
}
.pay-badge-cash::before {
    content: '\1F4B0';
    font-size: 0.7rem;
}
.pay-badge-credit {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FDE68A;
}
.pay-badge-credit::before {
    content: '\1F4CB';
    font-size: 0.7rem;
}
.pay-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* ===== Cart Delete Button ===== */
.cart-controls .delete-btn {
    background: #FEE2E2;
    color: #DC2626;
    margin-right: 4px;
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.cart-controls .delete-btn:hover {
    background: #DC2626;
    color: #fff;
}


/* ===== Cart Item Two-Box Layout ===== */
.cart-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid #E2E8F0;
}
.cart-item-name-box {
    background: #F8FAFC;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #E2E8F0;
}
.cart-item-name-box h4 {
    font-size: 0.82rem;
    font-weight: 600;
    color: #1E293B;
    margin: 0 0 4px 0;
    line-height: 1.4;
    word-break: break-word;
}
.cart-item-price {
    font-size: 0.8rem;
    color: #6366F1;
    font-weight: 700;
}
.cart-item-controls-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.cart-item-controls-box .cart-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}
.cart-item-pay-badges {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.cart-item-pay-badges .pay-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
}

/* ===== Cart Price Breakdown ===== */
#cart-price-breakdown {
    font-size: 0.78rem;
    color: #64748B;
    margin-top: 6px;
    line-height: 1.6;
}
#cart-price-breakdown div {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ==========================================================================
   ⚚ v105 (فاز ۷) — کارت‌های رادیویی «شیوه‌های پرداخت» و «روش ارسال» سبد خرید
   به‌جای لیست بازشونده (select)، همه‌ی گزینه‌های مجازِ کاربر به‌صورت کارت
   رادیویی با آیکون و رنگ‌بندی اختصاصی همزمان دیده می‌شوند.
   هر روش یک «هویه» (hue) دارد که رنگ حاشیه/پس‌زمینه/آیکون را در حالت
   انتخاب تعیین می‌کند: پرداخت: آبی/بنفش/سبز — ارسال: فیروزه‌ای/کهربایی/
   نیلی/خاکستری. رندر کارت‌ها در store.js v18 (renderChoiceCards).
   ========================================================================== */
.choice-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 5px;
    margin-bottom: 15px;
}

/* کارت واحد: [آیکون] [عنوان + توضیح] [نشان انتخاب] — در چیدمان RTL آیکون
   سمت راست و نشان انتخاب سمت چپ قرار می‌گیرد. */
.choice-card {
    --cc: #64748b;        /* رنگ اصلی روش (پیش‌فرض slate) */
    --cc-bg: #f8fafc;     /* تینت ملایم پس‌زمینه در حالت انتخاب */
    --cc-ring: rgba(100, 116, 139, 0.25);
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: border-color 0.18s ease, background-color 0.18s ease,
                box-shadow 0.18s ease, transform 0.18s ease;
}
.choice-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.07);
}

/* رادیوی اصلی از دید پنهان است (به‌جای display:none تا کیبورد/صفحه‌خوان
   درست کار کنند)؛ ظاهر انتخاب از طریق کلاس .selected کنترل می‌شود. */
.choice-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
}

/* حلقه فوکوس کیبورد روی خود کارت (رادیو نامرئیمان است) */
.choice-card:focus-within {
    box-shadow: 0 0 0 3px var(--cc-ring);
    border-color: var(--cc);
}

/* چیپ آیکون: در حالت عادی تینت ملایم؛ در حالت انتخاب توپر و سفید */
.choice-card-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--cc-bg);
    color: var(--cc);
    transition: background-color 0.18s ease, color 0.18s ease;
}

.choice-card-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0; /* اجازه شکست متن طولانی در کارت‌های باریک */
}
.choice-card-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-main);
    line-height: 1.4;
}
.choice-card-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* نشان تیک سمت چپ کارت: در حالت عادی دایره خالی کم‌رنگ */
.choice-card-check {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    margin-inline-start: auto;
    width: 22px;
    height: 22px;
    border: 2px solid var(--border);
    border-radius: 50%;
    color: transparent;
    background: var(--surface);
    transition: background-color 0.18s ease, border-color 0.18s ease,
                color 0.18s ease, transform 0.18s ease;
}
.choice-card-check svg { display: block; }

/* ---- حالت انتخاب: رنگ اختصاصی هر روش فعال می‌شود ---- */
.choice-card.selected {
    border-color: var(--cc);
    background: var(--cc-bg);
    box-shadow: 0 4px 14px var(--cc-ring);
}
.choice-card.selected .choice-card-icon {
    background: var(--cc);
    color: #ffffff;
}
.choice-card.selected .choice-card-title { color: var(--cc); }
.choice-card.selected .choice-card-check {
    background: var(--cc);
    border-color: var(--cc);
    color: #ffffff;
    transform: scale(1.08);
}

/* ---- هویه‌های اختصاصی روش‌های پرداخت ---- */
.choice-card--blue   { --cc: #2563eb; --cc-bg: #eff6ff; --cc-ring: rgba(37, 99, 235, 0.22); }
.choice-card--violet { --cc: #7c3aed; --cc-bg: #f5f3ff; --cc-ring: rgba(124, 58, 237, 0.20); }
.choice-card--green  { --cc: #059669; --cc-bg: #ecfdf5; --cc-ring: rgba(5, 150, 105, 0.20); }

/* ---- هویه‌های اختصاصی روش‌های ارسال ---- */
.choice-card--teal   { --cc: #0d9488; --cc-bg: #f0fdfa; --cc-ring: rgba(13, 148, 136, 0.20); }
.choice-card--amber  { --cc: #d97706; --cc-bg: #fffbeb; --cc-ring: rgba(217, 119, 6, 0.20); }
.choice-card--indigo { --cc: #4f46e5; --cc-bg: #eef2ff; --cc-ring: rgba(79, 70, 229, 0.20); }
.choice-card--slate  { --cc: #475569; --cc-bg: #f1f5f9; --cc-ring: rgba(71, 85, 105, 0.20); }

/* پشتیبانی مرورگرهای مدرن: انتخاب هم‌زمان با خود input (تکمیلی برای .selected) */
.choice-card:has(input[type="radio"]:checked) { border-color: var(--cc); background: var(--cc-bg); }

/* ---- موبایل: کارت‌های فشرده‌تر ---- */
@media (max-width: 767px) {
    .choice-cards { gap: 8px; margin-bottom: 10px; }
    .choice-card { padding: 10px 12px; gap: 10px; border-radius: 9px; }
    .choice-card-icon { width: 38px; height: 38px; border-radius: 9px; }
    .choice-card-icon svg { width: 19px; height: 19px; }
    .choice-card-title { font-size: 0.82rem; }
    .choice-card-desc { font-size: 0.66rem; }
    .choice-card-check { width: 20px; height: 20px; }
}
