/**
 * Sidecart Mobile Fix
 * Stellt sicher, dass Buttons im Sidecart auf Mobile sichtbar sind
 */

/* Mobile Sidecart Height Fix */
@media (max-width: 768px) {
    /* Container Höhe anpassen - Dynamische Viewport Höhe */
    html body #wcc-sidecart-container {
        height: 100% !important;
        height: 100vh !important;
        height: 100dvh !important; /* Dynamic viewport height - passt sich an wenn Browser UI sich versteckt */
        max-height: 100vh !important;
        max-height: 100dvh !important;
        display: flex !important;
        flex-direction: column !important;
        position: fixed !important;
        top: 0 !important;
        bottom: 0 !important;
    }
    
    /* Header bleibt oben */
    html body #wcc-sidecart-container .wcc-sidecart-header {
        flex-shrink: 0 !important;
        position: relative !important;
    }
    
    /* Body scrollbar */
    html body #wcc-sidecart-container .wcc-sidecart-body {
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important; /* Wichtig für Firefox */
        -webkit-overflow-scrolling: touch !important; /* Smooth scrolling auf iOS */
    }
    
    /* Footer bleibt unten sichtbar */
    html body #wcc-sidecart-container .wcc-sidecart-footer {
        flex-shrink: 0 !important;
        max-height: 40vh !important; /* Maximal 40% der Höhe */
        overflow-y: auto !important;
        position: sticky !important;
        bottom: 0 !important;
        background: #fff !important;
        z-index: 10 !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
    }
    
    /* Totals kompakter */
    html body #wcc-sidecart-container .wcc-sidecart-totals {
        padding: 10px 15px !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-total-row {
        padding: 8px 0 !important;
    }
    
    /* Footer Bottom mit Buttons */
    html body #wcc-sidecart-container .wcc-sidecart-footer-bottom {
        padding: 10px 15px 15px !important;
        position: relative !important;
        background: #fff !important;
    }
    
    /* Button Container immer sichtbar */
    html body #wcc-sidecart-container .wcc-sidecart-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
    }
    
    /* Buttons volle Breite auf Mobile */
    html body #wcc-sidecart-container .wcc-sidecart-btn,
    html body #wcc-sidecart-container .wcc-btn-secondary,
    html body #wcc-sidecart-container .wcc-btn-primary {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 15px !important;
        min-height: 48px !important; /* Touch-friendly */
    }
    
    /* Coupon Section kompakter */
    html body #wcc-sidecart-container .wcc-sidecart-coupon-section {
        margin-bottom: 10px !important;
    }
    
    /* Coupon Form responsiv */
    html body #wcc-sidecart-container .wcc-sidecart-coupon-form {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-coupon-input {
        width: 100% !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-coupon-btn {
        width: 100% !important;
    }
    
    /* Merged Coupon auf Mobile trotzdem untereinander */
    html body #wcc-sidecart-container .wcc-sidecart-coupon-merged {
        flex-direction: row !important; /* Behalte nebeneinander wenn gewünscht */
    }
    
    /* Free Shipping Info kompakter */
    html body #wcc-sidecart-container .wcc-free-shipping-info {
        padding: 10px !important;
        margin-bottom: 10px !important;
        font-size: 13px !important;
    }
    
    /* Progress Bar kleiner */
    html body #wcc-sidecart-container .wcc-shipping-progress {
        height: 6px !important;
    }
}

/* Extra kleine Screens (< 375px) */
@media (max-width: 375px) {
    /* Noch kompaktere Abstände */
    html body #wcc-sidecart-container .wcc-sidecart-header {
        padding: 15px !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-title {
        font-size: 16px !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-footer-bottom {
        padding: 10px !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-btn {
        padding: 12px 16px !important;
        font-size: 14px !important;
        min-height: 44px !important;
    }
    
    /* Sidecart width auf kleinen Screens */
    html body #wcc-sidecart-container {
        width: 100% !important;
        right: -100% !important;
    }
    
    html body #wcc-sidecart-container.active {
        right: 0 !important;
    }
}

/* iOS Safari Fix für Footer Position */
@supports (-webkit-touch-callout: none) {
    html body #wcc-sidecart-container {
        height: -webkit-fill-available !important;
        min-height: -webkit-fill-available !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-footer {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
}

/* Fallback für Browser die dvh nicht unterstützen */
@supports not (height: 100dvh) {
    html body #wcc-sidecart-container {
        height: calc(var(--vh, 1vh) * 100) !important;
    }
}

/* Landscape Mode auf Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    html body #wcc-sidecart-container .wcc-sidecart-footer {
        max-height: 50vh !important; /* Mehr Platz im Landscape */
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-body {
        max-height: 50vh !important;
    }
}

/* Debug: Zeige Scrollbar auf Mobile für bessere UX */
@media (max-width: 768px) {
    html body #wcc-sidecart-container .wcc-sidecart-body::-webkit-scrollbar,
    html body #wcc-sidecart-container .wcc-sidecart-footer::-webkit-scrollbar {
        width: 4px !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-body::-webkit-scrollbar-track,
    html body #wcc-sidecart-container .wcc-sidecart-footer::-webkit-scrollbar-track {
        background: #f1f1f1 !important;
    }
    
    html body #wcc-sidecart-container .wcc-sidecart-body::-webkit-scrollbar-thumb,
    html body #wcc-sidecart-container .wcc-sidecart-footer::-webkit-scrollbar-thumb {
        background: #888 !important;
        border-radius: 2px !important;
    }
}