/* ============================================================================
   GranMoney - Site Institucional - Dark Mode para Login

   Aplicado quando <html data-theme="dark">. Default (claro) renderiza
   normalmente via custom.css.

   Referencia visual: granmoney web (login_localhost.jsp + css/login-dark.css)
   Padrao: tokens em [data-theme="dark"] (nao no :root global) para nao vazar.

   Cobre: login.html + login-dev.html (mesma estrutura DOM).
   Funcionalidades preservadas: validate(), togglePassword, GTM, JSON-LD,
   OAuth redirects (3 endpoints), loading overlay.
   ============================================================================ */

/* ============================================================================
   DESIGN TOKENS — apenas quando [data-theme="dark"] no <html>
   ============================================================================ */
html[data-theme="dark"] {
    --bg-base:        #0A0E1A;
    --bg-surface:     #141A26;
    --bg-elevated:    #232B3A;
    --bg-input:       #0F1420;
    --bg-hover:       rgba(255, 255, 255, 0.04);

    --text-primary:   #E8ECF3;
    --text-secondary: #9CA3AF;
    --text-muted:     #6B7280;
    --text-faint:     #4B5563;

    --border:         rgba(255, 255, 255, 0.07);
    --border-strong:  rgba(255, 255, 255, 0.12);
    --border-subtle:  rgba(255, 255, 255, 0.04);

    --brand:          #E8945D;
    --brand-hover:    #F0A574;
    --brand-active:   #D17F4A;
    --brand-soft:     rgba(232, 148, 93, 0.14);
    --brand-ring:     rgba(232, 148, 93, 0.32);

    --info:           #60A5FA;
    --danger:         #F87171;
    --success:        #34D399;
}

/* ============================================================================
   GLOW DECORATIVO + GRID SUTIL (apenas dark)
   Glows ficam fora da viewport, blur(40px) para suavidade.
   ============================================================================ */
html[data-theme="dark"] body::before,
html[data-theme="dark"] body::after {
    content: "";
    position: fixed;
    pointer-events: none;
    z-index: 0;
    width: 600px;
    height: 600px;
    filter: blur(40px);
}

/* Glow laranja - canto superior esquerdo */
html[data-theme="dark"] body::before {
    top: -200px;
    left: -200px;
    background: radial-gradient(circle, rgba(232, 148, 93, 0.18), transparent 60%);
}

/* Glow azul - canto inferior direito */
html[data-theme="dark"] body::after {
    bottom: -200px;
    right: -200px;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.10), transparent 55%);
}

/* Grid sutil de fundo — so visivel em dark mode.
   Em tema claro o div existe mas fica invisivel (background: transparent). */
.login-grid-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image: none;
}

html[data-theme="dark"] .login-grid-bg {
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.014) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.014) 1px, transparent 1px);
    background-size: 28px 28px;
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

/* ============================================================================
   LAYOUT — Container + Wrapper
   ============================================================================ */
/* Body — sempre com background do tema + altura completa */
body {
    min-height: 100vh;
}

html[data-theme="dark"] body {
    background: var(--bg-base) !important;
    color: var(--text-primary);
}

/* Container-login centraliza tudo verticalmente */
.container-login100 {
    min-height: 100vh;
    align-items: stretch !important;
}

html[data-theme="dark"] .container-login100 {
    background: var(--bg-base) !important;
    position: relative;
    z-index: 1;
}

/* IMPORTANTE: O wrapper agora e TRANSPARENTE — paineis sao soltos no body.
   Aplicado em ambos os temas. Layout: marca esquerda + card direita.
   O HTML tem .login100-form (que vira card) ANTES do aside.login-brand,
   mas com flex-direction: row-reverse o aside fica visualmente a ESQUERDA. */
.wrap-login100 {
    background: transparent !important;
    max-width: 1280px !important;
    margin: 0 auto !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    padding: 60px 40px 100px !important;
    gap: 60px !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh;
}

html[data-theme="dark"] .wrap-login100 {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* ============================================================================
   FORM antigo (.login100-form) — desativa o estilo legado pra usar .login-card
   ============================================================================ */
.login100-form {
    width: auto !important;
    min-height: 0 !important;
    background: transparent !important;
    padding: 0 !important;
}

/* Logo PNG antigo — removida do markup; regra abaixo so existe pra esconder
   caso alguma versao do cache exiba. */
.logo-login {
    display: none !important;
}

/* ============================================================================
   CARD DE LOGIN (.login-card) — novo container do form (substitui o wrap antigo)
   ============================================================================ */
.login-card {
    width: 100%;
    max-width: 460px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    padding: 40px 36px;
    box-sizing: border-box;
    color: #2b2b2b;
}

html[data-theme="dark"] .login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
}

/* Header do card (tile G + nome + titulo + subtitulo) */
.login-card-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-card-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.login-card-brand-tile {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffa500, #e07e00);
    display: grid;
    place-items: center;
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(255, 165, 0, 0.32);
}

html[data-theme="dark"] .login-card-brand-tile {
    background: linear-gradient(135deg, var(--brand), var(--brand-active));
    color: #0b1117;
    box-shadow: 0 6px 16px rgba(232, 148, 93, 0.32);
}

.login-card-brand-tile svg {
    width: 20px;
    height: 20px;
}

.login-card-brand-name {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #2b2b2b;
}

html[data-theme="dark"] .login-card-brand-name {
    color: var(--text-primary);
}

.login-card-brand-name em {
    color: #ffa500;
    font-style: normal;
}

html[data-theme="dark"] .login-card-brand-name em {
    color: var(--brand);
}

.login-card-title {
    font-size: 22px;
    font-weight: 700;
    color: #2b2b2b;
    margin: 0 0 6px;
}

html[data-theme="dark"] .login-card-title {
    color: var(--text-primary);
}

.login-card-subtitle {
    font-size: 13px;
    color: #6c757d;
    margin: 0;
}

html[data-theme="dark"] .login-card-subtitle {
    color: var(--text-secondary);
}

/* ============================================================================
   CAMPOS DO FORM (label + wrapper input com icone)
   ============================================================================ */
.login-card-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6c757d;
    margin: 0;
}

html[data-theme="dark"] .login-field-label {
    color: var(--text-secondary);
}

/* Wrapper input com icone embutido */
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #6c757d;
    pointer-events: none;
    display: grid;
    place-items: center;
}

html[data-theme="dark"] .login-input-icon {
    color: var(--text-muted);
}

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

/* Override do .input-custom dentro do wrap — padding pra acomodar icone */
.login-input-wrap .input-custom,
.login-input-wrap .login-input {
    padding-left: 42px !important;
    width: 100%;
    margin-bottom: 0 !important;
}

/* Campo senha tem botao olho a direita */
.login-input-wrap .login-input[type="password"],
.login-input-wrap .login-input[type="text"]#usuSenha {
    padding-right: 42px !important;
}

/* Botao toggle olho */
.login-toggle-password {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #6c757d;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.15s ease;
    padding: 0;
}

.login-toggle-password:hover {
    background: rgba(255, 165, 0, 0.08);
    color: #ffa500;
}

html[data-theme="dark"] .login-toggle-password {
    color: var(--text-muted);
}

html[data-theme="dark"] .login-toggle-password:hover {
    background: var(--brand-soft);
    color: var(--brand);
}

.login-toggle-password i {
    font-size: 16px;
}

/* ============================================================================
   BOTAO ENTRAR (com seta SVG)
   ============================================================================ */
.login-submit {
    margin-top: 8px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ffa500 !important;
    border: 1px solid #ffa500 !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    transition: all 0.2s ease;
    width: 100%;
    padding: 12px 20px !important;
    height: auto !important;
    line-height: 1.4 !important;
}

.login-submit:hover {
    background: #e07e00 !important;
    border-color: #e07e00 !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 165, 0, 0.32);
}

html[data-theme="dark"] .login-submit {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #0b1117 !important;
}

html[data-theme="dark"] .login-submit:hover {
    background: var(--brand-hover) !important;
    border-color: var(--brand-hover) !important;
    box-shadow: 0 6px 16px rgba(232, 148, 93, 0.32);
}

.login-submit svg {
    width: 18px;
    height: 18px;
}

/* ============================================================================
   LINKS (esqueceu senha / signup) + DIVISOR "ou"
   ============================================================================ */
.login-forgot {
    text-align: right;
    margin: 0;
    font-size: 13px;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px 0;
    color: #999;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

html[data-theme="dark"] .login-divider {
    color: var(--text-muted);
}

html[data-theme="dark"] .login-divider::before,
html[data-theme="dark"] .login-divider::after {
    background: var(--border-subtle);
}

.login-signup {
    margin: 0;
    text-align: center;
    font-size: 13px;
    color: #6c757d;
}

html[data-theme="dark"] .login-signup {
    color: var(--text-secondary);
}

/* ============================================================================
   FOOTER FIXO no rodape
   ============================================================================ */
.login-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 12px;
    color: #6c757d;
    background: transparent;
    z-index: 5;
    flex-wrap: wrap;
}

html[data-theme="dark"] .login-footer {
    color: var(--text-muted);
}

.login-footer a {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s ease;
}

.login-footer a:hover {
    color: #ffa500;
}

html[data-theme="dark"] .login-footer a:hover {
    color: var(--brand);
}

.login-footer-sep {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}

/* ============================================================================
   PAINEL DE MARCA LATERAL (.login-brand) — substitui a imagem .login100-more
   Visivel >= 1024px; em mobile fica oculto (como a imagem original).
   Replica o painel de marca do granmoney login_localhost.jsp.
   ============================================================================ */

/* Painel marca — solto no body, sem fundo/borda (igual granmoney) */
.login-brand {
    display: none;
    flex: 1;
    max-width: 520px;
    padding: 0;
    box-sizing: border-box;
    background: transparent !important;
    color: #2b2b2b;
    align-self: center;
}

@media (min-width: 992px) {
    .login-brand {
        display: block;
    }
}

html[data-theme="dark"] .login-brand {
    background: transparent !important;
    color: var(--text-primary);
}

/* Header (logo tile + nome marca) */
.login-brand-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
}

.login-brand-tile {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #ffa500, #e07e00);
    display: grid;
    place-items: center;
    box-shadow: 0 12px 32px rgba(255, 165, 0, 0.32);
    flex-shrink: 0;
}

html[data-theme="dark"] .login-brand-tile {
    background: linear-gradient(135deg, var(--brand), var(--brand-active));
    box-shadow: 0 12px 32px rgba(232, 148, 93, 0.32);
}

.login-brand-tile svg {
    width: 28px;
    height: 28px;
    color: #1a0f08;
}

.login-brand-name {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #2b2b2b;
}

html[data-theme="dark"] .login-brand-name {
    color: var(--text-primary);
}

.login-brand-name em {
    color: #ffa500;
    font-style: normal;
}

html[data-theme="dark"] .login-brand-name em {
    color: var(--brand);
}

/* Tagline (h2 grande) */
.login-brand-tagline {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: #2b2b2b;
    margin: 0 0 16px;
}

html[data-theme="dark"] .login-brand-tagline {
    color: var(--text-primary);
}

.login-brand-tagline em {
    color: #ffa500;
    font-style: normal;
}

html[data-theme="dark"] .login-brand-tagline em {
    color: var(--brand);
}

/* Descricao curta */
.login-brand-desc {
    font-size: 14px;
    color: #6c757d;
    line-height: 1.6;
    max-width: 420px;
    margin: 0 0 36px;
}

html[data-theme="dark"] .login-brand-desc {
    color: var(--text-secondary);
}

/* Lista de features */
.login-brand-features {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-brand-feature {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.login-brand-feature-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: rgba(255, 165, 0, 0.14);
    color: #ffa500;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    margin-top: 2px;
}

html[data-theme="dark"] .login-brand-feature-icon {
    background: var(--brand-soft);
    color: var(--brand);
}

.login-brand-feature-icon svg {
    width: 14px;
    height: 14px;
}

.login-brand-feature-title {
    font-size: 14px;
    font-weight: 600;
    color: #2b2b2b;
    margin: 0 0 4px;
}

html[data-theme="dark"] .login-brand-feature-title {
    color: var(--text-primary);
}

.login-brand-feature-desc {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.5;
    margin: 0;
}

html[data-theme="dark"] .login-brand-feature-desc {
    color: var(--text-secondary);
}

/* ============================================================================
   INPUTS
   ============================================================================ */
html[data-theme="dark"] .input-custom {
    background: var(--bg-input) !important;
    border: 1px solid var(--border-strong) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .input-custom::placeholder {
    color: var(--text-muted) !important;
}

html[data-theme="dark"] .input-custom:hover,
html[data-theme="dark"] .input-custom:focus,
html[data-theme="dark"] .input-custom.focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-ring) !important;
    outline: none !important;
}

html[data-theme="dark"] .input-custom.has-error,
html[data-theme="dark"] .has-error .input-custom {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18) !important;
}

/* Autofill (Chrome) - evita amarelo legado em dark */
html[data-theme="dark"] .input-custom:-webkit-autofill,
html[data-theme="dark"] .input-custom:-webkit-autofill:hover,
html[data-theme="dark"] .input-custom:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    caret-color: var(--text-primary);
    transition: background-color 5000s ease-in-out 0s;
}

/* ============================================================================
   TOGGLE OLHO (bi-eye-slash / bi-eye)
   No login.html o icone tem id #togglePassword com estilo inline.
   Sobrescrevemos a cor — o resto (posicionamento, cursor) e legado.
   ============================================================================ */
html[data-theme="dark"] #togglePassword {
    color: var(--text-muted) !important;
    transition: color 0.15s ease;
}

html[data-theme="dark"] #togglePassword:hover {
    color: var(--brand) !important;
}

/* ============================================================================
   BOTAO ENTRAR (.btn-form)
   ============================================================================ */
html[data-theme="dark"] .btn-form {
    background: var(--brand) !important;
    border-color: var(--brand) !important;
    color: #0b1117 !important;
    font-weight: 700 !important;
    transition: all 0.2s ease;
}

html[data-theme="dark"] .btn-form:hover {
    background: var(--brand-hover) !important;
    border-color: var(--brand-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(232, 148, 93, 0.32);
}

html[data-theme="dark"] .btn-form:active {
    transform: translateY(0);
    background: var(--brand-active) !important;
}

/* ============================================================================
   MENSAGENS DE ERRO / SUCESSO
   ============================================================================ */
html[data-theme="dark"] .errorform {
    color: var(--danger) !important;
    background: rgba(248, 113, 113, 0.10);
    border-left: 3px solid var(--danger);
    padding: 10px 14px;
    border-radius: 4px;
}

html[data-theme="dark"] .successform {
    color: var(--success) !important;
    background: rgba(52, 211, 153, 0.10);
    border-left: 3px solid var(--success);
    padding: 10px 14px;
    border-radius: 4px;
}

html[data-theme="dark"] .errorform p,
html[data-theme="dark"] .successform p {
    margin-bottom: 0 !important;
}

/* ============================================================================
   LINKS (.color) — "Esqueceu sua senha?" / "Crie agora :)"
   ============================================================================ */
html[data-theme="dark"] .color,
html[data-theme="dark"] a.color {
    color: var(--brand) !important;
    text-decoration: none;
    transition: color 0.15s ease;
}

html[data-theme="dark"] .color:hover,
html[data-theme="dark"] a.color:hover {
    color: var(--brand-hover) !important;
    text-decoration: underline;
}

html[data-theme="dark"] .create-account {
    color: var(--text-secondary) !important;
}

/* ============================================================================
   DIVISORES (.divider, .divider-lg, .divider-sm, .divider-line, <hr>)
   ============================================================================ */
html[data-theme="dark"] hr,
html[data-theme="dark"] .divider-line {
    border-color: var(--border) !important;
    opacity: 1 !important;
}

/* ============================================================================
   PARAGRAFOS DE TEXTO LONGO (rodape do form)
   ============================================================================ */
html[data-theme="dark"] .login100-form p:not(.create-account) {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .login100-form .text-center {
    color: var(--text-secondary) !important;
}

/* ============================================================================
   LOADING OVERLAY (#loading)
   ============================================================================ */
html[data-theme="dark"] #loading {
    background: rgba(10, 14, 26, 0.85) !important;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

/* ============================================================================
   TOGGLE BUTTON (floating top-right)
   Aparece em ambos os temas (light e dark) — usuario alterna por aqui.
   ============================================================================ */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #d7dbdf;
    background: #ffffff;
    color: #6c757d;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    border-color: #ffa500;
    color: #ffa500;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.theme-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 165, 0, 0.25);
}

/* Em tema claro: mostrar lua (vai pra dark). Em dark: mostrar sol (vai pra light). */
.theme-toggle .bi-moon { display: inline-block; }
.theme-toggle .bi-sun  { display: none; }

html[data-theme="dark"] .theme-toggle {
    background: var(--bg-surface);
    border-color: var(--border-strong);
    color: var(--text-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .theme-toggle:hover {
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 6px 16px rgba(232, 148, 93, 0.32);
}

html[data-theme="dark"] .theme-toggle:focus {
    box-shadow: 0 0 0 3px var(--brand-ring);
}

html[data-theme="dark"] .theme-toggle .bi-moon { display: none; }
html[data-theme="dark"] .theme-toggle .bi-sun  { display: inline-block; }

/* ============================================================================
   RESPONSIVIDADE — mobile
   ============================================================================ */
@media (max-width: 991px) {
    .wrap-login100 {
        padding: 80px 16px 80px !important;
        gap: 0 !important;
    }

    .login-brand {
        display: none !important;
    }

    .login-card {
        max-width: 460px;
        margin: 0 auto;
        padding: 32px 24px;
    }

    .login-footer {
        position: static;
        padding: 24px 16px;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px;
        border-radius: 12px;
    }

    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .login-footer {
        font-size: 11px;
        gap: 8px;
    }
}

/* ============================================================================
   ACESSIBILIDADE — focus visivel para teclado
   ============================================================================ */
html[data-theme="dark"] a:focus-visible,
html[data-theme="dark"] button:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Preferencia reduzida de movimento — respeita configuracao do SO */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    html[data-theme="dark"] .btn-form,
    html[data-theme="dark"] #togglePassword,
    html[data-theme="dark"] .color {
        transition: none !important;
    }
}
