/**
 * Mobile Footer Positioning Fix
 * Addresses specific mobile viewport and footer positioning issues
 */

/* === MOBILE-SPECIFIC FOOTER IMPROVEMENTS === */

@media (max-width: 768px) {
    /* Use dynamic viewport units for true mobile viewport handling */
    body {
        min-height: 100dvh !important; /* Dynamic viewport height */
        height: auto !important;
        max-height: none !important;
    }
    
    /* Alternative fallback for older browsers */
    @supports not (height: 100dvh) {
        body {
            min-height: calc(100vh - env(keyboard-inset-height, 0px)) !important;
        }
    }
    
    /* Optimize main content area */
    main {
        flex: 1 !important;
        min-height: 0 !important;
        padding-bottom: 0 !important; /* Remove extra padding that might cause issues */
    }
    
    /* Reduce footer size and optimize positioning */
    footer {
        flex-shrink: 0 !important;
        position: relative !important; /* Changed from sticky to relative */
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: rgba(0, 0, 0, 0.95) !important;
        border-top: 1px solid rgba(0, 255, 65, 0.3) !important;
        backdrop-filter: blur(4px) !important;
        z-index: 100 !important;
    }
    
    /* Compact footer content */
    footer .container-matrix {
        margin: 0 !important;
        padding: 0.375rem 1rem !important; /* Reduced from 0.5rem */
        max-width: 100% !important;
    }
    
    /* Optimize footer text and layout */
    footer .flex {
        flex-direction: column !important;
        gap: 0.25rem !important; /* Reduced gap */
        align-items: center !important;
        justify-content: center !important;
    }
    
    footer p {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 0.6875rem !important; /* 11px - smaller text */
        line-height: 1.2 !important;
        text-align: center !important;
    }
    
    /* Hide or abbreviate footer text on very small screens */
    @media (max-width: 480px) {
        footer p:first-child {
            font-size: 0.625rem !important; /* 10px */
        }
        
        footer p:last-child {
            display: none !important; /* Hide "WELCOME TO THE MATRIX" on tiny screens */
        }
    }
    
    /* Ensure register page container doesn't interfere */
    .auth-register-container {
        min-height: calc(100dvh - 60px) !important; /* Account for footer height */
        padding-bottom: 1rem !important;
    }
    
    @supports not (height: 100dvh) {
        .auth-register-container {
            min-height: calc(100vh - 60px - env(keyboard-inset-height, 0px)) !important;
        }
    }
    
    /* Fix for registration form spacing */
    .auth-register-container .max-w-lg {
        margin-bottom: 0 !important;
    }
    
    /* Ensure no content causes overflow - ONLY registration page */
    .auth-register-container .space-y-8 > *:last-child {
        margin-bottom: 0 !important;
    }
}

/* === ULTRA-SMALL MOBILE FIXES (< 400px) === */

@media (max-width: 400px) {
    /* Even more compact footer */
    footer .container-matrix {
        padding: 0.25rem 0.5rem !important;
    }
    
    footer p {
        font-size: 0.5625rem !important; /* 9px */
    }
    
    /* Adjust register container for tiny screens */
    .auth-register-container {
        min-height: calc(100dvh - 40px) !important;
        padding: 0.5rem !important;
    }
}

/* === LANDSCAPE MOBILE FIXES === */

@media (max-height: 500px) and (orientation: landscape) {
    /* Special handling for landscape mobile */
    body {
        min-height: 100vh !important; /* Regular vh for landscape */
    }
    
    footer {
        position: fixed !important; /* Fixed positioning for landscape */
        bottom: 0 !important;
        z-index: 1000 !important;
    }
    
    footer .container-matrix {
        padding: 0.25rem 1rem !important; /* Very compact in landscape */
    }
    
    footer p:last-child {
        display: none !important; /* Hide secondary text in landscape */
    }
    
    .auth-register-container {
        padding-bottom: 50px !important; /* Account for fixed footer */
        min-height: calc(100vh - 50px) !important;
    }
    
    /* Reduce form spacing in landscape - ONLY registration page */
    .auth-register-container .space-y-8 > * + * {
        margin-top: 0.75rem !important;
    }
}

/* === SAFE AREA INSETS (for newer devices with notches) === */

@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        footer {
            padding-left: max(0px, env(safe-area-inset-left)) !important;
            padding-right: max(0px, env(safe-area-inset-right)) !important;
            padding-bottom: max(0px, env(safe-area-inset-bottom)) !important;
        }
        
        footer .container-matrix {
            padding-left: max(1rem, calc(1rem + env(safe-area-inset-left))) !important;
            padding-right: max(1rem, calc(1rem + env(safe-area-inset-right))) !important;
        }
    }
}