:root {
    --cart-mobile-header-height: 56px;
}

.cart-mobile-header {
    display: none;
}

@media (max-width: 991.98px) {
    .cart-mobile-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1030;
        display: block;
        width: 100%;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 3px rgba(0, 0, 0, .04);
        -webkit-tap-highlight-color: transparent;
    }

    .cart-mobile-header__row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        width: 100%;
        padding: 12px 20px;
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        box-sizing: border-box;
        background: #fff;
    }

    .cart-mobile-header__heading {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
        min-width: 0;
    }

    .cart-mobile-header__title {
        margin: 0;
        font-size: 1rem;
        font-weight: 600;
        line-height: 1.5;
        color: #0c0c0c;
        white-space: nowrap;
    }

    .cart-mobile-header__count {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        flex-shrink: 0;
        font-size: .8125rem;
        font-weight: 500;
        line-height: 1.4;
        color: #81858b;
        white-space: nowrap;
    }

    .cart-mobile-header__actions {
        display: flex;
        align-items: center;
        gap: 16px;
        flex-shrink: 0;
    }

    .cart-mobile-header__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 4px;
        border: none;
        background: transparent;
        border-radius: 8px;
        color: #333;
        cursor: pointer;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
    }

    .cart-mobile-header__btn:disabled {
        cursor: default;
        opacity: 1;
    }

    .cart-mobile-header__btn:active:not(:disabled) {
        transform: scale(0.92);
    }

    .cart-mobile-header__btn svg {
        width: 24px;
        height: 24px;
        fill: currentColor;
        display: block;
    }

    /* هدر مراحل ارسال / پرداخت */
    .cart-mobile-header--step {
        box-shadow: none;
        border-bottom: 1px solid #f0f0f1;
    }

    .cart-mobile-header__row--step {
        justify-content: flex-start;
        padding: 16px 20px;
        padding-top: calc(16px + env(safe-area-inset-top, 0px));
    }

    .cart-mobile-header__back-link {
        display: inline-flex;
        align-items: center;
        gap: 20px;
        margin: 0;
        padding: 0;
        color: #0c0c0c;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        max-width: 100%;
    }

    .cart-mobile-header__back-link:active {
        opacity: 0.7;
    }

    .cart-mobile-header__back-icon {
        display: inline-flex;
        flex-shrink: 0;
        color: #424750;
    }

    .cart-mobile-header__back-icon svg {
        width: 24px;
        height: 24px;
        display: block;
        fill: currentColor;
    }

    /* فاصله محتوا زیر هدر ثابت */
    body:has(.cart-mobile-header) .cart-checkout {
        padding-top: calc(var(--cart-mobile-header-height) + env(safe-area-inset-top, 0px) + 1rem) !important;
        padding-bottom: 1rem !important;
    }

    body:has(.cart-mobile-header) .cart-checkout > .container {
        padding-inline: 16px;
    }

    body:has(.cart-mobile-header) .cart-card-list {
        gap: 12px;
        margin-bottom: 16px;
    }

    body:has(.cart-mobile-header) .cart-checkout .col-md-4 {
        margin-top: 16px;
    }

    body:has(.cart-mobile-header) .empty-cart-page-container {
        min-height: calc(100dvh - var(--cart-mobile-header-height, 56px) - env(safe-area-inset-top, 0px) - 70px - env(safe-area-inset-bottom, 0px));
    }

    body:has(.cart-mobile-header) .empty-cart-container {
        padding: 1.5rem 1rem;
    }

    /* ارسال / پرداخت: فضا برای فوتر ثابت پایین */
    body:has(.cart-mobile-header--step):has(.mobile-checkout-footer) {
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
    }
}

@media (min-width: 992px) {
    .cart-mobile-header {
        display: none !important;
    }
}
