/* ==========================================================
   TEMA UFPEL - LOGIN KEYCLOAK
   Layout centralizado
   ========================================================== */

    .login-pf-page .card-pf
 {
        padding: 10px 20px 20px 10px !important;
    }

/* ==========================================================
   1. RESET
   ========================================================== */

html,
body {
    margin: 0 !important;
    padding: 0 !important;

    width: 100% !important;
    min-height: 100% !important;
    height: auto !important;

    background: #ffffff !important;
    background-image: none !important;

    font-family: 'Open Sans', Arial, sans-serif !important;

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

a {
    font-size: medium !important;
}

*,
*::before,
*::after {
    box-sizing: border-box !important;
}


/* ==========================================================
   2. BARRA SUPERIOR
   ========================================================== */

html body::before {
    content: "" !important;

    position: fixed !important;

    top: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 45px !important;

    background-color: #004c78 !important;

    z-index: 9999 !important;

    pointer-events: none !important;
}


/* ==========================================================
   3. BARRA INFERIOR
   ========================================================== */

html body::after {
    content: "" !important;

    position: fixed !important;

    bottom: 0 !important;
    left: 0 !important;

    width: 100% !important;
    height: 45px !important;

    background-color: #004c78 !important;

    z-index: 9999 !important;

    pointer-events: none !important;
}


/* ==========================================================
   4. ÁREA DO LOGIN
   ========================================================== */

html body .pf-v5-c-login {
    position: fixed !important;

    top: 45px !important;
    right: 0 !important;
    bottom: 45px !important;
    left: 0 !important;

    width: auto !important;
    height: auto !important;

    min-height: 0 !important;

    margin: 0 !important;

    padding: 20px !important;

    display: flex !important;

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

    background: #ffffff !important;

    overflow: auto !important;
}


/* ==========================================================
   5. CONTAINER ÚNICO
   ========================================================== */

/*
   ESTE é o elemento que define a largura.

   Não colocamos mais max-width nos elementos internos.
*/

html body .pf-v5-c-login__container {
    display: block !important;

    width: 100% !important;

    max-width: 480px !important;

    margin: 0 auto !important;
    padding: 0 !important;

    background: transparent !important;

    border: none !important;
    box-shadow: none !important;
}


/* ==========================================================
   6. MAIN
   ========================================================== */

html body .pf-v5-c-login__main {
    display: block !important;

    width: 100% !important;
    max-width: none !important;

    margin: 0 !important;
    padding: 0 !important;

    background: transparent !important;

    border: none !important;
    box-shadow: none !important;
}


/* ==========================================================
   7. TÍTULO
   ========================================================== */

/*
   Não esconder o cabeçalho principal do formulário.

   O título "Entrar na sua conta" deve ficar acima da logo.
*/

html body .pf-v5-c-login__main-header {
    display: block !important;

    width: 100% !important;

    margin: 0 0 25px 0 !important;
    padding: 0 !important;

    text-align: center !important;

    background: transparent !important;

    border: none !important;
    box-shadow: none !important;
}


/*
   Remove espaçamentos automáticos do PatternFly
   no título.
*/

html body .pf-v5-c-login__main-header h1,
html body .pf-v5-c-login__main-header h2,
html body .pf-v5-c-login__main-header h3,
html body #kc-page-title {
    margin: 0 !important;
    padding: 0 !important;

    font-size: 24px !important;
    font-weight: 400 !important;

    line-height: 1.3 !important;

    color: #444444 !important;

    text-align: center !important;
}


/* ==========================================================
   8. REMOVE CABEÇALHO EXTERNO / IDIOMA
   ========================================================== */

html body .pf-v5-c-login__header,
html body #kc-header,
html body #kc-header-wrapper,
html body #kc-locale {
    display: none !important;
}


/* ==========================================================
   9. LOGO UFPEL
   ========================================================== */

/*
   A logo fica DEPOIS do título e ANTES do formulário.
*/

html body #kc-content::before {
    content: "" !important;

    display: block !important;

    width: 100% !important;

    height: 200px !important;

    margin: 0 0 10px 0 !important;

    background-image: url('../img/logo.svg') !important;

    background-repeat: no-repeat !important;

    background-position: center center !important;

    background-size: contain !important;
}


/* ==========================================================
   10. CONTEÚDO
   ========================================================== */

html body #kc-content,
html body #kc-content-wrapper {
    display: block !important;

    width: 100% !important;

    max-width: none !important;

    margin: 0 !important;
    padding: 0 !important;

    background: transparent !important;

    border: none !important;
    box-shadow: none !important;
}


/* ==========================================================
   11. CARD
   ========================================================== */

html body .card-pf {
    width: 100% !important;

    max-width: none !important;

    margin: 0 !important;
    padding: 0 !important;

    background: transparent !important;

    border: none !important;
    box-shadow: none !important;
}


/* ==========================================================
   12. FORMULÁRIO
   ========================================================== */

html body #kc-form,
html body #kc-form-wrapper {
    width: 100% !important;

    margin: 0 !important;
    padding: 0 !important;
}


/* ==========================================================
   13. CAMPOS
   ========================================================== */

html body #kc-form input[type="text"],
html body #kc-form input[type="password"],
html body #kc-form input[type="email"],
html body #kc-form input[type="tel"],
html body #kc-form input[type="number"] {
    width: 100% !important;

    box-sizing: border-box !important;
}


/* ==========================================================
   14. OPÇÕES DO FORMULÁRIO
   ========================================================== */

html body #kc-form-options {
    width: 100% !important;

    margin-top: 15px !important;
}


/*
   Mantém o "Mantenha-me conectado" à esquerda
   e o "Esqueceu sua senha?" à direita.
*/

html body #kc-form-options,
html body .pf-v5-c-login__main-footer {
    width: 100% !important;
}


/* ==========================================================
   15. BOTÃO ACESSAR
   ========================================================== */

html body #kc-login,
html body .pf-v5-c-button.pf-m-primary {
    display: block !important;

    width: 100% !important;

    margin-top: 20px !important;
    padding: 12px !important;

    background-color: #004c78 !important;

    border: 1px solid #003656 !important;

    border-radius: 4px !important;

    color: #ffffff !important;

    font-size: 16px !important;
    font-weight: 700 !important;

    text-align: center !important;

    cursor: pointer !important;
}


html body #kc-login:hover,
html body .pf-v5-c-button.pf-m-primary:hover {
    background-color: #003656 !important;
}


/* ==========================================================
   16. LINKS
   ========================================================== */

html body #kc-form-options a,
html body .pf-v5-c-login__main-footer a {
    color: #008dcc !important;

    font-weight: 600 !important;

    text-decoration: none !important;
}


html body #kc-form-options a:hover,
html body .pf-v5-c-login__main-footer a:hover {
    text-decoration: underline !important;
}


/* ==========================================================
   17. MOBILE
   ========================================================== */

@media (max-width: 600px) {

    html body .pf-v5-c-login {
        padding: 15px !important;
    }

    html body .pf-v5-c-login__container {
        max-width: 480px !important;
    }

    html body .pf-v5-c-login__main-header {
        margin-bottom: 20px !important;
    }

    html body #kc-content::before {
        height: 110px !important;

        margin-bottom: 25px !important;
    }

    html body .pf-v5-c-login__main-header h1,
    html body .pf-v5-c-login__main-header h2,
    html body .pf-v5-c-login__main-header h3,
    html body #kc-page-title {
        font-size: 21px !important;
    }
}

/* ==========================================================
   OBSOLETO - REMOVIDO E CENTRALIZADO NA SEÇÃO SEGUINTE
   ========================================================== */

/* ==========================================================
   TRECHO ISOLADO: ALTERAÇÃO DE TÍTULO VIA #kc-page-title
   ========================================================== */

html body #kc-page-title {
    font-size: 0 !important;
    visibility: hidden !important;
    height: 0 !important;
    margin: 0 !important;
}

html body #kc-page-title::after {
    content: "Portal de autenticação UFPel" !important;
    font-size: 1.4rem !important;
    font-weight: 600 !important;
    color: #222222 !important;
    display: block !important;
    visibility: visible !important;
    text-align: center !important;
    margin-bottom: 20px !important;
}

/* ==========================================================
   CORREÇÃO DEFINITIVA DE ALTURA, CENTRALIZAÇÃO E ROLAGEM VERTICAL
   ========================================================== */

/*
   Para garantir que a tela nunca corte o conteúdo e funcione tanto em 
   versões modernas do Keycloak (.pf-v5-c-login) quanto em versões antigas (.login-pf-page):
   
   1. Permitimos a rolagem vertical nativa no próprio body (com overflow-y: auto).
   2. Removemos position: fixed dos elementos principais de login para que eles
      possam fluir naturalmente e esticar a página quando necessário.
   3. Adicionamos margens superior e inferior de 45px para garantir que o conteúdo
      nunca fique escondido por baixo das barras superior e inferior (que são fixed).
   4. Usamos flexbox com 'margin: auto' no container filho para centralizar verticalmente
      quando houver espaço, mas rolar normalmente sem cortar o topo se o conteúdo for maior.
*/

html body .pf-v5-c-login,
html body .login-pf-page {
    position: relative !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;

    width: 100% !important;
    min-height: calc(100vh - 90px) !important;
    height: auto !important;

    margin-top: 45px !important;
    margin-bottom: 45px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;

    padding: 30px 20px !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;

    background: #ffffff !important;
    box-sizing: border-box !important;

    overflow: visible !important;
}

/*
   Container de largura máxima (480px) centralizado vertical e horizontalmente.
   O uso de margin-top: auto e margin-bottom: auto dentro de um pai Flex
   resolve o clássico bug de flexbox onde o topo do conteúdo é cortado na rolagem.
*/
html body .pf-v5-c-login__container,
html body .card-pf {
    width: 100% !important;
    max-width: 480px !important;

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

    padding: 0 !important;
    display: block !important;
    background: transparent !important;
    box-sizing: border-box !important;
}

/*
   Garante que todos os sub-elementos herdem a largura do container
   de 480px responsivamente, sem precisar de larguras fixas ou resets complexos.
*/
html body .pf-v5-c-login__main,
html body #kc-content,
html body #kc-content-wrapper,
html body #kc-form,
html body #kc-form-wrapper,
html body .pf-v5-c-login__main-header,
html body #kc-content::before,
html body #kc-form input[type="text"],
html body #kc-form input[type="password"],
html body #kc-form input[type="email"],
html body #kc-form input[type="tel"],
html body #kc-form input[type="number"],
html body #kc-login,
html body .pf-v5-c-button.pf-m-primary {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
}

/* Restabelece a altura específica da Logo do topo */
html body #kc-content::before {
    height: 230px !important;
}

/* ==========================================================
   AJUSTES MOBILE DE ROLAGEM E PADDING
   ========================================================== */

@media (max-width: 520px) {
    html body .pf-v5-c-login,
    html body .login-pf-page {
        padding: 20px 15px !important;
    }

    html body #kc-content::before {
        height: 110px !important;
        margin-bottom: 25px !important;
    }
}
/* Garantir visibilidade de mensagens de erro */
.pf-v5-c-form__helper-text.pf-m-error,
.pf-v5-c-alert.pf-m-danger {
    display: block !important;
    visibility: visible !important;
    color: #c9190b !important;
    margin-top: 5px !important;
    font-size: 0.875rem !important;
}
