﻿/* =========================================================
   Product Filter Mega Menu
   Single Selection - Mobile Only
   ========================================================= */

.product-filter-mega-modal[hidden] {
    display: none !important;
}

@media (min-width: 992px) {
    .product-filter-mega-modal {
        display: none !important;
    }
}

@media (max-width: 991.98px) {

    body.product-filter-mega-open {
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    .product-filter-mega-modal {
        position: fixed;
        inset: 0;
        z-index: 999999;
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        display: block;
        overflow: hidden;
        direction: rtl;
        background: #ffffff;
        transform: translateY(100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.24s ease, opacity 0.18s ease, visibility 0.24s ease;
    }

        .product-filter-mega-modal.is-open {
            transform: translateY(0);
            opacity: 1;
            visibility: visible;
        }

    .product-filter-mega-shell {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-rows: auto auto minmax(0, 1fr);
        background: #ffffff;
    }

    /* هدر مودال */

    .product-filter-mega-header {
        min-height: 64px;
        padding: max(10px, env(safe-area-inset-top)) 10px 10px;
        display: flex;
        align-items: center;
        gap: 8px;
        direction: ltr;
        background: #ffffff;
        border-bottom: 1px solid #edf0f3;
    }

    .product-filter-mega-back {
        width: 42px;
        min-width: 42px;
        height: 42px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 0;
        border-radius: 12px;
        background: transparent;
        color: #111827;
        font-size: 1rem;
        cursor: pointer;
    }

        .product-filter-mega-back:active {
            background: #f1f3f5;
        }

    .product-filter-mega-search-trigger {
        min-width: 0;
        height: 42px;
        padding: 0 12px;
        display: inline-flex;
        flex: 1 1 auto;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        direction: rtl;
        border: 0;
        border-radius: 11px;
        background: #f1f3f5;
        color: #94a3b8;
        font-family: inherit;
        font-size: 0.75rem;
        font-weight: 750;
        white-space: nowrap;
        overflow: hidden;
        cursor: pointer;
    }

        .product-filter-mega-search-trigger span {
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .product-filter-mega-search-trigger i {
            flex: 0 0 auto;
            color: #64748b;
        }

    /* تب‌ها */

    .product-filter-mega-tabs {
        min-height: 52px;
        padding: 0 8px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        background: #ffffff;
        border-bottom: 1px solid #e5e7eb;
    }

    .product-filter-mega-tab {
        position: relative;
        border: 0;
        background: transparent;
        color: #64748b;
        font-family: inherit;
        font-size: 0.82rem;
        font-weight: 900;
        cursor: pointer;
    }

        .product-filter-mega-tab::after {
            content: "";
            position: absolute;
            right: 10px;
            bottom: -1px;
            left: 10px;
            height: 3px;
            border-radius: 999px 999px 0 0;
            background: #224173;
            transform: scaleX(0);
            transition: transform 0.18s ease;
        }

        .product-filter-mega-tab.is-active {
            color: #224173;
        }

            .product-filter-mega-tab.is-active::after {
                transform: scaleX(1);
            }

    /* بدنه */

    .product-filter-mega-body {
        min-height: 0;
        overflow: hidden;
        background: #ffffff;
    }

    .product-filter-mega-pane {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: none;
        overflow: hidden;
    }

        .product-filter-mega-pane.is-active {
            display: block;
        }

    /* دسته‌بندی */

    .product-filter-category-layout {
        width: 100%;
        height: 100%;
        min-height: 0;
        display: grid;
        grid-template-columns: 108px minmax(0, 1fr);
        direction: rtl;
    }

    .product-filter-category-rail {
        min-width: 0;
        height: 100%;
        padding: 5px 0 24px;
        overflow-x: hidden;
        overflow-y: auto;
        background: #f5f6f7;
        border-left: 1px solid #e5e7eb;
        scrollbar-width: none;
    }

        .product-filter-category-rail::-webkit-scrollbar {
            display: none;
        }

    .product-filter-category-rail-item {
        position: relative;
        width: 100%;
        min-height: 78px;
        padding: 8px 5px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 7px;
        border: 0;
        border-bottom: 1px solid #e6e8eb;
        background: transparent;
        color: #334155;
        font-family: inherit;
        font-size: 0.66rem;
        font-weight: 850;
        line-height: 1.55;
        text-align: center;
        cursor: pointer;
    }

        .product-filter-category-rail-item::before {
            content: "";
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            width: 3px;
            background: #224173;
            transform: scaleY(0);
        }

        .product-filter-category-rail-item.is-active {
            background: #ffffff;
            color: #224173;
        }

            .product-filter-category-rail-item.is-active::before {
                transform: scaleY(1);
            }

    .product-filter-category-rail-icon {
        width: 35px;
        height: 35px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 1px solid #dfe4ea;
        border-radius: 10px;
        background: #ffffff;
        color: #475569;
        font-size: 0.95rem;
    }

    .product-filter-category-rail-item.is-active
    .product-filter-category-rail-icon {
        border-color: rgba(34, 65, 115, 0.25);
        background: #eef3fa;
        color: #224173;
    }

    .product-filter-category-content {
        min-width: 0;
        height: 100%;
        padding: 0 11px 26px;
        overflow-x: hidden;
        overflow-y: auto;
        background: #ffffff;
    }

    .product-filter-category-panel {
        display: none;
    }

        .product-filter-category-panel.is-active {
            display: block;
        }

    .product-filter-category-panel-header {
        position: sticky;
        top: 0;
        z-index: 4;
        min-height: 66px;
        padding: 11px 0 9px;
        display: flex;
        align-items: center;
        background: rgba(255, 255, 255, 0.97);
        border-bottom: 1px solid #eef1f4;
        backdrop-filter: blur(10px);
    }

        .product-filter-category-panel-header > div {
            display: flex;
            flex-direction: column;
            gap: 3px;
        }

        .product-filter-category-panel-header strong {
            color: #111827;
            font-size: 0.89rem;
            font-weight: 950;
        }

        .product-filter-category-panel-header span {
            color: #94a3b8;
            font-size: 0.61rem;
            font-weight: 700;
        }

    .product-filter-category-groups {
        padding: 12px 0 24px;
        display: flex;
        flex-direction: column;
        gap: 17px;
    }

    .product-filter-category-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .product-filter-category-group-title {
        min-height: 30px;
        display: flex;
        align-items: center;
        gap: 7px;
        color: #111827;
        font-size: 0.76rem;
        font-weight: 950;
    }

        .product-filter-category-group-title::before {
            content: "";
            width: 3px;
            height: 17px;
            flex: 0 0 auto;
            border-radius: 999px;
            background: #224173;
        }

    .product-filter-category-option-list {
        display: flex;
        flex-direction: column;
        gap: 7px;
    }

    /* گزینه تک‌انتخابی */

    .product-filter-single-option {
        width: 100%;
        min-height: 48px;
        padding: 9px 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        border: 1px solid #edf0f3;
        border-radius: 11px;
        background: #ffffff;
        color: #334155;
        font-family: inherit;
        text-align: right;
        text-decoration: none;
        cursor: pointer;
        transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, opacity 0.16s ease;
    }

        .product-filter-single-option:active {
            border-color: rgba(34, 65, 115, 0.32);
            background: #f8fafc;
        }

        .product-filter-single-option.is-selected {
            border-color: rgba(34, 65, 115, 0.4);
            background: #eef3fa;
            color: #17345f;
        }

    .product-filter-section-option {
        min-height: 52px;
        border-color: rgba(34, 65, 115, 0.2);
        background: #f8fafc;
    }

    .product-filter-group-main-option {
        background: #fafafa;
    }

    .product-filter-option-copy {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

        .product-filter-option-copy strong {
            overflow: hidden;
            color: inherit;
            font-size: 0.74rem;
            font-weight: 850;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

    .product-filter-option-arrow {
        width: 25px;
        min-width: 25px;
        height: 25px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        background: #f1f5f9;
        color: #64748b;
        font-size: 0.65rem;
    }

    .product-filter-single-option.is-selected
    .product-filter-option-arrow {
        background: #224173;
        color: #ffffff;
    }

    .product-filter-single-option.is-loading {
        opacity: 0.6;
        pointer-events: none;
    }

        .product-filter-single-option.is-loading
        .product-filter-option-arrow i {
            display: none;
        }

        .product-filter-single-option.is-loading
        .product-filter-option-arrow::after {
            content: "";
            width: 12px;
            height: 12px;
            border: 2px solid rgba(34, 65, 115, 0.25);
            border-top-color: #224173;
            border-radius: 50%;
            animation: product-filter-loading 0.7s linear infinite;
        }

    @keyframes product-filter-loading {
        to {
            transform: rotate(360deg);
        }
    }

    /* برندها */

    .product-filter-brand-shell {
        width: 100%;
        height: 100%;
        padding: 10px 12px 28px;
        overflow-x: hidden;
        overflow-y: auto;
        background: #ffffff;
    }

    .product-filter-brand-search {
        position: sticky;
        top: 0;
        z-index: 4;
        min-height: 48px;
        padding: 5px 10px;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        align-items: center;
        gap: 8px;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        background: rgba(248, 250, 252, 0.98);
        backdrop-filter: blur(10px);
    }

        .product-filter-brand-search i {
            color: #64748b;
        }

        .product-filter-brand-search input {
            width: 100%;
            min-width: 0;
            height: 36px;
            border: 0;
            outline: 0;
            background: transparent;
            color: #111827;
            font-family: inherit;
            font-size: 0.75rem;
            font-weight: 750;
        }

        .product-filter-brand-search > span {
            color: #94a3b8;
            font-size: 0.61rem;
            font-weight: 750;
            white-space: nowrap;
        }

    .product-filter-brand-all,
    .product-filter-brand-card {
        position: relative;
        width: 100%;
        min-width: 0;
        min-height: 72px;
        padding: 9px;
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr) 25px;
        align-items: center;
        gap: 8px;
        border: 1px solid #e8ebef;
        border-radius: 12px;
        background: #ffffff;
        color: #334155;
        font-family: inherit;
        text-align: right;
        cursor: pointer;
    }

    .product-filter-brand-all {
        margin-top: 10px;
    }

        .product-filter-brand-card.is-selected,
        .product-filter-brand-all.is-selected {
            border-color: rgba(34, 65, 115, 0.4);
            background: #eef3fa;
            color: #17345f;
        }

    .product-filter-brand-grid {
        margin-top: 9px;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .product-filter-brand-logo {
        width: 42px;
        height: 42px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        border: 1px solid #edf0f3;
        border-radius: 10px;
        background: #ffffff;
        color: #224173;
    }

        .product-filter-brand-logo img {
            width: 100%;
            height: 100%;
            padding: 4px;
            display: block;
            object-fit: contain;
        }

    .product-filter-brand-initial {
        color: #224173;
        font-size: 1rem;
        font-weight: 950;
    }

    .product-filter-brand-copy {
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

        .product-filter-brand-copy strong {
            overflow: hidden;
            color: inherit;
            font-size: 0.72rem;
            font-weight: 900;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .product-filter-brand-copy small {
            color: #94a3b8;
            font-size: 0.58rem;
            font-weight: 700;
        }

    .product-filter-brand-card.is-loading {
        opacity: 0.6;
        pointer-events: none;
    }

    /* خالی */

    .product-filter-mega-empty {
        min-height: 180px;
        padding: 24px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 9px;
        color: #94a3b8;
        text-align: center;
    }

        .product-filter-mega-empty i {
            font-size: 1.6rem;
        }

        .product-filter-mega-empty strong {
            color: #475569;
            font-size: 0.8rem;
            font-weight: 900;
        }

        .product-filter-mega-empty span {
            font-size: 0.66rem;
        }
}

/* موبایل کوچک */

@media (max-width: 390px) {

    .product-filter-category-layout {
        grid-template-columns: 98px minmax(0, 1fr);
    }

    .product-filter-category-rail-item {
        min-height: 73px;
        font-size: 0.61rem;
    }

    .product-filter-category-rail-icon {
        width: 32px;
        height: 32px;
        font-size: 0.88rem;
    }

    .product-filter-category-content {
        padding-right: 8px;
        padding-left: 8px;
    }

    .product-filter-brand-grid {
        grid-template-columns: 1fr;
    }
}

/* حالت تاریک */

@media (max-width: 991.98px) {

    body.dark-mode
    .product-filter-mega-modal,
    body.dark-mode
    .product-filter-mega-shell,
    body.dark-mode
    .product-filter-mega-header,
    body.dark-mode
    .product-filter-mega-tabs,
    body.dark-mode
    .product-filter-mega-body,
    body.dark-mode
    .product-filter-category-content,
    body.dark-mode
    .product-filter-brand-shell {
        background: #0f172a;
    }

    body.dark-mode
    .product-filter-category-rail {
        background: #111c30;
        border-color: #243047;
    }

    body.dark-mode
    .product-filter-category-rail-item {
        color: #cbd5e1;
        border-color: #243047;
    }

        body.dark-mode
        .product-filter-category-rail-item.is-active {
            background: #0f172a;
            color: #93c5fd;
        }

    body.dark-mode
    .product-filter-category-panel-header {
        background: rgba(15, 23, 42, 0.97);
        border-color: #243047;
    }

        body.dark-mode
        .product-filter-category-panel-header strong,
        body.dark-mode
        .product-filter-category-group-title {
            color: #f8fafc;
        }

    body.dark-mode
    .product-filter-single-option,
    body.dark-mode
    .product-filter-brand-card,
    body.dark-mode
    .product-filter-brand-all {
        border-color: #26354d;
        background: #111c30;
        color: #cbd5e1;
    }

        body.dark-mode
        .product-filter-single-option.is-selected,
        body.dark-mode
        .product-filter-brand-card.is-selected {
            border-color: #60a5fa;
            background: #172c4d;
            color: #f8fafc;
        }

    body.dark-mode
    .product-filter-brand-search,
    body.dark-mode
    .product-filter-mega-search-trigger {
        border-color: #26354d;
        background: #111c30;
        color: #94a3b8;
    }

        body.dark-mode
        .product-filter-brand-search input {
            color: #f8fafc;
        }
}

/* =========================================================
   Hide mobile menu controls while product mega filter is open
   ========================================================= */

@media (max-width: 991.98px) {

    /*
     * مگامنو باید بالاتر از هدر،
     * دکمه منو و Bottom Bar قرار بگیرد.
     */
    .product-filter-mega-modal {
        z-index: 999999 !important;
        isolation: isolate;
    }

    /*
     * انیمیشن مخفی و ظاهر شدن دکمه منوی هدر
     */
    #siteHeader .dangaah-mobile-menu-button,
    #siteHeader .premium-menu-toggler {
        transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease !important;
    }

    /*
     * انیمیشن نوار پایین موبایل
     */
    .mobile-bottom-bar,
    .product-mobile-bottom-bar {
        transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease !important;
    }

    /*
     * هنگام باز بودن مگامنو:
     * دکمه همبرگری هدر مخفی شود.
     */
    body.product-filter-mega-open
    #siteHeader
    .dangaah-mobile-menu-button,
    body.product-filter-mega-open
    #siteHeader
    .premium-menu-toggler {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translateY(-8px) scale(0.92) !important;
        z-index: -1 !important;
    }

    /*
     * هنگام باز بودن مگامنو:
     * Bottom Bar نیز روی مودال قرار نگیرد.
     */
    body.product-filter-mega-open
    .mobile-bottom-bar,
    body.product-filter-mega-open
    .product-mobile-bottom-bar {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transform: translateY(110%) !important;
        z-index: -1 !important;
    }

    /*
     * جلوگیری از ظاهرشدن سایر عناصر ثابت هدر
     * روی مودال فیلتر.
     */
    body.product-filter-mega-open
    #siteHeader
    .dangaah-header-actions {
        z-index: 1 !important;
    }
}