/**
 * Mobile bottom navigation + stacking with sticky bars / FABs
 */
:root {
    --mbnav-h: 0px;
    --mbnav-sticky-cart-h: 62px;
    --mbnav-compare-bar-h: 88px;
}

@media screen and (max-width: 995px) {
    body.has-mobile-bottom-nav {
        --mbnav-h: 58px;
        padding-bottom: calc(var(--mbnav-h) + env(safe-area-inset-bottom, 0px));
    }

    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9990;
        height: calc(var(--mbnav-h) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(255, 255, 255, 0.98);
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        direction: rtl;
    }

    .mbnav-item {
        flex: 1 1 25%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-width: 0;
        padding: 6px 4px 4px;
        border: none;
        background: transparent;
        color: #9ca3af;
        text-decoration: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        transition: color 0.15s ease;
    }

    .mbnav-item:active {
        opacity: 0.85;
    }

    .mbnav-icon {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 26px;
        height: 26px;
        font-size: 19px;
        line-height: 1;
        color: inherit;
    }

    .mbnav-label {
        font-family: iransans, yekan, tahoma, sans-serif;
        font-size: 10px;
        font-weight: 600;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    .mbnav-item.is-active {
        color: #111827;
    }

    .mbnav-item.is-active .mbnav-icon {
        color: #4285F4;
    }

    .mbnav-item.is-active::after {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 18px;
        height: 2px;
        border-radius: 0 0 2px 2px;
        background: #4285F4;
    }

    .mbnav-badge {
        position: absolute;
        top: -4px;
        left: -6px;
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        border-radius: 999px;
        background: #111827;
        color: #fff;
        font-family: byekan, iransans, sans-serif;
        font-size: 10px;
        line-height: 16px;
        text-align: center;
    }

    /* FABs sit above bottom nav */
    body.has-mobile-bottom-nav .mobile-fab-wrap {
        bottom: calc(var(--mbnav-h) + 14px + env(safe-area-inset-bottom, 0px));
    }

    body.has-mobile-bottom-nav:has(.pd-sticky-cart) .mobile-fab-wrap {
        bottom: calc(var(--mbnav-h) + var(--mbnav-sticky-cart-h) + 10px + env(safe-area-inset-bottom, 0px));
    }

    body.has-mobile-bottom-nav.has-compare-bar .mobile-fab-wrap {
        bottom: calc(var(--mbnav-h) + var(--mbnav-compare-bar-h) + 10px + env(safe-area-inset-bottom, 0px));
    }

    body.has-mobile-bottom-nav.has-compare-bar:has(.pd-sticky-cart) .mobile-fab-wrap {
        bottom: calc(var(--mbnav-h) + var(--mbnav-sticky-cart-h) + var(--mbnav-compare-bar-h) + 8px + env(safe-area-inset-bottom, 0px));
    }

    /* Product detail sticky add-to-cart */
    body.has-mobile-bottom-nav .pd-sticky-cart {
        bottom: calc(var(--mbnav-h) + env(safe-area-inset-bottom, 0px));
        z-index: 9992;
    }

    body.has-mobile-bottom-nav:has(.pd-sticky-cart) .site-footer {
        padding-bottom: calc(var(--mbnav-sticky-cart-h) + var(--mbnav-h) + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Compare floating bar */
    body.has-mobile-bottom-nav.has-compare-bar {
        padding-bottom: calc(var(--mbnav-h) + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.has-mobile-bottom-nav.has-compare-bar #compare_float_bar {
        bottom: calc(var(--mbnav-h) + env(safe-area-inset-bottom, 0px));
        z-index: 9993;
    }

    body.has-mobile-bottom-nav.has-compare-bar:has(.pd-sticky-cart) {
        padding-bottom: calc(var(--mbnav-h) + env(safe-area-inset-bottom, 0px)) !important;
    }

    body.has-mobile-bottom-nav.has-compare-bar:has(.pd-sticky-cart) #compare_float_bar {
        bottom: calc(var(--mbnav-h) + var(--mbnav-sticky-cart-h) + env(safe-area-inset-bottom, 0px));
    }

    /* Product type filter FAB */
    body.has-mobile-bottom-nav .pt-filter-fab {
        bottom: calc(var(--mbnav-h) + 16px + env(safe-area-inset-bottom, 0px));
    }

    body.has-mobile-bottom-nav.has-compare-bar .pt-filter-fab {
        bottom: calc(var(--mbnav-h) + var(--mbnav-compare-bar-h) + 12px + env(safe-area-inset-bottom, 0px));
    }
}

@media screen and (min-width: 996px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}
