/* ============================================
   FIX CRÍTICO - LOGIN E ONBOARDING NO MOBILE
   ============================================ */

/* === LOGIN SCREEN (Supabase Auth) === */
/* Corrige inputs da tela de login/registro */
#login-screen {
    -webkit-overflow-scrolling: touch !important;
    overflow-y: auto !important;
}

#login-screen input {
    position: relative !important;
    z-index: 10000 !important;
    -webkit-user-select: text !important;
    user-select: text !important;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Garantir que inputs do login tenham tamanho adequado */
@media screen and (max-width: 1024px) {
    #login-screen input {
        font-size: 16px !important;
        min-height: 48px !important;
    }
}

/* === ONBOARDING SCREEN === */
/* Aplicar mesmas correções ao onboarding */
#onboarding-screen input,
#onboarding-screen select,
#onboarding-screen textarea {
    position: relative !important;
    z-index: 10000 !important;
    -webkit-user-select: text !important;
    user-select: text !important;
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

@media screen and (max-width: 1024px) {

    #onboarding-screen input,
    #onboarding-screen select {
        font-size: 16px !important;
        min-height: 48px !important;
    }
}

/* === TODOS OS FORMULÁRIOS === */
/* Correção universal para qualquer input no sistema */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    -webkit-user-select: text !important;
    user-select: text !important;
    -webkit-tap-highlight-color: rgba(16, 185, 129, 0.2) !important;
    touch-action: manipulation !important;
}

/* Mobile - prevenir zoom e garantir interação */
@media screen and (max-width: 1024px) {

    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* === CORREÇÕES ESPECÍFICAS iOS === */
@supports (-webkit-touch-callout: none) {

    input,
    select,
    textarea {
        transform: translate3d(0, 0, 0);
        -webkit-transform: translate3d(0, 0, 0);
        will-change: transform;
    }

    #login-screen,
    #onboarding-screen {
        -webkit-overflow-scrolling: touch;
        transform: translate3d(0, 0, 0);
    }
}

/* === REMOVER SOBREPOSIÇÕES PROBLEMÁTICAS === */
/* Garantir que nada bloqueie os inputs */
.form-group label,
.form-label {
    pointer-events: none !important;
    user-select: none !important;
}

/* Inputs devem estar acima de tudo */
input,
select,
textarea {
    isolation: isolate;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* === FIX PARA TECLADO VIRTUAL === */
/* Quando o teclado abre no mobile */
@media (max-height: 600px) and (orientation: portrait) {

    #login-screen>div,
    #onboarding-screen .onboarding-container {
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* === DEBUGGING === */
/* Se continuar com problemas, ativar essas regras */
/*
input {
    background: yellow !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}
*/