/* ============================================
   Cart Sidebar Mobile Optimizations
   Robust für iOS und Android
   ============================================ */

/* Smooth scroll for cart items */
.cart-items-wrapper {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Fix cart footer visibility on mobile */
@media (max-width: 768px) {
    .cart-sidebar {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height */
        max-height: 100vh;
        max-height: 100dvh;
    }

    .cart-items-wrapper {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 200px; /* Space for fixed footer */
        padding-bottom: calc(200px + env(safe-area-inset-bottom, 0px));
        -webkit-overflow-scrolling: touch;
    }

    /* ============================================
       FIXED CART FOOTER - iOS/Android Safe Area
       ============================================ */
    .cart-footer {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: #ffffff !important;
        border-top: 1px solid #e5e5e5;
        padding: 12px 15px;
        /* iOS Safe Area Support */
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding-bottom: calc(12px + constant(safe-area-inset-bottom)); /* iOS 11 */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        z-index: 9999 !important;
        /* Prevent scroll bounce on iOS */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }

    /* Fallback für ältere iOS Versionen */
    @supports (padding-bottom: constant(safe-area-inset-bottom)) {
        .cart-footer {
            padding-bottom: calc(12px + constant(safe-area-inset-bottom));
        }
    }

    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .cart-footer {
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
        }
    }

    /* ============================================
       CHECKOUT BUTTON - Prominent und gut sichtbar
       ============================================ */
    .checkout-btn {
        width: 100% !important;
        padding: 16px 20px !important;
        font-size: 17px !important;
        font-weight: 700 !important;
        border-radius: 12px !important;
        background: linear-gradient(135deg, #00b900 0%, #00a810 100%) !important;
        color: white !important;
        border: none !important;
        box-shadow: 0 4px 15px rgba(0, 185, 0, 0.4) !important;
        transition: all 0.2s ease !important;
        /* Touch-Optimierung */
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        cursor: pointer;
        /* Mindesthöhe für Touch */
        min-height: 54px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .checkout-btn:not(:disabled):active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0, 185, 0, 0.4) !important;
    }

    .checkout-btn:disabled {
        background: #cccccc !important;
        box-shadow: none !important;
        opacity: 0.7;
    }

    /* Ensure cart total is visible */
    .cart-total-section {
        margin-bottom: 12px;
        padding: 12px 0;
        border-top: 1px solid #f0f0f0;
    }

    .cart-total-section .total-row {
        display: flex;
        justify-content: space-between;
        font-size: 16px;
        font-weight: 600;
    }

    /* Prevent content from being hidden behind footer */
    .cart-content {
        padding-bottom: 220px;
        padding-bottom: calc(220px + env(safe-area-inset-bottom, 0px));
    }

    /* Better touch targets for mobile */
    .cart-item-quantity button {
        min-width: 40px;
        min-height: 40px;
        font-size: 18px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }

    .cart-item-remove {
        min-width: 36px;
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }
}

/* ============================================
   EXTRA SMALL SCREENS (iPhone SE, etc.)
   ============================================ */
@media (max-width: 375px) {
    .checkout-btn {
        padding: 14px 16px !important;
        font-size: 15px !important;
        min-height: 50px;
    }

    .cart-items-wrapper {
        padding-bottom: 180px;
        padding-bottom: calc(180px + env(safe-area-inset-bottom, 0px));
    }
}

/* ============================================
   LANDSCAPE MODE
   ============================================ */
@media (max-width: 768px) and (orientation: landscape) {
    .cart-footer {
        padding: 10px 15px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .checkout-btn {
        padding: 12px 16px !important;
        min-height: 48px;
    }
}