/**
 * ADM Organizador Pro - Custom Login Styles
 * iOS/HyperOS Glassmorphism Design
 * Version: 3.2.0
 */

/* ==================================================================
   RESET E PREVENÇÃO DE OVERFLOW MOBILE
   ================================================================== */
html {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* ==================================================================
   LOGIN PAGE BASE - GLASSMORPHISM
   ================================================================== */
body.login {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height para mobile */
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    background-attachment: fixed;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
}

/* Overlay gradiente para melhorar legibilidade */
body.login::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
    z-index: 0;
}

/* ==================================================================
   LOGIN CONTAINER
   ================================================================== */
#login {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    margin: auto;
    padding: 24px;
    box-sizing: border-box;
}

/* ==================================================================
   LOGO
   ================================================================== */
#login h1 a,
.login h1 a {
    display: block;
    width: 100%;
    max-width: 100%;
    height: 84px;
    margin: 0 auto 30px;
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    text-indent: -9999px;
    outline: none;
    transition: transform 0.3s ease, opacity 0.3s ease, border-radius 0.3s ease;
    box-sizing: border-box;
    /* Dimensões e formatos personalizados são aplicados via CSS inline com !important */
}

#login h1 a:hover,
.login h1 a:hover {
    transform: scale(1.03);
}

#login h1 a:focus,
.login h1 a:focus {
    outline: 2px solid rgba(0, 122, 255, 0.5);
    outline-offset: 4px;
}

/* ==================================================================
   LOGIN FORM - GLASSMORPHISM CARD
   ================================================================== */
.login form {
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 1px 0 rgba(255, 255, 255, 0.4) inset;
    padding: 32px;
    margin-top: 0;
    margin-bottom: 0;
}

/* ==================================================================
   FORM LABELS
   ================================================================== */
.login label {
    font-size: 14px;
    font-weight: 600;
    color: #1c1c1e;
    letter-spacing: -0.2px;
    margin-bottom: 6px;
    display: block;
}

/* ==================================================================
   INPUT FIELDS - iOS STYLE
   ================================================================== */
.login form .input,
.login form input[type="text"],
.login form input[type="password"],
.login form input[type="email"] {
    width: 100%;
    padding: 14px 16px;
    margin: 0;
    font-size: 16px;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid rgba(60, 60, 67, 0.15);
    border-radius: 12px;
    box-shadow: 
        inset 0 1px 2px rgba(0, 0, 0, 0.04),
        0 1px 0 rgba(255, 255, 255, 0.6);
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-appearance: none;
    appearance: none;
}

.login form .input:focus,
.login form input[type="text"]:focus,
.login form input[type="password"]:focus,
.login form input[type="email"]:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 
        0 0 0 4px rgba(0, 122, 255, 0.15),
        inset 0 1px 2px rgba(0, 0, 0, 0.04);
    background: #fff;
}

.login form .input::placeholder,
.login form input::placeholder {
    color: #8e8e93;
}

/* Input wrapper (para senha) */
.login .user-pass-wrap {
    margin-bottom: 0;
}

.login .wp-pwd {
    position: relative;
}

/* Botão de mostrar/ocultar senha */
.login .wp-pwd .button.wp-hide-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px 8px;
    min-height: auto;
    background: transparent;
    border: none;
    color: #8e8e93;
    cursor: pointer;
    transition: color 0.2s ease;
}

.login .wp-pwd .button.wp-hide-pw:hover {
    color: #007AFF;
    background: transparent;
}

.login .wp-pwd .button.wp-hide-pw:focus {
    box-shadow: none;
    outline: none;
}

.login .wp-pwd .button.wp-hide-pw .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* ==================================================================
   REMEMBER ME / LEMBRAR-ME
   ================================================================== */
.login form .forgetmenot {
    float: none;
    margin: 16px 0;
}

.login form .forgetmenot label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #3c3c43;
    cursor: pointer;
}

/* Checkbox estilizado iOS */
.login form .forgetmenot input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin: 0;
    background: rgba(255, 255, 255, 0.8);
    border: 1.5px solid rgba(60, 60, 67, 0.2);
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.login form .forgetmenot input[type="checkbox"]:checked {
    background: #007AFF;
    border-color: #007AFF;
}

.login form .forgetmenot input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 3px;
    width: 6px;
    height: 11px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.login form .forgetmenot input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

/* ==================================================================
   SUBMIT BUTTON - iOS STYLE
   ================================================================== */
.login .submit {
    margin-top: 20px;
}

.wp-core-ui .button-primary,
.login .button-primary {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    letter-spacing: -0.2px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    text-shadow: none;
    -webkit-appearance: none;
    appearance: none;
    /* Cores e estilos personalizados são aplicados via CSS inline */
}

.wp-core-ui .button-primary:hover,
.login .button-primary:hover {
    transform: translateY(-1px);
}

.wp-core-ui .button-primary:active,
.login .button-primary:active {
    transform: translateY(0) scale(0.98);
}

.wp-core-ui .button-primary:focus,
.login .button-primary:focus {
    outline: none;
}

/* ==================================================================
   NAVIGATION LINKS
   ================================================================== */
#login #nav,
#login #backtoblog {
    text-align: center;
    padding: 0;
    margin: 20px 0 8px;
}

#login #nav a,
#login #backtoblog a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: inline-block;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

#login #nav a:hover,
#login #backtoblog a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Separador entre links */
#login #nav a:first-child::after {
    content: '|';
    margin: 0 8px;
    opacity: 0.5;
}

/* ==================================================================
   LANGUAGE SWITCHER
   ================================================================== */
.login .language-switcher {
    margin-top: 20px;
    text-align: center;
}

.login .language-switcher select {
    padding: 10px 36px 10px 14px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    color: #1c1c1e;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238e8e93' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.login .language-switcher select:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.login .language-switcher .button {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    background: rgba(0, 122, 255, 0.1);
    border: none;
    border-radius: 10px;
    color: #007AFF;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 8px;
}

.login .language-switcher .button:hover {
    background: rgba(0, 122, 255, 0.2);
}

/* ==================================================================
   ERROR / SUCCESS MESSAGES
   ================================================================== */
#login_error,
.login .message,
.login .success {
    margin: 0 0 20px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    line-height: 1.5;
}

#login_error {
    background: rgba(255, 59, 48, 0.1);
    border-left: 4px solid #FF3B30;
    color: #d62828;
}

.login .message,
.login .success {
    background: rgba(52, 199, 89, 0.1);
    border-left: 4px solid #34C759;
    color: #1a7431;
}

#login_error a {
    color: #d62828;
    font-weight: 600;
}

.login .message a,
.login .success a {
    color: #1a7431;
    font-weight: 600;
}

/* ==================================================================
   PRIVACY POLICY LINK
   ================================================================== */
.login .privacy-policy-page-link {
    text-align: center;
    margin-top: 16px;
}

.login .privacy-policy-page-link a {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.login .privacy-policy-page-link a:hover {
    color: #fff;
}

/* ==================================================================
   TWO-FACTOR / INTERIM LOGIN
   ================================================================== */
.login-action-backup_2fa #login,
.login-action-validate_2fa #login,
.interim-login #login {
    padding: 20px;
}

/* ==================================================================
   RESPONSIVE
   ================================================================== */
@media screen and (max-width: 480px) {
    /* Corrigir overflow e scroll no mobile - App-like experience */
    html {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    body.login {
        min-height: 100vh;
        min-height: 100dvh; /* Dynamic viewport height */
        min-height: -webkit-fill-available;
        overflow-y: auto;
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    #login {
        padding: 16px;
        max-width: 100% !important;
        width: 100% !important;
        min-height: auto;
        margin: 0 auto;
        box-sizing: border-box;
    }
    
    .login form {
        padding: 24px 20px;
        border-radius: 16px;
        margin-bottom: 16px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    #login h1 {
        margin-bottom: 16px;
        max-width: 100%;
    }
    
    #login h1 a,
    .login h1 a {
        height: 60px !important;
        margin-bottom: 16px;
        max-width: 200px !important;
        width: auto !important;
    }
    
    /* Ajustar campos de input no mobile - CRÍTICO: font-size 16px evita zoom no iOS */
    .login form .input,
    .login form input[type="text"],
    .login form input[type="password"],
    .login form input[type="email"] {
        font-size: 16px !important; /* Evita zoom automático no iOS */
        padding: 12px 14px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .wp-core-ui .button-primary,
    .login .button-primary {
        padding: 14px 20px;
        font-size: 16px !important; /* Evita zoom no iOS */
        margin-bottom: 12px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Links de navegação */
    #login #nav,
    #login #backtoblog {
        margin: 16px 0 12px;
    }
    
    #login #nav a,
    #login #backtoblog a {
        font-size: 14px;
        padding: 10px 14px;
        display: block;
        margin: 6px 0;
    }
    
    /* Remover separador entre links no mobile */
    #login #nav a:first-child::after {
        display: none;
    }
    
    /* Mensagens de erro/sucesso */
    #login_error,
    .login .message,
    .login .success {
        margin: 0 0 16px;
        padding: 12px 16px;
        font-size: 14px;
        max-width: 100%;
        box-sizing: border-box;
        word-wrap: break-word;
    }
    
    /* Language switcher */
    .login .language-switcher {
        margin-top: 16px;
        margin-bottom: 16px;
    }
    
    /* Forçar todos os elementos a respeitarem a largura da tela */
    * {
        max-width: 100vw;
    }
}

/* ==================================================================
   DARK MODE SUPPORT
   ================================================================== */
@media (prefers-color-scheme: dark) {
    .login form {
        background: rgba(44, 44, 46, 0.85);
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .login label {
        color: #ffffff;
    }
    
    .login form .input,
    .login form input[type="text"],
    .login form input[type="password"],
    .login form input[type="email"] {
        background: rgba(58, 58, 60, 0.9);
        border-color: rgba(255, 255, 255, 0.1);
        color: #ffffff;
    }
    
    .login form .input::placeholder,
    .login form input::placeholder {
        color: #8e8e93;
    }
    
    .login form .forgetmenot label {
        color: #ebebf5;
    }
    
    .login form .forgetmenot input[type="checkbox"] {
        background: rgba(58, 58, 60, 0.9);
        border-color: rgba(255, 255, 255, 0.15);
    }
    
    #login_error,
    .login .message,
    .login .success {
        background: rgba(44, 44, 46, 0.9);
    }
}

/* ==================================================================
   ANIMATIONS
   ================================================================== */
@keyframes loginFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.login #login {
    animation: loginFadeIn 0.5s ease-out;
}

.login form,
#login_error,
.login .message {
    animation: loginFadeIn 0.5s ease-out 0.1s both;
}

#login #nav,
#login #backtoblog {
    animation: loginFadeIn 0.5s ease-out 0.2s both;
}
