/*
  Alcance — tela de entrada.

  Copia fiel da tela de login do Sistema-Geral (frontend/pages/auth/css/Login.css):
  mesmo cartao de 440px, mesmos espacamentos, mesmos raios, mesmas sombras, mesma
  animacao de entrada. Quem usa os dois sistemas precisa reconhecer o Alcance na
  primeira olhada — por isso NADA aqui foi "melhorado".

  As unicas diferencas em relacao ao original, e o porque de cada uma:
    - marca Alcance (SVG inline) no lugar da logo da outra empresa;
    - sem webfont: o CSP e `default-src 'self'` e o Inter vinha de CDN. Fica a pilha do
      sistema — que e exatamente para onde o original tambem cai quando a CDN nao responde;
    - sem "Registre-se", sem "Esqueci a senha", sem "Voltar ao site": o Alcance tem um
      unico usuario, criado por linha de comando, nao tem recuperacao de senha e nao tem
      site institucional. Link que nao leva a lugar nenhum e pior que link nenhum.
*/

:root {
    /* Verde da marca — mesmos valores do token do Sistema-Geral (frontend/css/tokens.css),
       que e o que o servidor injeta na tela de login real. */
    --primary: #007349;
    --primary-dark: #005f3b;
    --primary-light: #34d399;
}

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

[hidden] { display: none !important; }

body {
    /* O cartao e sempre escuro; sem isto o navegador pinta os controles dele (a
       caixinha do "lembrar", a barra de rolagem) no tema CLARO e eles saem brancos
       no meio do escuro. No Sistema-Geral quem faz isso e o `body:not(.light-mode)`
       do tokens.css — aqui nao existe modo claro, entao e direto. */
    color-scheme: dark;
    font-family: 'Segoe UI', system-ui, Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: color-mix(in srgb, var(--primary, #10b981) 9%, #04070a);
    position: relative;
    /* overflow-x escondido (orbs decorativos nao geram scroll horizontal); overflow-y
       automatico para o card poder rolar em telas baixas / zoom 200% / paisagem. */
    overflow-x: hidden;
    overflow-y: auto;
}

/* ── Orbs de gradiente animados ── */
body::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary, #10b981) 18%, transparent), transparent 70%);
    top: -200px;
    left: -100px;
    animation: orbFloat1 8s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, color-mix(in srgb, var(--primary-light, var(--primary, #10b981)) 12%, transparent), transparent 70%);
    bottom: -150px;
    right: -100px;
    animation: orbFloat2 10s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes orbFloat1 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(60px, 40px) scale(1.1); }
}

@keyframes orbFloat2 {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(-50px, -30px) scale(1.15); }
}

/* ── Trama de pontos do fundo ── */
.login-bg-pattern {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 40px 40px;
    animation: drift 25s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes drift {
    0% { transform: translate(0, 0); }
    100% { transform: translate(40px, 40px); }
}

/* ── Entrada do cartao ── */
@keyframes cardFloat {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Cartao ── */
.card {
    background: rgba(10, 20, 15, 0.85);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    padding: 70px 46px 44px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: #fff;
    width: 440px;
    /* margin:auto num filho flex centraliza quando cabe E permite rolar ate o topo quando
       nao cabe (evita o card ser cortado sem poder rolar em telas baixas). */
    margin: auto;
    position: relative;
    z-index: 1;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.03) inset,
        0 0 120px color-mix(in srgb, var(--primary, #10b981) 4%, transparent);
    animation: cardFloat 0.8s ease-out;
}

/* ── Marca ── */
.card-logo {
    text-align: center;
    margin-bottom: 32px;
}

/* Mesmas medidas da <img> do original (84px, cantos 22px, subindo 42px para "sair"
   pela borda de cima do cartao). */
.card-logo .card-marca {
    height: 84px;
    width: 84px;
    border-radius: 22px;
    margin: -42px auto 4px;
    display: block;
    filter: drop-shadow(0 0 24px color-mix(in srgb, var(--primary, #10b981) 25%, transparent));
    position: relative;
    z-index: 2;
}

.card-logo .card-marca .fundo { fill: var(--primary, #10b981); }

.card-logo h1 {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 30%, var(--primary-light, var(--primary, #10b981)));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.card-logo p {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 500;
}

/* ── Campos ── */
.input-box {
    position: relative;
    margin-bottom: 18px;
}

.input-box input {
    width: 100%;
    height: 52px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: #fff;
    padding: 0 44px 0 18px;
    font-size: 14px;
    font-family: inherit;
    transition: background-color 0.3s, border-color 0.3s, opacity 0.3s;
    outline: none;
}

.input-box input:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: color-mix(in srgb, var(--primary, #10b981) 50%, transparent);
    box-shadow: 0 0 24px color-mix(in srgb, var(--primary, #10b981) 12%, transparent),
                0 0 0 3px color-mix(in srgb, var(--primary, #10b981) 6%, transparent);
}

.input-box input::placeholder {
    color: rgba(255, 255, 255, 0.55); /* contraste AA sobre o card escuro */
}

.input-box i {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.45);
    font-size: 18px;
    pointer-events: none;
    transition: color 0.3s;
}

/* Botao de mostrar/ocultar senha: e <button> (focavel pelo teclado), nao um <i> clicavel. */
.input-box button.toggle-senha {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    padding: 0;
}

.input-box button.toggle-senha i { position: static; transform: none; pointer-events: none; color: inherit; }
.input-box button.toggle-senha:hover { color: var(--primary, #10b981); }

.input-box input:focus + i {
    color: var(--primary, #10b981);
}

/* ── Aviso de Caps Lock ── */
.caps-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #fdcb6e;
    margin: -8px 0 14px;
}
.caps-hint i { font-size: 14px; }

/* ── Linha do "lembrar" ── */
.remember-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    margin-bottom: 22px;
}

.remember-row label {
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.3s;
}

.remember-row label:hover { color: #fff; }

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

/* ── Botao principal ── */
.btn-submit {
    width: 100%;
    height: 50px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    color: #fff;
    font-size: 15px;
    font-family: inherit;
    background: linear-gradient(135deg, var(--primary, #10b981), var(--primary-dark, var(--primary, #10b981)));
    transition: background-color 0.3s, border-color 0.3s, opacity 0.3s;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px color-mix(in srgb, var(--primary, #10b981) 15%, transparent);
}

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

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px color-mix(in srgb, var(--primary, #10b981) 45%, transparent),
                0 0 60px color-mix(in srgb, var(--primary, #10b981) 15%, transparent);
}

.btn-submit:hover::before { left: 100%; }
.btn-submit:active { transform: translateY(0); }

/* Enquanto entra, o botao fica travado: o clique repetido nao vira segunda tentativa. */
.btn-submit:disabled {
    cursor: default;
    opacity: 0.65;
    transform: none;
}
.btn-submit:disabled::before { left: -100%; }

/* ── Foco visivel por teclado (WCAG 2.4.7) ── */
.btn-submit:focus-visible,
.input-box input:focus-visible,
.input-box button.toggle-senha:focus-visible,
input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--primary-light, #34d399);
    outline-offset: 2px;
}

/* ── Toast ── */
.toast {
    display: none;
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    background: rgba(10, 20, 15, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    padding: 16px 20px;
    max-width: 380px;
    color: #fff;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.4s ease-out;
}

.toast.show {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast i {
    font-size: 24px;
    flex-shrink: 0;
}

.toast i.success { color: var(--primary, #10b981); }
.toast i.warning { color: #fdcb6e; }
.toast i.error { color: #e17055; }

.toast-text {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
}

.toast-sub {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Responsividade ── */
@media (max-width: 480px) {
    /* font-size >= 16px nos inputs evita o zoom automatico do Safari iOS ao focar. */
    .input-box input { font-size: 16px; }

    .card {
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        border-radius: 0;
        padding: 28px 28px calc(28px + env(safe-area-inset-bottom, 0px));
        display: flex;
        flex-direction: column;
        justify-content: center;
        border: none;
        background: rgba(255, 255, 255, 0.02);
        box-shadow: none;
    }

    .card-logo {
        margin-bottom: 36px;
    }

    .card-logo .card-marca {
        height: 64px;
        width: 64px;
    }

    .card-logo h1 {
        font-size: 26px;
    }

    .toast {
        left: 16px;
        right: 16px;
        max-width: none;
    }
}
