/* ==========================================================
   GS CENTRAL — LOGIN MINHA CONTA
   Teclado mobile sem box ou área vazia
   ========================================================== */

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

    /*
     * Os campos permanecem com 16px para impedir
     * o zoom automático no iPhone.
     */
    body.gs-login-mobile-corrected
    .portal-login-card input {
        font-size: 16px !important;
    }

    /*
     * Não fixar o body.
     *
     * A estratégia anterior com position: fixed era
     * responsável pelo grande box vazio acima do teclado.
     */
    html.gs-login-mobile-corrected,
    body.gs-login-mobile-corrected {
        position: static !important;

        width: 100% !important;

        min-height:
            var(
                --gs-login-visual-height,
                100dvh
            ) !important;

        height: auto !important;
        max-height: none !important;

        margin: 0 !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        overscroll-behavior-y: auto !important;

        -webkit-overflow-scrolling: touch !important;
    }

    /*
     * Com o teclado aberto, continua sem body fixo.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible {
        position: static !important;

        min-height:
            var(
                --gs-login-visual-height,
                100dvh
            ) !important;

        height: auto !important;
        max-height: none !important;

        overflow-x: hidden !important;
        overflow-y: auto !important;

        touch-action: pan-y !important;
    }

    /*
     * Remove alturas baseadas em 100vh dos contêineres
     * internos enquanto o teclado estiver aberto.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .gs-app-like-scroll,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .gs-app-like-portal-scroll,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .gs-portal-shell,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    main {
        position: static !important;

        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;

        overflow-x: hidden !important;
        overflow-y: visible !important;

        transform: none !important;
    }

    /*
     * Área principal compacta durante a digitação.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .gs-portal-shell {
        margin: 0 auto !important;

        padding:
            8px
            10px
            12px !important;
    }

    /*
     * O formulário fica no fluxo normal da página,
     * sem centralização vertical que cria espaço vazio.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-login-card {
        position: relative !important;

        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;

        min-height: 0 !important;
        height: auto !important;
        max-height: none !important;

        margin:
            6px
            auto
            12px !important;

        transform: none !important;
    }

    /*
     * Remove centralização vertical de possíveis pais.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-login-page,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-auth-page,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    [class*="login-page"],

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    [class*="auth-page"] {
        display: block !important;

        min-height: 0 !important;
        height: auto !important;

        align-items: initial !important;
        justify-content: initial !important;

        padding-top: 4px !important;
        padding-bottom: 10px !important;
    }

    /*
     * O rodapé não ocupa a área reduzida pelo teclado.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-footer {
        display: none !important;
    }

    /*
     * Mantém o cabeçalho no fluxo normal, sem criar
     * uma segunda área fixa.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-topbar {
        position: relative !important;

        top: auto !important;

        margin: 0 !important;

        transform: none !important;
    }

    /*
     * Campos e botão não podem ter transformações
     * ou posicionamentos absolutos durante o teclado.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-form,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-form label,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-form input,

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-form button {
        position: relative !important;

        top: auto !important;
        bottom: auto !important;

        transform: none !important;
    }

    /*
     * Espaço pequeno para permitir que o último campo
     * suba acima do teclado.
     */
    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-form {
        padding-bottom: 12px !important;
    }

    body.gs-login-mobile-corrected.gs-login-keyboard-visible
    .portal-form input {
        scroll-margin-top: 18px !important;
        scroll-margin-bottom: 140px !important;
    }
}
