/**
 * Mobile Keyboard Fix - ULTRA AGGRESSIVE CSS
 * 
 * An extremely aggressive solution to completely eliminate keyboard padding issues
 * on mobile browsers, especially iPhone X and newer models.
 */

/* Global resets for all devices */
html,
body {
    padding: 0 !important;
    margin: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    height: 100% !important;
    width: 100% !important;
    overflow: hidden !important;
}

/* Reset safe area insets */
:root {
    --safe-area-inset-bottom: 0px !important;
    --safe-area-inset-top: 0px !important;
    --safe-area-inset-left: 0px !important;
    --safe-area-inset-right: 0px !important;
}

/* Flutter container styles */
#flutter-container {
    padding: 0 !important;
    margin: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    height: 100% !important;
    width: 100% !important;
}

/* Ultra aggressive styles for iPhone X and newer */
@media only screen and (min-device-width: 375px) and (max-device-width: 812px) and (-webkit-min-device-pixel-ratio: 3),
only screen and (min-device-width: 414px) and (max-device-width: 896px) and (-webkit-min-device-pixel-ratio: 2) {

    html,
    body,
    #flutter-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-overflow-scrolling: touch;
        overflow: hidden !important;
    }

    /* Force hardware acceleration on all elements */
    * {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-perspective: 1000;
        perspective: 1000;
    }

    /* Target bottom sheets and modals */
    [role="dialog"],
    [class*="bottom"],
    [class*="modal"],
    [class*="sheet"],
    [class*="overlay"] {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
        bottom: 0 !important;
        max-height: 100% !important;
    }

    /* Special class for when keyboard is open */
    .keyboard-open {
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        overflow: hidden !important;
    }

    /* Special handling for iPhone X */
    .iphone-x {
        padding-bottom: 0 !important;
        margin-bottom: 0 !important;
    }

    /* Override any potential Flutter-added styles */
    body::after,
    body::before,
    html::after,
    html::before {
        content: none !important;
        display: none !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Ensure no padding is added to inputs */
    input,
    textarea {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }
}

/* Special styles for iOS devices */
.ios-device {
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden !important;
}

/* Special styles for when keyboard is dismissed */
.ios-device.keyboard-dismissed {
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    bottom: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Force hardware acceleration on all elements for iOS */
.ios-device * {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}