/* =====================================================
   iOS SAFE AREA FIX - Verhindert abgeschnittene Buttons
   Speziell für Apple-Geräte mit Home Indicator
   ===================================================== */

/* KRITISCH: Bottom Safe Area für iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    /* 1. FORMULAR SEKTION - Extra Padding unten */
    #formSection {
        padding-bottom: max(1.5rem, calc(1rem + env(safe-area-inset-bottom))) !important;
    }
    
    /* 2. SUBMIT BUTTON - Verhindert Abschneiden */
    #submitBtn {
        margin-bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
    }
    
    /* 3. ALLE FIXED BOTTOM ELEMENTS */
    [class*="fixed"][class*="bottom"],
    .fixed.bottom-0,
    #scanActionButtons,
    #scanImportProgress {
        padding-bottom: max(1rem, calc(0.5rem + env(safe-area-inset-bottom))) !important;
    }
    
    /* 4. APP SECTION CONTAINER */
    #appSection {
        padding-bottom: max(2rem, calc(1rem + env(safe-area-inset-bottom))) !important;
    }
    
    /* 5. MODALS AM UNTEREN RAND */
    #progressModal > div,
    #reviewModal > div,
    #quoteModal > div {
        padding-bottom: max(2rem, calc(1rem + env(safe-area-inset-bottom))) !important;
    }
    
    /* 6. BODY - Genereller Safe Area Support */
    body {
        padding-bottom: max(1rem, env(safe-area-inset-bottom)) !important;
    }
}

/* FALLBACK für ältere iOS Versionen */
#formSection {
    padding-bottom: 1.5rem;
}

#submitBtn {
    margin-bottom: 0.5rem;
}

#appSection {
    padding-bottom: 2rem;
}

/* MOBILE VIEWPORT OPTIMIZATION */
@media (max-width: 768px) {
    /* Verhindert horizontales Scrollen */
    body,
    #appSection,
    #formSection,
    form {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }
    
    /* iOS Zoom Prevention - Font Size >= 16px */
    input,
    select,
    textarea,
    button {
        font-size: 16px !important;
    }
    
    /* Bessere Touch Targets auf Mobile */
    button,
    .icon-btn,
    .feature-btn {
        min-height: 44px !important;
        min-width: 44px !important;
    }
}

/* SPEZIELLE iOS SAFARI FIXES */
@supports (-webkit-touch-callout: none) {
    /* Nur für iOS Safari */
    
    /* Fix für Fixed Elements am Bottom */
    .fixed.bottom-0,
    [style*="bottom: 0"] {
        bottom: env(safe-area-inset-bottom) !important;
    }
}

/* ZUSÄTZLICHE SAFE AREA SUPPORT */
@supports (padding: env(safe-area-inset-bottom)) {
    /* Alle Buttons die am unteren Rand sein könnten */
    button[type="submit"],
    .submit-btn,
    .action-btn-bottom {
        margin-bottom: calc(0.5rem + env(safe-area-inset-bottom)) !important;
    }
    
    /* Footer Navigation */
    footer,
    nav.bottom-nav {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
    }
}

/* DEBUG MODE - Zum Testen (kann nach Test entfernt werden) */
/* Kommentiere die folgenden Zeilen ein, um die Safe Area rot anzuzeigen:

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body::after {
        content: "";
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: env(safe-area-inset-bottom);
        background: rgba(255, 0, 0, 0.3);
        pointer-events: none;
        z-index: 99999;
    }
}
*/
