/* ============================================
   LOGIN PAGE STYLES - ENHANCED UX
   Ritmo: --spacing-md entre campos, --spacing-xl entre seções
   ============================================ */

/* Página: hero 100dvh + rodapé no scroll */
.login-page {
    position: relative;
    width: 100%;
}

.login-hero {
    min-height: 100vh;
    min-height: 100dvh;
    box-sizing: border-box;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(14px, 3.5vw, 28px) clamp(14px, 4vw, 24px);
    padding-bottom: max(14px, env(safe-area-inset-bottom, 0px));
}

.login-below-fold {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: clamp(1.25rem, 3vh, 2rem) clamp(14px, 4vw, 24px)
        max(2rem, env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

/* Card: altura natural, sem scroll interno (rolagem só na página) */
.login-card {
    max-width: 380px;
    width: 100%;
    flex: 0 1 auto;
    position: relative;
    animation: scaleIn 0.4s ease-out;
    overflow: visible;
    background: linear-gradient(
        135deg,
        rgba(139, 92, 246, 0.08) 0%,
        rgba(59, 130, 246, 0.08) 100%
    );
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: clamp(1rem, 3vw, 1.35rem) clamp(0.95rem, 3.5vw, 1.4rem);
    box-shadow: var(--shadow-2xl);
}

.login-session-banner {
    margin-bottom: var(--spacing-sm);
    padding: 8px 12px;
    background: rgba(234, 179, 8, 0.12);
    border: 1px solid rgba(234, 179, 8, 0.35);
    border-radius: 8px;
    color: #fbbf24;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

/* Logo Section */
.logo {
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.login-brand-title {
    font-size: clamp(var(--font-size-3xl), 5.5vw, var(--font-size-4xl));
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    margin: 0 0 var(--spacing-xs) 0;
    color: var(--text-primary);
}

.logo-subtitle {
    margin: 0.15rem 0 0;
    font-weight: var(--font-weight-medium);
    font-size: 11px;
    line-height: 1.35;
    color: var(--text-tertiary);
}

.login-card .fl-brand {
    margin: 0 auto 4px;
}

.login-card .fl-brand-logo.login-brand-img {
    height: clamp(30px, 7vw, 34px);
    max-width: 200px;
    margin: 0 auto;
}

/* Login Form */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-form .form-group {
    margin-bottom: 0;
}

/* Input Wrapper with Icon */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
    pointer-events: none;
    transition: color var(--transition-base);
}

.login-card .input-icon svg {
    width: 18px;
    height: 18px;
}

/* Login: tem .input-icon à esquerda e toggle à direita */
.login-card .input-wrapper input {
    padding-left: 40px;
    padding-right: 40px;
}

/* Registro: só tem toggle à direita (sem ícone à esquerda) */
.reg-modal-card .input-wrapper input {
    padding-left: 14px;
    padding-right: 40px;
}

.input-wrapper:focus-within .input-icon {
    color: var(--accent-primary);
}

/* Campos escuros como no restante da plataforma (evita fundo claro do autofill) */
.login-card .input-modern {
    min-height: 40px;
    padding-top: 8px;
    padding-bottom: 8px;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.12);
    font-size: 14px;
    line-height: 1.35;
}

.login-card .input-modern:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.18);
}

.login-card .input-modern::placeholder {
    color: var(--text-tertiary);
}

.login-card .input-modern:-webkit-autofill,
.login-card .input-modern:-webkit-autofill:hover,
.login-card .input-modern:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary);
    caret-color: var(--text-primary);
    transition: background-color 9999s ease-out 0s;
    box-shadow: 0 0 0 1000px var(--bg-secondary) inset;
    border-color: rgba(255, 255, 255, 0.12);
}

/* Toggle Password Button */
.toggle-password {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.toggle-password:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.toggle-password:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.login-card .toggle-password svg {
    width: 17px;
    height: 17px;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-sm);
    margin: 2px 0 0;
    min-height: 0;
    font-size: 12px;
}

/* Remember Me Checkbox */
.remember-me {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
    user-select: none;
}

.remember-me input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.remember-me span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.35;
    font-weight: var(--font-weight-medium);
}

/* Text Link */
.text-link {
    color: var(--text-secondary);
    font-weight: var(--font-weight-semibold);
    transition: all var(--transition-base);
    text-decoration: none;
}

.text-link:hover {
    color: var(--accent-primary);
}

.login-card .form-actions .text-link {
    font-size: 12px;
}

/* Divider Enhanced */
.divider {
    display: flex;
    align-items: center;
    margin: 10px 0;
    color: var(--text-tertiary);
    font-size: 10px;
    line-height: var(--line-height-normal);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-label);
    font-weight: var(--font-weight-semibold);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 50%, 
        transparent 100%);
}

.divider span {
    padding: 0 10px;
    text-align: center;
}

/* Botão primário: altura de toque alinhada aos campos */
.login-card .btn.btn-primary {
    min-height: 40px;
    padding-top: 9px;
    padding-bottom: 9px;
    font-size: 13px;
    letter-spacing: 0.06em;
}

/* Container do botão oficial Google (GSI renderButton — popup com seletor de contas) */
.google-signin-slot {
    width: 100%;
    min-height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.google-signin-slot > div {
    width: 100%;
}

/* Google Button Enhanced */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    width: 100%;
    min-height: 48px;
    padding: 12px var(--spacing-lg);
    background: var(--bg-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-snug);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}

.btn-google::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
    transition: left 0.5s ease;
}

.btn-google:hover::before {
    left: 100%;
}

.btn-google:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-google:active {
    transform: translateY(0);
}

.btn-google svg {
    flex-shrink: 0;
}

/* Form Footer */
.form-footer {
    text-align: center;
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.form-footer .text-link {
    font-weight: var(--font-weight-semibold);
}

/* Modal Subtitle */
.modal-subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    margin: calc(var(--spacing-sm) * -1) 0 var(--spacing-lg) 0;
}

/* Modal Description */
.modal-description {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
    margin-bottom: var(--spacing-lg);
    text-align: center;
}

/* Input Hint */
.input-hint {
    font-size: var(--font-size-xs);
    line-height: var(--line-height-normal);
    color: var(--text-tertiary);
    margin: var(--spacing-xs) 0 0 0;
}

/* Checkbox Modern */
.checkbox-modern {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-modern input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-primary);
    margin-top: 2px;
    flex-shrink: 0;
}

.checkbox-modern span {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-relaxed);
}

/* Footer Enhanced (abaixo do fold) */
.login-footer {
    margin-top: 0;
    padding: var(--spacing-md) 0 var(--spacing-sm);
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    /* escape the 520px parent constraint */
    position: relative;
    left: 50%;
    transform: translateX(-50%);
    width: 100vw;
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin: 0 auto var(--spacing-md);
    width: 80%;
    max-width: 900px;
}

.footer-link {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-base);
    text-decoration: none;
}

.footer-link:hover {
    color: var(--accent-primary);
}

.footer-separator {
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
}

.copyright {
    color: #909090; /* override: var(--text-tertiary) #7a7a7a falha ratio 4.4:1 no bg #0f1115; #909090 passa 5.1:1 */
    font-size: var(--font-size-xs);
    margin: 0;
}

/* Toast Container */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    pointer-events: none;
}

.toast-container > * {
    pointer-events: auto;
}

/* Loading States */
.btn [id$="ButtonText"] {
    transition: opacity var(--transition-fast);
}

.btn.loading [id$="ButtonText"] {
    opacity: 0;
}

.btn.loading .loading-spinner-sm {
    display: block !important;
    position: absolute;
}

/* Focus Visible States */
.btn:focus-visible,
.btn-google:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Error State for Inputs */
input[aria-invalid="true"] {
    border-color: var(--error);
}

input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Success State Animation */
@keyframes successPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
}

.success-animation {
    animation: successPulse 0.6s ease-out;
}

/* Disabled State */
.btn:disabled,
.btn-google:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .login-hero {
        padding: max(12px, env(safe-area-inset-top, 0px)) clamp(12px, 4vw, 20px)
            max(12px, env(safe-area-inset-bottom, 0px));
    }

    .login-card {
        max-width: 100%;
    }

    .login-below-fold {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .form-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-sm);
    }
    
    .footer-nav {
        width: 88%;
        gap: 4px 10px;
    }
    
    .toast-container {
        right: 10px;
        left: 10px;
        width: calc(100% - 20px);
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .input-wrapper input {
        border-width: 2px;
    }
    
    .btn-primary,
    .btn-google {
        border-width: 2px;
    }
}

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

/* Dark Mode Enhancements (já é dark por padrão, mas preparado para light) */
@media (prefers-color-scheme: light) {
    /* Futuro suporte a light mode */
}

/* ══════════════════════════════════════════════════════════════
   MODAL DE CADASTRO — design consistente com o restante do site
   ══════════════════════════════════════════════════════════════ */

.reg-modal-card {
    max-width: 440px;
    padding: 28px 28px 24px;
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(139, 92, 246, 0.08);
}

.reg-modal-card .modal-header-modern {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.reg-modal-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.reg-modal-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.15));
    border: 1px solid rgba(139, 92, 246, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a78bfa;
    flex-shrink: 0;
}

.reg-modal-card h2 {
    margin: 0 0 2px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary, #e6edf3);
    letter-spacing: -0.01em;
}

.reg-modal-sub {
    margin: 0;
    font-size: 12px;
    color: var(--text-tertiary, #8b949e);
}

/* Labels com ícone */
.reg-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary, #8b949e);
    margin-bottom: 6px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1;
}

.reg-label svg {
    color: #8b5cf6;
    flex-shrink: 0;
    position: relative;
    top: 0;
}

/* Campos com menos espaçamento no modal */
.reg-modal-card .form-group-modern {
    margin-bottom: 14px;
}

.reg-modal-card .input-modern {
    height: 44px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.reg-modal-card .input-modern:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(139, 92, 246, 0.6);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

/* Input com erro */
.input-modern.input-error {
    border-color: rgba(239, 68, 68, 0.7) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Input OK (válido) */
.input-modern.input-ok {
    border-color: rgba(34, 197, 94, 0.5) !important;
}

/* Mensagem de erro inline por campo */
.field-error-msg {
    display: block;
    font-size: 11.5px;
    color: #f87171;
    margin-top: 4px;
    padding-left: 2px;
    line-height: 1.4;
}

.reg-modal-card .input-hint {
    font-size: 11px;
    color: var(--text-tertiary, #8b949e);
    margin-top: 4px;
}

/* Botão submit */
.reg-submit-btn {
    height: 46px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    border-radius: 12px;
    margin-top: 4px;
}

/* Divider */
.reg-modal-card .divider {
    margin: 14px 0;
    font-size: 12px;
    color: var(--text-tertiary, #8b949e);
}

/* Form-group-modern dentro do modal */
.reg-modal-card .form-group-modern label:not(.checkbox-modern):not(.reg-label) {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary, #b1bac4);
    letter-spacing: 0.01em;
    text-transform: uppercase;
    margin-bottom: 6px;
    display: block;
}

@media (max-width: 480px) {
    .reg-modal-card {
        padding: 20px 16px 18px;
        border-radius: 14px;
    }
}

/* ══════════════════════════════════════════════════════════════
   TELA DE CRIANDO CONTA / CONTA CRIADA
   ══════════════════════════════════════════════════════════════ */
#regStatusOverlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(10, 12, 16, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    animation: fadeIn 0.2s ease;
}

#regStatusOverlay.active {
    display: flex;
}

.reg-status-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.reg-status-icon--loading {
    background: rgba(139, 92, 246, 0.12);
    border: 2px solid rgba(139, 92, 246, 0.3);
    animation: reg-pulse 1.6s ease-in-out infinite;
}

.reg-status-icon--success {
    background: rgba(34, 197, 94, 0.12);
    border: 2px solid rgba(34, 197, 94, 0.4);
    animation: reg-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes reg-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.25); }
    50%       { box-shadow: 0 0 0 14px rgba(139, 92, 246, 0); }
}

@keyframes reg-pop {
    from { transform: scale(0.6); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.reg-status-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.reg-status-text {
    text-align: center;
}

.reg-status-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #e6edf3;
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.reg-status-sub {
    font-size: 14px;
    color: #8b949e;
    margin: 0;
}

.reg-status-icon--success svg {
    color: #4ade80;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    gap: var(--spacing-md);
}

.loading-overlay p {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
