/**
 * Custom Login Styles - Modelo exato do login_modelo.html
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Anular completamente UIPress */
body.uip-login,
body.uip-login::before,
body.uip-login::after {
    background: none !important;
    content: none !important;
    width: auto !important;
    height: auto !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    display: none !important;
}

body.login,
body.login.uip-login {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    min-height: 100vh !important;
    display: grid !important;
    place-items: center !important;
    padding: 1rem !important;
    margin: 0 !important;
}

/* Desativar pseudoelementos que interferem */
body.login::before,
body.login::after {
    display: none !important;
    content: none !important;
}

/* Container principal - corrigir centralização */
#login {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    position: relative;
    overflow: visible;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s ease;
    margin: 0 !important; /* Sobrescrever margin: auto do WordPress */
    left: auto !important;
    right: auto !important;
    top: auto !important;
}

/* Animação de entrada */
#login.mpa-animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* Borda superior removida conforme solicitado */
/* #login::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #9333ea);
} */

/* Seção do logo */
.logo-section {
    text-align: center;
    margin-bottom: 2rem;
    margin-top: 1rem;
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.5rem;
}

.logo img {
    max-height: 48px;
    width: auto;
}

.logo-accent {
    color: #2563eb;
}

.logo-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

/* Header de login */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-title,
.mpa-welcome-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.5rem;
    text-align: center;
    margin-top: 1rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
}

/* Formulários do WordPress */
form#loginform,
form#lostpasswordform,
form#resetpassform {
    border: 0;
    background: none;
    padding: 0;
    margin: 0;
}

/* Grupos de campos do WordPress */
.login-username,
.login-password,
.login-email {
    margin-bottom: 1.25rem;
}

.login-submit {
    margin-bottom: 1.5rem;
}

/* Labels do WordPress */
form#loginform label,
form#lostpasswordform label,
form#resetpassform label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

/* Inputs do WordPress - bordas mais sutis */
input#user_login,
input#user_pass,
input#user_email,
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #dfdfdf;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 400;
    color: #374151;
    background-color: #fafafa;
    transition: all 0.2s;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
}

input#user_login:focus,
input#user_pass:focus,
input#user_email:focus,
.input:focus {
    outline: none;
    border-color: #e5e7eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.05);
    background-color: white;
}

input#user_login:hover,
input#user_pass:hover,
input#user_email:hover,
.input:hover {
    border-color: #e5e7eb;
}

input#user_login::placeholder,
input#user_pass::placeholder,
input#user_email::placeholder,
.input::placeholder {
    color: #9ca3af;
    font-weight: 400;
    font-size: 0.9375rem;
}

/* Classes genéricas para compatibilidade */
.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #dfdfdf;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 400;
    color: #374151;
    background-color: #fafafa;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #e5e7eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.05);
    background-color: white;
}

.form-input:hover {
    border-color: #e5e7eb;
}

.form-input::placeholder {
    color: #9ca3af;
    font-weight: 300;
    font-size: 0.875rem;
}

/* Container de senha */
.password-container {
    position: relative;
}

/* Botão de toggle da senha - melhor alinhado */
.password-toggle {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 0.25rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.password-toggle:hover {
    color: #6b7280;
}

.password-toggle .icon {
    width: 16px;
    height: 16px;
}

/* Opções do formulário */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Checkbox "Lembrar de mim" do WordPress */
.login-remember,
.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

input#rememberme,
.checkbox {
    width: 1rem;
    height: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    cursor: pointer;
}

input#rememberme:checked,
.checkbox:checked {
    background-color: #2563eb;
    border-color: #2563eb;
}

.login-remember label,
.remember-label {
    font-size: 0.875rem;
    color: #6b7280;
    cursor: pointer;
    margin-bottom: 0;
}

/* Links do WordPress */
#login p a,
.forgot-password {
    font-size: 0.875rem;
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

#login p a:hover,
.forgot-password:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* Espaçamento dos parágrafos do WordPress */
#login p {
    margin-bottom: 1rem;
}

#login p:last-child {
    margin-bottom: 0;
}

/* Botão de login do WordPress */
input#wp-submit,
input[type="submit"],
.button,
.button-primary,
.button-large,
.login-btn {
    width: 100%;
    background: linear-gradient(135deg, #2563eb, #1d4ed8) !important;
    color: white !important;
    border: none !important;
    border-radius: 0.5rem !important;
    padding: 0.875rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1.5rem;
    text-decoration: none !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

input#wp-submit:hover,
input[type="submit"]:hover,
.button:hover,
.button-primary:hover,
.button-large:hover,
.login-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4) !important;
}

input#wp-submit:active,
input[type="submit"]:active,
.button:active,
.button-primary:active,
.button-large:active,
.login-btn:active {
    transform: translateY(0);
}

input#wp-submit:disabled,
input[type="submit"]:disabled,
.button:disabled,
.button-primary:disabled,
.button-large:disabled,
.login-btn:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none !important;
}

/* Seletor de idioma */
.language-selector {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
    z-index: 100;
    position: relative;
}

.language-dropdown {
    position: relative;
    display: inline-block;
}

.language-btn {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: #6b7280;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.language-btn:hover {
    background-color: #f3f4f6;
    border-color: #d1d5db;
}

/* Dropdown de idiomas */
.language-options {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 180px;
    z-index: 200;
    display: none;
    margin-top: 0.5rem;
}

.language-options.show {
    display: block;
}

.language-option {
    padding: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #374151;
    transition: background-color 0.2s;
}

.language-option:hover {
    background-color: #f9fafb;
}

.language-option:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.language-option:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

/* Ícone */
.icon {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
}

/* Bandeiras */
.flag {
    width: 1rem;
    height: 0.75rem;
    border-radius: 0.125rem;
    display: inline-block;
}

.flag-br {
    background: #009639;
    position: relative;
    overflow: hidden;
}

.flag-br::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 0.6rem;
    height: 0.6rem;
    background: #fedd00;
    border-radius: 0.05rem;
}

.flag-br::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    width: 0.35rem;
    height: 0.35rem;
    background: #002776;
    border-radius: 50%;
    z-index: 1;
}

.flag-us {
    background: linear-gradient(
        to bottom,
        #b22234 7.69%,
        white 7.69%,
        white 15.38%,
        #b22234 15.38%
    );
}

.flag-es {
    background: linear-gradient(
        to bottom,
        #c60b1e 25%,
        #ffc400 25%,
        #ffc400 75%,
        #c60b1e 75%
    );
}

/* Estados de erro */
.form-input.error {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.error-message {
    color: #dc2626;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.error-message.show {
    display: block;
}

/* Loading spinner */
.loading-spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid transparent;
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsivo - Mobile */
@media (max-width: 768px) {
    body.login {
        display: grid;
        place-items: start center; /* Centraliza horizontalmente, mas permite scroll vertical */
        padding: 2rem 1rem;
        min-height: 100vh;
    }

    #login {
        padding: 1.5rem;
        margin: 0 !important;
        width: calc(100% - 2rem);
        max-width: 380px;
    }
}

@media (max-width: 480px) {
    body.login {
        padding: 1.5rem 0.5rem;
    }

    #login {
        padding: 1.5rem;
        margin: 0 !important;
        width: calc(100% - 1rem);
    }

    .logo {
        font-size: 1.75rem;
    }

    .login-title {
        font-size: 1.25rem;
    }

    .form-options {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

/* Estados especiais do WordPress - esconder elementos nativos */
#nav, 
#backtoblog,
.language-switcher {
    display: none !important;
}

/* Tratamento especial para notices/mensagens do WordPress */
.login .message,
.login #login_error {
    background: rgba(244, 67, 54, 0.1) !important;
    border: 1px solid rgba(244, 67, 54, 0.3) !important;
    border-radius: 0.75rem !important;
    padding: 1rem !important;
    margin: 0 0 1.5rem 0 !important;
    color: #d32f2f !important;
    font-size: 0.875rem !important;
    text-align: center !important;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
}

.login .message {
    background: rgba(76, 175, 80, 0.1) !important;
    border-color: rgba(76, 175, 80, 0.3) !important;
    color: #388e3c !important;
}

/* Ajustar layout quando há notices */
body.login:has(.message),
body.login:has(#login_error) {
    display: grid;
    place-items: start center;
    padding-top: 2rem;
}

/* Fallback para navegadores sem :has() */
body.login .login-with-message {
    display: grid;
    place-items: start center;
    padding-top: 2rem;
}

/* Mostrar notices apenas em formulários de recuperação */
body.login.login-action-lostpassword .notice,
body.login.login-action-lostpassword .message,
body.login.login-action-resetpass .notice,
body.login.login-action-resetpass .message {
    display: block !important;
}

/* Esconder notices apenas na tela de login principal se não forem importantes */
body.login:not(.login-action-lostpassword):not(.login-action-resetpass) .notice:not(.error):not(.updated),
body.login:not(.login-action-lostpassword):not(.login-action-resetpass) .update-nag {
    display: none !important;
}

/* Ajustes específicos para WordPress login */
body.login #login h1,
body.login #login h1 a {
    display: none !important;
}

/* Ajustes adicionais de espaçamento para WordPress */
#loginform {
    padding-bottom: 0;
}

.forgetmenot {
    float: left;
    margin-bottom: 0;
}

.submit {
    float: right;
    margin-bottom: 0;
}

#login form p.submit {
    clear: both;
    float: none;
    margin-top: 1rem;
}

/* Container deve ocupar toda a largura no mobile */
@media (max-width: 768px) {
    body.login {
        padding: 0.5rem;
    }
    
    #login {
        max-width: none;
        width: calc(100vw - 1rem);
    }
}

/* Loading state para o botão */
.mpa-loading {
    opacity: 0.7;
}

/* Animação suave de entrada da página */
@keyframes pageEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

body.login {
    animation: pageEnter 0.6s ease-out;
}

/* Melhorias de acessibilidade */
.form-input:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
