/**
 * Mobile Cart Button - Lieferando Flat Design
 * Clean, modern, flat design inspired by Lieferando
 */

/* ============================================
   MOBILE CART BUTTON - Robust iOS/Android
   ============================================ */
.mobile-cart-btn, #mobileCartBtn {
    position: fixed;
    /* Safe Area Support für iOS */
    bottom: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    display: none; /* Hidden by default, shown via JS */
    align-items: center;
    justify-content: center;
    padding: 14px 24px;
    min-width: 200px;
    max-width: calc(100% - 40px);
    /* Mindesthöhe für Touch */
    min-height: 54px;

    /* Flat Design with subtle gradient */
    background: linear-gradient(135deg, #00AA00 0%, #009900 100%);
    color: white;
    border: none;
    border-radius: 12px;

    /* Typography */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.3px;

    /* Shadow for visibility */
    box-shadow: 0 4px 15px rgba(0, 170, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.15);

    /* Layout */
    z-index: 998; /* Unter Cart Footer aber über Content */
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* GPU Acceleration */
    -webkit-transform: translateX(-50%) translateZ(0);
    transform: translateX(-50%) translateZ(0);
}

/* Hover State */
.mobile-cart-btn:hover, #mobileCartBtn:hover {
    background: linear-gradient(135deg, #009900 0%, #008800 100%);
    box-shadow: 0 6px 20px rgba(0, 170, 0, 0.5), 0 3px 10px rgba(0, 0, 0, 0.2);
    transform: translateX(-50%) translateY(-2px) translateZ(0);
}

/* Active State */
.mobile-cart-btn:active, #mobileCartBtn:active {
    background: linear-gradient(135deg, #008800 0%, #007700 100%);
    box-shadow: 0 2px 8px rgba(0, 170, 0, 0.4);
    transform: translateX(-50%) translateY(0) scale(0.98) translateZ(0);
}

/* Cart Info Container */
.mobile-cart-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
}

/* Cart Count Badge */
.mobile-cart-count {
    background-color: white;
    color: #00AA00;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 14px;
    min-width: 24px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Cart Total */
.mobile-cart-total {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* Cart Icon */
.mobile-cart-btn i, #mobileCartBtn i {
    font-size: 20px;
    margin-right: 8px;
}

/* Warenkorb Text */
.mobile-cart-text {
    display: inline-block;
    margin: 0 8px;
}

/* Media Queries */
@media (max-width: 1200px) {
    .mobile-cart-btn, #mobileCartBtn {
        display: flex !important; /* Show on tablets and mobile */
    }
}

@media (max-width: 680px) {
    .mobile-cart-btn, #mobileCartBtn {
        bottom: 15px;
        bottom: calc(15px + env(safe-area-inset-bottom, 0px));
        padding: 12px 20px !important;
        min-width: 180px;
        font-size: 15px;
        min-height: 50px;
    }

    .mobile-cart-count {
        font-size: 13px;
        padding: 2px 6px;
    }

    .mobile-cart-total {
        font-size: 15px;
    }
}

/* Extra small screens (iPhone SE) */
@media (max-width: 375px) {
    .mobile-cart-btn, #mobileCartBtn {
        bottom: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding: 10px 16px !important;
        min-width: 160px;
        font-size: 14px;
        min-height: 48px;
    }
}

/* Animation when cart updates */
@keyframes cartPulse {
    0% {
        transform: translateX(-50%) scale(1);
    }
    50% {
        transform: translateX(-50%) scale(1.05);
    }
    100% {
        transform: translateX(-50%) scale(1);
    }
}

.mobile-cart-btn.cart-updated, #mobileCartBtn.cart-updated {
    animation: cartPulse 0.3s ease;
}

/* Hide on desktop */
@media (min-width: 1201px) {
    .mobile-cart-btn, #mobileCartBtn {
        display: none !important;
    }
}

/* Ensure button stays above other elements */
.mobile-cart-btn, #mobileCartBtn {
    z-index: 999;
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    .mobile-cart-btn, #mobileCartBtn {
        -webkit-appearance: none;
    }
}

/* Mobile Cart Sidebar Toggle Styles */
@media (max-width: 1200px) {
    /* Cart Sidebar Mobile Styles */
    .cart-sidebar, #cartSidebar {
        position: fixed !important;
        top: 0;
        right: -100%; /* Hidden by default */
        width: 100%;
        max-width: 400px;
        height: 100vh;
        transition: right 0.3s ease-in-out;
        z-index: 1001;
        background: white;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    /* When open on mobile */
    .cart-sidebar.mobile-open, #cartSidebar.mobile-open {
        right: 0; /* Slide in from right */
    }
    
    /* Overlay for mobile cart */
    .cart-sidebar.mobile-open::before, #cartSidebar.mobile-open::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }
    
    /* Ensure content scrolls but summary stays fixed */
    .cart-sidebar .cart-content {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Keep checkout summary at bottom, above browser UI */
    .cart-sidebar .cart-summary {
        position: sticky;
        bottom: 0;
        background: white;
        border-top: 2px solid #f1f5f9;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        padding-bottom: env(safe-area-inset-bottom, 20px); /* iOS safe area */
        z-index: 10;
    }
    
    /* Additional padding for iOS devices */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .cart-sidebar .cart-summary {
            padding-bottom: calc(16px + env(safe-area-inset-bottom));
        }
    }
}

/* On smaller screens, make cart full width */
@media (max-width: 480px) {
    .cart-sidebar, #cartSidebar {
        max-width: 100%;
    }
}