/* === iOS & iPhone Optimization Fixes === */

/* 
 * 1. PREVENT AUTO-ZOOM
 * iOS zooms in if input font-size is < 16px. 
 * We force 16px on mobile inputs.
 */
@media screen and (max-width: 768px) {

    input,
    select,
    textarea,
    .form-control,
    .custom-multiselect-trigger,
    .multiselect-label {
        font-size: 16px !important;
    }

    /* Adjust padding if 16px breaks layout height */
    input,
    select,
    textarea {
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

/* 
 * 2. SAFE AREA INSETS (iPhone X and newer)
 * Respect the home indicator area at the bottom.
 */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 20px);
}

.toast-container {
    bottom: max(20px, var(--safe-bottom)) !important;
}

/* Add padding to bottom of page/containers to avoid cutoff */
body,
.relatorio-container,
.container {
    padding-bottom: max(20px, var(--safe-bottom));
}

/* 
 * 3. TOUCH & SCROLLING 
 */
.chart-carousel-track,
.admin-carousel-track {
    -webkit-overflow-scrolling: touch;
    /* Momentum scrolling */
}

button,
.btn,
.carousel-nav-btn {
    touch-action: manipulation;
    /* Disable double-tap zoom delay */
}

/* 
 * 4. RESET iOS DEFAULT STYLES 
 * Removes rounded corners and shadows on inputs
 */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="search"],
textarea {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 4px;
    /* Ensure our radius is applied */
}
/* === iPhone Login Footer Fix === */
/* Aumentar espaçamento do rodapé na tela de login quando teclado abre */
@media screen and (max-width: 480px) {
    .login-page footer {
        padding-bottom: 20px; /* Mais espaço embaixo */
        margin-top: 40px; /* Afastar do botão ACESSAR */
        position: relative; /* Garantir que não flutue estranho */
        z-index: 10;
    }

    .login-container {
        margin-bottom: 20px; /* Empurrar footer pra baixo */
    }
    
    /* Garantir que o botão não cole */
    .btn-glow {
        margin-bottom: 20px !important;
    }
}


/* === FIX LOGIN FOOTER ABSOLUTE POSITIONING === */
/* O footer estava position:absolute bottom:20px, o que faz ele subir junto com o teclado */
@media screen and (max-height: 600px), screen and (max-width: 480px) {
    .login-page .main-footer {
        position: static !important; /* Desgrudar do fundo da tela */
        margin-top: 40px !important; /* Dar espaço do form */
        padding-bottom: 20px !important;
        transform: none !important;
        width: 100%;
        display: block;
    }
    
    /* Garantir scroll se a tela ficar pequena com teclado */
    .login-page {
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh;
        padding: 20px 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}


/* === RE-FIX LOGIN FOOTER LAYOUT === */
/* Corrigindo especificidade do seletor para garantir coluna */
@media screen and (max-width: 480px) {
    body.login-page {
        flex-direction: column !important; /* Forçar vertical */
        justify-content: flex-start !important; /* Começar do topo se necessario, ou center */
        padding-top: 40px; /* Espaço extra no topo */
    }

    .login-wrapper {
         /* Garantir que o form não ocupe tudo e empurre o footer */
         flex: 0 0 auto !important;
         margin-bottom: 40px !important; /* Espaço solicitado pelo usuário (Margin Bottom) */
    }

    .login-page .main-footer {
        position: static !important;
        width: 100%;
        margin-top: 0 !important; /* Já tem margin-bottom no wrapper */
        padding-bottom: 20px;
    }
}

