/* ===================================================
   باتم‌بار و کشوی اختصاصی دسته‌بندی‌های موبایل rpkala
   Mobile Bottom Navigation & Categories Drawer
   =================================================== */

/* پنهان‌سازی کامل در دسکتاپ */
.rp-bottom-bar,
.rp-drawer-overlay,
.rp-categories-drawer {
    display: none;
}

/* فعال‌سازی اختصاصی در نمایشگرهای موبایل */
@media screen and (max-width: 768px) {

    /* رزرو فضای کافی در انتهای صفحه برای باتم‌بار */
    body {
        padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* قفل اسکرول بدنه هنگام باز بودن کشوی دسته‌بندی */
    body.rp-drawer-opened {
        overflow: hidden !important;
        touch-action: none !important;
    }

    /* ===================================================
       ۱. نوار باتم‌بار موبایل
       =================================================== */
    .rp-bottom-bar {
        display: block !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 99990 !important;
        background-color: #ffffff !important;
        border-top: 1px solid #f0f2f5 !important;
        border-bottom: none !important;
        border-left: none !important;
        border-right: none !important;
        box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.05) !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
        margin: 0 !important;
        direction: rtl !important;
        box-sizing: border-box !important;
        -webkit-tap-highlight-color: transparent !important;
        user-select: none !important;
    }

    .rp-bottom-bar-inner {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        align-items: center !important;
        justify-content: space-around !important;
        height: 60px !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        padding: 0 4px !important;
        box-sizing: border-box !important;
    }

    .rp-bottom-bar-item {
        position: relative !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        box-shadow: none !important;
        text-decoration: none !important;
        color: #6a7282 !important; /* رنگ پیش‌فرض آیکون‌ها و متون */
        font-family: inherit !important;
        cursor: pointer !important;
        padding: 4px 0 !important;
        margin: 0 !important;
        transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.15s ease !important;
        box-sizing: border-box !important;
    }

    .rp-bottom-bar-item:active {
        transform: scale(0.92) !important;
    }

    .rp-bottom-bar-icon {
        position: relative !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 26px !important;
        height: 26px !important;
        color: #6a7282 !important;
        transition: color 0.2s ease !important;
        background: none !important;
        border: none !important;
        box-shadow: none !important;
    }

    .rp-bottom-bar-icon .rp-bb-svg {
        display: block !important;
        width: 24px !important;
        height: 24px !important;
        stroke: #6a7282 !important;
        transition: stroke 0.2s ease, transform 0.2s ease !important;
    }

    .rp-bottom-bar-label {
        font-size: 11px !important;
        line-height: 1.25 !important;
        font-weight: 500 !important;
        margin-top: 3px !important;
        color: #6a7282 !important;
        text-align: center !important;
        white-space: nowrap !important;
        transition: color 0.2s ease, font-weight 0.2s ease !important;
        letter-spacing: -0.01em !important;
    }

    /* وضعیت فعال آیتم‌های باتم‌بار */
    .rp-bottom-bar-item.is-active {
        color: #23437c !important;
    }

    .rp-bottom-bar-item.is-active .rp-bottom-bar-icon {
        color: #23437c !important;
    }

    .rp-bottom-bar-item.is-active .rp-bottom-bar-icon .rp-bb-svg {
        stroke: #23437c !important;
        stroke-width: 2.15px !important;
    }

    .rp-bottom-bar-item.is-active .rp-bottom-bar-label {
        color: #23437c !important;
        font-weight: 700 !important;
    }

    /* بج سبد خرید در باتم‌بار */
    .rp-bottom-bar-icon.rp-cart-icon .rp-cart-badge {
        position: absolute !important;
        top: -7px !important;
        left: -8px !important;
        min-width: 17px !important;
        height: 17px !important;
        padding: 0 4px !important;
        background-color: #23437c !important;
        color: #ffffff !important;
        font-size: 10px !important;
        font-weight: 800 !important;
        border: 2px solid #ffffff !important;
        border-radius: 9999px !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
        box-sizing: border-box !important;
        z-index: 5 !important;
    }

    .rp-bottom-bar-icon.rp-cart-icon .rp-cart-badge.rp-cart-badge--hidden,
    .rp-bottom-bar-icon.rp-cart-icon .rp-cart-badge[data-count="0"],
    .rp-bottom-bar-icon.rp-cart-icon .rp-cart-badge:empty {
        display: none !important;
    }

    /* ===================================================
       ۲. لایه پس‌زمینه تار (Overlay)
       =================================================== */
    .rp-drawer-overlay {
        display: block !important;
        position: fixed !important;
        inset: 0 !important;
        background-color: rgba(15, 23, 42, 0.6) !important;
        backdrop-filter: blur(5px) !important;
        -webkit-backdrop-filter: blur(5px) !important;
        z-index: 99995 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.45s cubic-bezier(0.32, 0.72, 0, 1), visibility 0.45s ease !important;
        pointer-events: none !important;
    }

    .rp-drawer-overlay.is-visible {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* ===================================================
       ۳. کشوی اختصاصی دسته‌بندی‌های موبایل (Drawer)
       کاملاً مخفی و خارج از دید تا زمان کلیک روی دکمه دسته‌بندی
       =================================================== */
    .rp-categories-drawer {
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100dvh !important;
        background-color: #ffffff !important;
        z-index: 99999 !important;
        transform: translateY(115%) !important; /* کاملاً هدایت‌شده به زیر صفحه */
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: transform 0.48s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.38s ease, visibility 0.48s !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        direction: rtl !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    /* حالت باز بودن کشو */
    .rp-categories-drawer.is-open {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }

    /* هدر کشو */
    .rp-drawer-header {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        height: 60px !important;
        padding: 0 16px !important;
        background-color: #ffffff !important;
        border-bottom: 1px solid #f1f5f9 !important;
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
    }

    .rp-drawer-logo {
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
    }

    .rp-drawer-logo-img,
    .rp-drawer-logo .custom-logo {
        max-height: 38px !important;
        width: auto !important;
        display: block !important;
        object-fit: contain !important;
    }

    .rp-drawer-logo-text {
        font-size: 1.15rem !important;
        font-weight: 800 !important;
        color: #23437c !important;
        line-height: 1 !important;
    }

    /* دکمه بستن در هدر (استایل کاملاً ایزوله و شیک) */
    .rp-drawer-close-btn {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        border-radius: 10px !important;
        background-color: #f1f5f9 !important;
        border: 1px solid #e2e8f0 !important;
        color: #475569 !important;
        text-decoration: none !important;
        cursor: pointer !important;
        padding: 0 !important;
        margin: 0 !important;
        outline: none !important;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
        transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease !important;
        box-sizing: border-box !important;
    }

    .rp-drawer-close-btn .rp-close-svg {
        display: block !important;
        width: 18px !important;
        height: 18px !important;
        stroke: #475569 !important;
        stroke-width: 2.2px !important;
        transition: stroke 0.2s ease !important;
    }

    .rp-drawer-close-btn:hover,
    .rp-drawer-close-btn:active {
        background-color: #e2e8f0 !important;
        border-color: #cbd5e1 !important;
        transform: scale(0.93) !important;
    }

    .rp-drawer-close-btn:hover .rp-close-svg,
    .rp-drawer-close-btn:active .rp-close-svg {
        stroke: #0f172a !important;
    }

    /* بدنه دو ستونه کشو */
    .rp-drawer-body {
        display: flex !important;
        flex: 1 !important;
        overflow: hidden !important;
        background-color: #ffffff !important;
        height: calc(100% - 60px) !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* ستون راست: تب‌های سرگروه */
    .rp-drawer-tabs {
        width: 104px !important;
        min-width: 104px !important;
        max-width: 104px !important;
        flex-shrink: 0 !important;
        background-color: #f8fafc !important;
        border-left: 1px solid #f1f5f9 !important;
        border-right: none !important;
        border-top: none !important;
        border-bottom: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 10px 6px 30px 6px !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    /* پنهان‌سازی اسکرول‌بار ستون راست */
    .rp-drawer-tabs::-webkit-scrollbar {
        display: none !important;
    }
    .rp-drawer-tabs {
        -ms-overflow-style: none !important;
        scrollbar-width: none !important;
    }

    /* تب‌های سرگروه (موبایل، لوازم جانبی، گجت‌های هوشمند، صدا و موسیقی) */
    .rp-drawer-tab-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px 4px 10px 4px !important;
        border-radius: 14px !important;
        border: 1px solid #e2e8f0 !important;
        background-color: #ffffff !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03) !important;
        cursor: pointer !important;
        width: 100% !important;
        text-align: center !important;
        text-decoration: none !important;
        font-family: inherit !important;
        outline: none !important;
        margin: 0 !important;
        transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-sizing: border-box !important;
    }

    .rp-drawer-tab-item:active {
        transform: scale(0.95) !important;
    }

    .rp-tab-icon-box {
        width: 42px !important;
        height: 42px !important;
        min-width: 42px !important;
        min-height: 42px !important;
        border-radius: 10px !important;
        background-color: #f8fafc !important;
        border: 1px solid #edf2f7 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        color: #475569 !important;
        margin-bottom: 5px !important;
        transition: all 0.22s ease !important;
        box-sizing: border-box !important;
    }

    .rp-tab-icon-box .rp-cat-svg {
        width: 22px !important;
        height: 22px !important;
        stroke: #6a7282 !important;
        display: block !important;
        transition: stroke 0.22s ease !important;
    }

    .rp-tab-title {
        font-size: 11px !important;
        font-weight: 600 !important;
        color: #475569 !important;
        line-height: 1.3 !important;
        text-align: center !important;
        display: block !important;
        transition: color 0.22s ease, font-weight 0.22s ease !important;
        word-break: break-word !important;
        white-space: normal !important;
        overflow-wrap: break-word !important;
        width: 100% !important;
    }

    /* ===================================================
       تب فعال سرگروه (Active State)
       =================================================== */
    .rp-drawer-tab-item.is-active {
        background-color: #23437c !important; /* سرمه‌ای برند */
        border-color: #23437c !important;
        box-shadow: 0 4px 12px rgba(35, 67, 124, 0.28) !important;
    }

    .rp-drawer-tab-item.is-active .rp-tab-icon-box {
        background-color: rgba(255, 255, 255, 0.16) !important;
        border-color: transparent !important;
        box-shadow: none !important;
    }

    .rp-drawer-tab-item.is-active .rp-tab-icon-box .rp-cat-svg {
        stroke: #ffffff !important;
    }

    .rp-drawer-tab-item.is-active .rp-tab-title {
        color: #ffffff !important;
        font-weight: 700 !important;
    }

    /* ستون چپ: پنل محتوا و زیردسته‌ها */
    .rp-drawer-content {
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 16px 16px 40px 16px !important;
        background-color: #ffffff !important;
        box-sizing: border-box !important;
    }

    .rp-drawer-panel {
        display: none !important;
    }

    .rp-drawer-panel.is-active {
        display: block !important;
        animation: rpPanelFadeIn 0.25s ease !important;
    }

    @keyframes rpPanelFadeIn {
        from {
            opacity: 0;
            transform: translateY(6px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* دکمه کپسولی بالا: همه [نام دسته] */
    .rp-drawer-all-link {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        width: 100% !important;
        padding: 11px 16px !important;
        background-color: #edf2f9 !important; /* رنگ ملایم برند */
        border: 1px solid #e0ecf8 !important;
        border-radius: 12px !important;
        color: #23437c !important; /* سرمه‌ای برند */
        text-decoration: none !important;
        font-size: 13px !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        margin-bottom: 22px !important;
        transition: background-color 0.2s ease, transform 0.15s ease !important;
        box-sizing: border-box !important;
    }

    .rp-drawer-all-link:active {
        background-color: #e0ecf8 !important;
        transform: scale(0.98) !important;
    }

    .rp-all-arrow-svg {
        stroke: #23437c !important;
        display: block !important;
    }

    /* گروه‌بندی‌های سطح ۲ */
    .rp-drawer-subgroups {
        display: flex !important;
        flex-direction: column !important;
        gap: 22px !important;
    }

    .rp-subgroup-block {
        display: flex !important;
        flex-direction: column !important;
    }

    /* عنوان سرگروه با خط نشانگر سرمه‌ای */
    .rp-subgroup-title {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        text-decoration: none !important;
        color: #1e293b !important;
        margin-bottom: 12px !important;
        font-size: 14px !important;
        font-weight: 800 !important;
        line-height: 1.2 !important;
        transition: color 0.18s ease !important;
    }

    .rp-subgroup-title:hover,
    .rp-subgroup-title:active {
        color: #23437c !important;
    }

    .rp-subgroup-bar {
        width: 4px !important;
        height: 18px !important;
        background-color: #23437c !important; /* خط نشانگر سرمه‌ای */
        border-radius: 3px !important;
        display: inline-block !important;
        flex-shrink: 0 !important;
    }

    .rp-subgroup-name {
        flex: 1 !important;
    }

    /* لیست آیتم‌های نهایی (سطح ۳) */
    .rp-subgroup-list {
        list-style: none !important;
        margin: 0 !important;
        padding: 0 10px 0 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    .rp-subgroup-item {
        margin: 0 !important;
        padding: 0 !important;
    }

    .rp-subgroup-link {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        text-decoration: none !important;
        color: #475569 !important;
        font-size: 13px !important;
        font-weight: 500 !important;
        line-height: 1.3 !important;
        transition: color 0.18s ease, transform 0.18s ease !important;
        padding: 2px 0 !important;
    }

    .rp-bullet-dot {
        width: 6px !important;
        height: 6px !important;
        border-radius: 50% !important;
        background-color: #94a3b8 !important;
        display: inline-block !important;
        flex-shrink: 0 !important;
        transition: background-color 0.18s ease, transform 0.18s ease !important;
    }

    .rp-subgroup-link:hover,
    .rp-subgroup-link:active {
        color: #23437c !important;
        transform: translateX(-3px) !important;
    }

    .rp-subgroup-link:hover .rp-bullet-dot,
    .rp-subgroup-link:active .rp-bullet-dot {
        background-color: #23437c !important;
        transform: scale(1.3) !important;
    }

    .rp-drawer-empty-state,
    .rp-drawer-empty-notice {
        padding: 20px !important;
        text-align: center !important;
        color: #64748b !important;
        font-size: 13px !important;
        background-color: #f8fafc !important;
        border-radius: 12px !important;
        margin-top: 10px !important;
    }
}
