/**
 * Ganjeh Kala – Archive & Product Grid
 * بازطراحی کامل صفحه آرشیو فروشگاه + فیلترها
 * (نسخه اصلاح شده نهایی برای رفع مشکل اسکرول افقی و مدال سفید)
 * Refactored to Canonical Tokens
 */

/* =========================================================
   0. Base Settings
   ========================================================= */
html, body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

*, *::before, *::after {
    box-sizing: border-box;
}

.gk-archive {
    margin: 1rem 0 4rem;
}

.gk-archive__inner {
    max-width: var(--gk-site-width);
    margin: 0 auto;
    padding: 0 var(--gk-container-gap);
    width: 100%;
}

/* =========================================================
   1. Layout (Sidebar & Main Column)
   ========================================================= */
.gk-archive__layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 1.5rem;
    width: 100%;
}

.gk-archive__sidebar-col {
    flex: 0 0 260px;
    max-width: 260px;
    border: var(--gk-border-width) solid var(--gk-neutral-100);
    border-radius: var(--gk-radius-lg);
    padding: 15px;
}

.gk-archive__main-col {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}



/* هدر و توضیحات */
.gk-breadcrumb {
    font-size: 0.8rem;
    color: var(--gk-neutral-900);
    margin-bottom: 0.75rem;
}

.gk-archive__header {
    margin-bottom: 1.5rem;
}

.gk-archive__title {
    font-size: 1.5rem;
    font-weight: var(--gk-heading-weight);
    margin: 0 0 0.75rem;
}

.gk-archive__description {
    font-size: 0.92rem;
    color: var(--gk-neutral-600);
    line-height: 1.7;
}

.gk-archive__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
/* ... بقیه استایل‌های تولبار که قبلاً داشتید ... */
.gk-archive__filters-toggle {
    display: none; /* در دسکتاپ مخفی */
    border: var(--gk-border-width) solid var(--gk-border-color);
    border-radius: var(--gk-radius-round);
    padding: 0.35rem 0.9rem;
    background: var(--gk-surface);
    font-size: 0.85rem;
    cursor: pointer;
}


.gk-archive__sort-label {
    font-size: 0.82rem;
    color: var(--gk-neutral-600);
}

.gk-archive__sort-list {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    padding-bottom: 5px;
}

.gk-archive__sort-item {
    position: relative;
    flex: 0 0 auto;
}

.gk-archive-toolbar__sort-link {
    text-decoration: none;
    color: var(--gk-neutral-600);
    font-size: 0.85rem;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.gk-archive__sort-item--active .gk-archive-toolbar__sort-link {
    color: var(--gk-primary);
    font-weight: 600;
}

.gk-archive__sort-item--active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 2px;
    background: var(--gk-primary);
    border-radius: 2px;
}

/* حالت در حال لود */

.gk-archive--loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* حذف منوی کشویی و شمارنده پیش‌فرض ووکامرس در این صفحه */
.gk-archive .woocommerce-result-count,
.gk-archive .woocommerce-ordering {
    display: none !important;
}

/* =========================================================
   2. سایدبار فیلتر – استایل حرفه‌ای شبیه دیجی‌کالا
   ========================================================= */

.gk-archive__filters-wrapper {
    position: sticky;
    top: 1.25rem;
    background: var(--gk-surface);
    max-height: calc(100vh - 2.5rem);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--gk-neutral-300) transparent;
}
/* استایل دکمه اعمال فیلتر با اولویت بالا */
.gk-archive__filters-wrapper .gk-archive__filters-footer .gk-archive__filters-apply {
    width: 100% !important;
    background-color: var(--gk-primary) !important;
    color: var(--gk-surface) !important;
    border: 1px solid var(--gk-primary) !important;
    padding: 12px !important; /* کمی ارتفاع بیشتر برای لمس راحت‌تر */
    border-radius: var(--gk-radius-md) !important;
    font-size: 16px !important;
    font-weight: var(--gk-heading-weight) !important;
    cursor: pointer !important;
    margin-top: 0 !important; /* چون در فوتر پدینگ دادیم */
    font-family: inherit !important;
    box-shadow: none !important;
    line-height: 1.5 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease !important;
}

.gk-archive__filters-wrapper .gk-archive__filters-footer .gk-archive__filters-apply:hover {
    opacity: 0.9 !important;
    background-color: var(--gk-primary) !important;
    color: var(--gk-surface) !important;
}
/* هدر کلی فیلترها (عنوان "فیلترها" و ریست) */
.gk-archive__filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.gk-archive__filters-title {
    font-size: 0.92rem;
    font-weight: var(--gk-heading-weight);
    color: var(--gk-neutral-900);
    margin: 0;
}

.gk-archive__filters-reset {
    font-size: 0.8rem;
    color: var(--gk-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;;
}
.gk-active-filter {
    border: none;
    font-family: inherit;
    border-radius: 5px;
    padding: 5px;
}
/* گروه فیلتر – حالت کارت‌مانند با هدر کلیک‌پذیر */

.gk-filter {
    border-radius: var(--gk-radius-lg);
    border: var(--gk-border-width) solid var(--gk-neutral-100);
    background: var(--gk-surface);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.gk-filter:last-child {
    margin-bottom: 0;
}

.gk-filter__header {
    background: var(--gk-neutral-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none; /* جلوگیری از انتخاب متن هنگام کلیک */
}

.gk-filter__title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.6rem 0.75rem;
    color: var(--gk-neutral-900);
    background: var(--gk-neutral-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gk-filter__toggle-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--gk-neutral-600);
    transition: transform 0.2s ease;
}

/* اگر JS کلاس gk-filter--collapsed را اضافه کند */
.gk-filter--collapsed .gk-filter__toggle-icon {
    transform: rotate(180deg);
}

/* +++ اضافه شده: مخفی کردن بادی وقتی بسته است +++ */
.gk-filter--collapsed .gk-filter__body {
    display: none;
}

.gk-filter__body {
    padding: 0.5rem 0.75rem 0.75rem;
    border-top: var(--gk-border-width) solid var(--gk-neutral-100);
}

/* لیست آیتم‌های فیلتر (چک‌باکس‌ها) */
.gk-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 210px;
    overflow-y: auto;
    padding-right: 2px;
}

.gk-list::-webkit-scrollbar {
    width: 4px;
}
.gk-list::-webkit-scrollbar-thumb {
    background: var(--gk-neutral-300);
    border-radius: var(--gk-radius-round);
}

/* چک‌باکس سفارشی */

.gk-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--gk-neutral-700);
    margin: 0;
}

.gk-check input[type="checkbox"],
.gk-check input[type="radio"] {
    position: relative;
    width: 16px;
    height: 16px;
    margin: 0;
    flex: 0 0 16px;
    appearance: none;
    border-radius: 4px;
    border: var(--gk-border-width) solid var(--gk-neutral-300);
    background: var(--gk-surface);
    cursor: pointer;
    transition: all 0.15s ease;
}

.gk-check input[type="checkbox"]:checked,
.gk-check input[type="radio"]:checked {
    border-color: var(--gk-primary);
    background: var(--gk-primary);
    box-shadow: 0 0 0 1px rgba(239, 64, 86, 0.2);
}

.gk-check input[type="checkbox"]:checked::after,
.gk-check input[type="radio"]:checked::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 2px;
    border: solid var(--gk-surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* برچسب متنی کنار چک‌باکس */

.gk-label {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.gk-label-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gk-count {
    font-size: 0.78rem;
    color: var(--gk-neutral-400);
}

/* فیلترهای خاص – مثل سوئیچ «ارسال سریع» */

.gk-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.gk-toggle-label {
    font-size: 0.85rem;
    color: var(--gk-neutral-700);
}

/* سوئیچ */

.gk-toggle-input {
    position: relative;
    width: 34px;
    height: 18px;
    appearance: none;
    border-radius: var(--gk-radius-round);
    background: var(--gk-neutral-200);
    cursor: pointer;
    outline: none;
    transition: background 0.2s ease;
    margin: 0;
}

.gk-toggle-input::before {
    content: "";
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: var(--gk-radius-round);
    background: var(--gk-surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease;
}

.gk-toggle-input:checked {
    background: var(--gk-accent);
}

.gk-toggle-input:checked::before {
    transform: translateX(-16px);
}

/* فیلتر قیمت – نمایش رنج و ورودی‌ها */

.gk-price-range {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--gk-neutral-600);
}

.gk-price-range__inputs {
    display: flex;
    gap: 0.4rem;
}

.gk-price-range__inputs input[type="number"],
.gk-price-range__inputs input[type="text"] {
    flex: 1;
    height: 32px;
    border-radius: 6px;
    border: var(--gk-border-width) solid var(--gk-border-color);
    padding: 0 0.4rem;
    font-size: 0.8rem;
    width: 100%;
}

/* =========================================================
   3. GRID SYSTEM (لیست محصولات)
   ========================================================= */

.gk-archive__main-col ul.products {
    display: grid !important;
    /* استفاده از متغیر توکن برای تعداد ستون */
    grid-template-columns: repeat(var(--gk-archive-cols-desktop, 4), 1fr);
    background-color: var(--gk-neutral-100) !important;
    /* استفاده از متغیر توکن برای فاصله (Gap) */
    gap: var(--gk-archive-gap, 1px) !important;
    border: var(--gk-archive-gap, 1px) solid var(--gk-neutral-100) !important;

    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
    float: none !important;
}

.gk-archive__main-col ul.products::before,
.gk-archive__main-col ul.products::after {
    content: none !important;
    display: none !important;
}

.gk-archive__main-col ul.products > *:not(li.product) {
    display: none !important;
}

.gk-archive__main-col ul.products li.product {
    width: auto !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: var(--gk-surface) !important;
    border: none !important;
    clear: none !important;
}

/* =========================================================
   4. DIGIKALA CARD STYLES
   ========================================================= */
.gk-dk-card {
    background: var(--gk-surface);
    position: relative;
    transition: all 0.2s ease-in-out;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-radius: 0 !important;
    width: 100% !important;
}

.gk-dk-card:hover {
    box-shadow: var(--gk-shadow-lg);
    z-index: 10;
    transform: translateY(0);
}

.gk-dk-card__inner {
    padding: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}

.gk-dk-card__image {
    display: block;
    width: 100%;
    height: 200px;
    margin-bottom: 10px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.gk-dk-card__image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    margin: 0 !important;
    transition: transform 0.3s ease;
}

/* عنوان محصول با محدودیت خطوط */
.gk-dk-card__title {
    font-size: 11px;
    font-weight: var(--gk-heading-weight);
    line-height: 24px;
    color: var(--gk-text);
    margin: 0 0 4px;
    min-height: 48px; /* ارتفاع ثابت برای 2 خط */

    display: -webkit-box;
    -webkit-line-clamp: var(--gk-card-title-lines, 2);
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: right;
}

.gk-dk-card__title a {
    text-decoration: none;
    color: inherit;
}

.gk-dk-card__delivery-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.gk-dk-card__delivery-info {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--gk-text);
}

.gk-dk-icon-truck {
    fill: var(--gk-secondary);
}

.gk-dk-card__delivery-info span {
    font-size: 10px;
    color: var(--gk-neutral-600);
}

.gk-dk-card__rating {
    display: flex;
    align-items: center;
    gap: 3px;
    margin-right: auto;
}

.gk-dk-card__rating-num {
    font-size: 11px;
    font-weight: var(--gk-heading-weight);
    color: var(--gk-text);
}

.gk-dk-card__price-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
}

.gk-dk-card__badge-container {
    flex: 0 0 auto;
}

.gk-dk-card__badge {
    background: var(--gk-primary);
    color: var(--gk-surface);
    font-size: 11px;
    font-weight: var(--gk-heading-weight);
    padding: 1px 6px;
    border-radius: 16px;
    display: inline-block;
    min-width: 24px;
    text-align: center;
}

.gk-dk-card__price-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-right: 8px;
}

.gk-dk-card__price-current {
    font-size: 15px;
    font-weight: var(--gk-heading-weight);
    color: var(--gk-text);
    display: flex;
    align-items: center;
    line-height: 1.2;
}

.gk-dk-card__price-current .woocommerce-Price-currencySymbol {
    font-size: 10px;
    margin-right: 4px;
    font-weight: 400;
}

.gk-dk-card__price-old {
    font-size: 11px;
    color: var(--gk-neutral-300);
    text-decoration: line-through;
    margin-top: 2px;
    line-height: 1;
}

.gk-dk-card__price-old .woocommerce-Price-currencySymbol {
    display: none;
}

.gk-dk-card__unavailable {
    font-size: 12px;
    color: var(--gk-neutral-400);
    font-weight: var(--gk-heading-weight);
    background: var(--gk-neutral-100);
    padding: 4px 10px;
    border-radius: 4px;
    width: 100%;
    text-align: center;
}

/* =========================================================
   5. RESPONSIVE & APP-STYLE BOTTOM SHEET (FINAL FIX)
   ========================================================= */

/* مخفی کردن دکمه‌های پیش‌فرض قالب یا ووکامرس */
.woocommerce-filter-toggle,
.storefront-sorting + .filter-toggle {
    display: none !important;
}

/* تبلت و دسکتاپ کوچک */
@media (max-width: 1400px) {
    .gk-archive__main-col ul.products { --gk-archive-cols: 4; }
}
@media (max-width: 1100px) {
    .gk-archive__main-col ul.products { --gk-archive-cols: 3; }
}

/* --- شروع استایل موبایل (تبدیل به Bottom Sheet) --- */
@media (max-width: 991px) {

    /* چیدمان ستونی */
    .gk-archive__layout {
        flex-direction: column;
        gap: 0;
    }

    /* 1. فضای سایدبار را در جریان صفحه نگه می‌داریم اما ابعادش را صفر می‌کنیم */
    .gk-archive__sidebar-col {
        display: block !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        overflow: visible !important;
    }

    /* دکمه باز کردن فیلتر */
    .gk-archive__filters-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: var(--gk-surface);
        color: var(--gk-text);
        border: var(--gk-border-width) solid var(--gk-border-color);
        padding: 8px 16px;
        border-radius: var(--gk-radius-md);
        font-weight: var(--gk-heading-weight);
        font-size: 14px;
        margin-bottom: 10px;
        width: auto; /* یا 100% بسته به سلیقه */
    }

    /* --- 2. کانتینر اصلی مدال (Wrapper) --- */
    .gk-archive__filters-wrapper {
        position: fixed !important;
        inset: auto 0 0 0 !important; /* چسبیدن به پایین */
        width: 100% !important;
        height: 85vh !important; /* ارتفاع ثابت */
        max-height: 85vh !important;

        background: var(--gk-surface) !important;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
        z-index: 999999 !important;

        /* انیمیشن */
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.35s;

        /* لی‌اوت فلکس برای فرزند مستقیم (فرم) */
        display: flex !important;
        flex-direction: column !important;
    }

    /* کلاس باز شدن مدال */
    .gk-archive__filters-wrapper--open {
        transform: translateY(0) !important;
        visibility: visible !important;
    }

    /* --- 3. اصلاح فرم برای پر کردن ارتفاع --- */
    /* نکته حیاتی: فرم باید ارتفاع والد (Wrapper) را کامل بگیرد */
    .gk-archive__filters-wrapper form {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        width: 100% !important;
        min-height: 0 !important; /* جلوگیری از باگ فلکس */
        background: var(--gk-surface) !important;
    }

    /* --- 4. هدر مدال (عنوان و دکمه حذف) --- */
    .gk-archive__filters-header {
        flex: 0 0 auto; /* ارتفاع ثابت بر اساس محتوا */
        padding: 18px 20px;
        border-bottom: var(--gk-border-width) solid var(--gk-neutral-100);
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: var(--gk-surface);
        border-radius: 20px 20px 0 0;
    }

    /* --- 5. بدنه اسکرول شونده (لیست فیلترها) --- */
    .gk-archive__filters-body {
        flex: 1 1 auto; /* پر کردن فضای باقی‌مانده */
        overflow-y: auto !important;
        overflow-x: hidden;
        padding: 20px;
        background: var(--gk-surface);
        min-height: 0; /* حیاتی برای اسکرول در فلکس */
    }

    /* --- 6. فوتر (دکمه اعمال) --- */
    .gk-archive__filters-footer {
        flex: 0 0 auto; /* ارتفاع ثابت */
        padding: 16px 20px;
        border-top: var(--gk-border-width) solid var(--gk-neutral-100);
        background: var(--gk-surface);
        /* فاصله امن برای آیفون‌های بدون دکمه */
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    /* خط تیره بالای مدال (Drag Handle) */
    .gk-archive__filters-wrapper::before {
        content: "";
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 48px;
        height: 5px;
        background: var(--gk-neutral-200);
        border-radius: 100px;
        z-index: 100000;
        pointer-events: none;
    }

    /* استایل دکمه اعمال فیلتر با اولویت بالا */
    .gk-archive__filters-wrapper .gk-archive__filters-footer .gk-archive__filters-apply {
        width: 100% !important;
        background-color: var(--gk-primary) !important;
        color: var(--gk-surface) !important;
        border: 1px solid var(--gk-primary) !important;
        padding: 12px !important; /* کمی ارتفاع بیشتر برای لمس راحت‌تر */
        border-radius: var(--gk-radius-md) !important;
        font-size: 16px !important;
        font-weight: var(--gk-heading-weight) !important;
        cursor: pointer !important;
        margin-top: 0 !important; /* چون در فوتر پدینگ دادیم */
        font-family: inherit !important;
        box-shadow: none !important;
        line-height: 1.5 !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        transition: opacity 0.2s ease !important;
    }

    .gk-archive__filters-wrapper .gk-archive__filters-footer .gk-archive__filters-apply:hover {
        opacity: 0.9 !important;
        background-color: var(--gk-primary) !important;
        color: var(--gk-surface) !important;
    }

    /* بک‌دراپ (تاریک شدن پشت) */
    .gk-filters-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,var(--gk-opacity-overlay));
        z-index: 99998 !important; /* زیر مدال */
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(3px);
    }

    .gk-filters-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
    }

    /* اصلاح گرید محصولات در موبایل */
    .gk-archive__main-col ul.products {
        --gk-archive-cols: 2;
        gap: 1px !important;
    }

    /* رفع باگ احتمالی display:none روی فیلترها در CSS پایه */
    .gk-filter {
        display: block; /* اطمینان از نمایش */
    }
}

/* گوشی‌های کوچک */
@media (max-width: 480px) {
    .gk-dk-card__image { height: 150px; }
    .gk-dk-card__title { font-size: 11px; min-height: 38px; }
    .gk-dk-card__price-current { font-size: 14px; }
}

/* =========================================================
   7. استایل وضعیت خالی (Empty State)
   ========================================================= */

.woocommerce-info {
    background: var(--gk-surface);
    border: var(--gk-border-width) solid var(--gk-border-color);
    border-radius: var(--gk-radius-lg);
    padding: 40px 20px;
    text-align: center;
    color: var(--gk-neutral-700);
    font-size: 1rem;
    margin: 20px 0;
    list-style: none;
    width: 100%;
    box-shadow: var(--gk-shadow-sm);
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.woocommerce-info::before {
    content: "!";
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--gk-primary-100);
    color: var(--gk-primary);
    border-radius: var(--gk-radius-round);
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
}

.woocommerce-info a {
    display: inline-block;
    margin-top: 10px;
    color: var(--gk-primary);
    text-decoration: none;
    border-bottom: 1px dashed;
}






/* =========================================================
   8. SUB-CATEGORIES CARDS (استایل زیر دسته‌بندی‌ها)
   ========================================================= */

.gk-subcats-section {
    margin-bottom: 2rem;
    width: 100%;
}

.gk-subcats-grid {
    display: grid;
    /* ایجاد ستون‌های واکنش‌گرا با حداقل عرض 140 پیکسل */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

/* کارت تکی */
.gk-subcat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--gk-neutral-100); /* رنگ پس‌زمینه خاکستری */
    border-radius: var(--gk-radius-lg);
    padding: 20px 10px;
    text-decoration: none;
    color: var(--gk-text);
    transition: all 0.2s ease;
    min-height: 160px;
    text-align: center;
}

.gk-subcat-card:hover {
    background-color: var(--gk-neutral-200);
    transform: translateY(-3px);
}

/* تصویر کارت */
.gk-subcat-card__img {
    width: 80px;
    height: 80px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gk-subcat-card__img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* فیلتر برای هماهنگی عکس با پس‌زمینه خاکستری (اختیاری) */
    mix-blend-mode: multiply;
}

/* عنوان کارت */
.gk-subcat-card__title {
    font-size: 0.9rem;
    font-weight: var(--gk-heading-weight);
    margin: 0;
    color: var(--gk-neutral-800);
    line-height: 1.4;
}

/* کارت "مشاهده بقیه" */
.gk-subcat-card--more {
    background-color: var(--gk-neutral-100);
    cursor: pointer;
    justify-content: center;
    gap: 5px;
}

.gk-subcat-card--more:hover {
    background-color: var(--gk-neutral-200);
}

.gk-subcat-card__more-txt {
    font-size: 0.85rem;
    color: var(--gk-neutral-600);
}

.gk-subcat-card__more-count {
    font-size: 2.5rem;
    font-weight: var(--gk-heading-weight);
    color: var(--gk-neutral-600);
    line-height: 1;
}

.gk-subcat-card__more-label {
    font-size: 0.85rem;
    color: var(--gk-neutral-600);
}

/* ریسپانسیو */
@media (max-width: 768px) {
    .gk-subcats-grid {
        /* در موبایل اسکرول افقی می‌خورد */
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
        scroll-snap-type: x mandatory;
    }

    .gk-subcat-card {
        min-width: 130px;
        width: 130px;
        scroll-snap-align: start;
        flex-shrink: 0;
    }
}




/* =========================================================
   9. PRODUCT HOVER IMAGE (اصلاح شده)
   ========================================================= */

.gk-dk-card__image {
    position: relative;
    overflow: hidden;
    display: block; /* اطمینان از بلاک بودن */
}

/* تصویر اصلی */
.gk-dk-card__image .gk-img-main {
    transition: opacity 0.3s ease-in-out;
    opacity: 1;
    z-index: 1;
    display: block; /* حذف فضای اضافه پایین عکس */
}

/* تصویر دوم (هاور) */
.gk-dk-card__image .gk-img-hover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    opacity: 0;
    z-index: 2;
    transition: opacity 0.3s ease-in-out;
    backface-visibility: hidden;
}

/* --- منطق هوشمند --- */

/* فقط زمانی عکس دوم را نشان بده که موس روی کارت است */
.gk-has-hover:hover .gk-img-hover {
    opacity: 1;
}

/* فقط زمانی عکس اصلی را محو کن که کلاس gk-has-hover وجود داشته باشد */
/* یعنی اگر محصول عکس دوم نداشت، عکس اصلی سرجایش می‌ماند و محو نمی‌شود */
.gk-has-hover:hover .gk-img-main {
    opacity: 0;
}

/* غیرفعال کردن در موبایل */
@media (max-width: 991px) {
    .gk-dk-card__image .gk-img-hover {
        display: none !important;
    }
    .gk-dk-card__image .gk-img-main {
        opacity: 1 !important;
    }
}


/* =========================================================
   10. Pagination Styles (اصلاح شده)
   ========================================================= */

#gk-archive-pagination {
    margin-top: 40px;
    display: flex;
    justify-content: center;
    width: 100%;
}

#gk-archive-pagination ul.page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

#gk-archive-pagination ul.page-numbers li {
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
}

/* لینک‌ها و دکمه‌های صفحه */
#gk-archive-pagination .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 10px;
    border-radius: var(--gk-radius-md);
    background: var(--gk-surface);
    border: var(--gk-border-width) solid var(--gk-border-color);
    color: var(--gk-text);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    line-height: 1;
}

/* هاور */
#gk-archive-pagination a.page-numbers:hover {
    border-color: var(--gk-primary);
    color: var(--gk-primary);
    background: var(--gk-primary-50); /* اگر متغیر دارید، وگرنه #f0f7ff */
}

/* صفحه فعال (Current) */
#gk-archive-pagination .page-numbers.current {
    background: var(--gk-primary);
    color: var(--gk-surface); /* سفید */
    border-color: var(--gk-primary);
    cursor: default;
}

/* دکمه‌های قبلی/بعدی (شامل آیکون SVG) */
#gk-archive-pagination .page-numbers.prev,
#gk-archive-pagination .page-numbers.next {
    padding: 0;
    width: 40px; /* مربعی برای آیکون */
}

#gk-archive-pagination .page-numbers svg {
    display: block;
    width: 18px;
    height: 18px;
}




/* =========================================================
   6. Layout Modifiers (Added in Step 3)
   ========================================================= */

/* Sidebar Left */
.gk-layout--sidebar-left {
    flex-direction: row-reverse;
}

/* No Sidebar (Desktop) */
@media (min-width: 992px) {
    .gk-layout--no-sidebar .gk-archive__sidebar-col {
        display: none;
    }
}

/* Fluid Container */
.gk-archive__inner--fluid {
    max-width: 100% !important;
    padding: 0 40px;
}

/* Empty State Styles */
.gk-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    background: var(--gk-surface);
    border: var(--gk-border-width) solid var(--gk-border-color);
    border-radius: var(--gk-radius-lg);
    width: 100%;
    grid-column: 1 / -1; /* For grid context */
}

.gk-empty-state__img {
    max-width: 200px;
    margin-bottom: 20px;
    opacity: 0.8;
}

.gk-empty-state__text h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: var(--gk-text);
}

.gk-empty-state__text p {
    color: var(--gk-neutral-500);
}

.gk-empty-state__search {
    margin-top: 20px;
    width: 100%;
    max-width: 400px;
    display: flex;
}
.gk-empty-state__search input {
    flex: 1;
    border-radius: 0 var(--gk-radius-md) var(--gk-radius-md) 0;
    /* RTL aware border radius adjustment might be needed via simple CSS logic if direction is RTL */
    border: 1px solid var(--gk-border-color);
    padding: 0 15px;
    height: 44px;
}
[dir="rtl"] .gk-empty-state__search input {
    border-radius: 0 var(--gk-radius-md) var(--gk-radius-md) 0;
}
.gk-empty-state__search button {
    border-radius: var(--gk-radius-md) 0 0 var(--gk-radius-md);
    background: var(--gk-primary);
    color: white;
    border: none;
    padding: 0 20px;
    cursor: pointer;
}
[dir="rtl"] .gk-empty-state__search button {
    border-radius: var(--gk-radius-md) 0 0 var(--gk-radius-md);
}



/* =========================================================
   7. Load More & Infinite Scroll
   ========================================================= */

/* دکمه مشاهده بیشتر */
.gk-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    height: 48px;
    background-color: var(--gk-surface);
    border: 1px solid var(--gk-border-color);
    border-radius: var(--gk-radius-md);
    color: var(--gk-text);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 20px auto;
}

.gk-load-more-btn:hover {
    border-color: var(--gk-primary);
    color: var(--gk-primary);
    background-color: var(--gk-neutral-50);
}

/* حالت لودینگ دکمه */
.gk-load-more-btn.loading {
    opacity: 0.7;
    cursor: wait;
    pointer-events: none;
}

/* اگر اینفینیت اسکرول فعال باشد، دکمه را می‌توان مخفی کرد تا دیده نشود
   یا استایلش را ساده‌تر کرد که فقط وقتی اسکرول می‌رسد دیده شود */
.gk-infinite-trigger {
    opacity: 0;
    height: 10px;
    pointer-events: none;
}





/* ریسپانسیو موبایل */
@media (max-width: 768px) {
    #gk-archive-pagination .page-numbers {
        min-width: 36px;
        height: 36px;
        font-size: 0.9rem;
        padding: 0 8px;
    }
}

/* Tablet & Small Desktop (1024px - 1400px) */
@media (max-width: 1400px) {
    .gk-archive__main-col ul.products {
        /* اگر متغیر تبلت تعریف شده باشد، استفاده می‌شود */
        grid-template-columns: repeat(var(--gk-archive-cols-tablet, 3), 1fr);
    }
}

/* Mobile (Bottom Sheet Mode) */
@media (max-width: 991px) {
    /* Layout Stack */
    .gk-archive__layout {
        flex-direction: column;
        gap: 0;
    }

    /* Sidebar becomes 0-size but keeps DOM presence */
    .gk-archive__sidebar-col {
        display: block !important;
        width: 0 !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
        overflow: visible !important;
    }

    /* Toggle Button Visible */
    .gk-archive__filters-toggle {
        display: inline-flex;
    }

    /* Product Grid Mobile */
    .gk-archive__main-col ul.products {
        grid-template-columns: repeat(var(--gk-archive-cols-mobile, 2), 1fr);
        gap: 1px !important;
    }

    /* Bottom Sheet Styles (همان استایل‌های قبلی که عالی بود) */
    .gk-archive__filters-wrapper {
        position: fixed !important;
        inset: auto 0 0 0 !important;
        width: 100% !important;
        height: 85vh !important;
        background: var(--gk-surface) !important;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
        z-index: 999999 !important;
        transform: translateY(105%);
        visibility: hidden;
        transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.35s;
        display: flex !important;
        flex-direction: column !important;
    }

    .gk-archive__filters-wrapper--open {
        transform: translateY(0) !important;
        visibility: visible !important;
    }

    .gk-archive__filters-wrapper form {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        width: 100% !important;
    }

    .gk-archive__filters-body {
        flex: 1 1 auto;
        overflow-y: auto !important;
        padding: 20px;
    }

    .gk-archive__filters-footer {
        flex: 0 0 auto;
        padding: 16px 20px;
        border-top: var(--gk-border-width) solid var(--gk-neutral-100);
        padding-bottom: calc(16px + env(safe-area-inset-bottom));
    }

    /* Drag Handle */
    .gk-archive__filters-wrapper::before {
        content: "";
        position: absolute;
        top: 8px; left: 50%; transform: translateX(-50%);
        width: 48px; height: 5px;
        background: var(--gk-neutral-200);
        border-radius: 100px;
        z-index: 100000;
        pointer-events: none;
    }

    /* Backdrop */
    .gk-filters-backdrop {
        position: fixed; inset: 0;
        background: rgba(0,0,0,var(--gk-opacity-overlay));
        z-index: 99998 !important;
        opacity: 0; visibility: hidden;
        transition: opacity 0.3s ease;
        backdrop-filter: blur(3px);
    }
    .gk-filters-backdrop.is-visible {
        opacity: 1; visibility: visible;
    }
}