/* =============================================================
   ForensiQ — Login: "Corrente Viva"
   -------------------------------------------------------------
   Login unificado com o design system global. Usa tokens de
   main.css (--bg, --surface, --text, --accent, etc.) e suporta
   ambos os temas (dia/noite).

   Decisão de design: o login renderiza sempre em modo escuro (a
   cinematografia da constellation depende do contraste escuro).
   Isto é forçado via <html data-theme="dark"> no template, mas
   se o utilizador voltar ao dashboard, o tema guardado continua
   a ser respeitado. Ver login.html e login.js.

   Linhagem / créditos: docs/design/login-design-credits.md
   ============================================================= */

/* Container da página: ocupa ecrã inteiro, cancelando o container global. */
.container:has(.lp-page) {
    max-width: none;
    padding: 0;
    margin: 0;
}

.lp-page {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    overflow: hidden;
    position: relative;
}

/* Vinheta decorativa — apenas accent (âmbar). Usa --accent-tint nos dois
   gradientes radiais; nenhuma outra cor entra na vinheta. */

.lp-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 25% 20%, var(--accent-tint) 0%, transparent 50%),
        radial-gradient(ellipse at 75% 80%, var(--accent-tint) 0%, transparent 55%);
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

/* =============================================================
   PAINEL ESQUERDO — CORRENTE VIVA
   ============================================================= */

.lp-chain-panel {
    display: none;
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg,
        var(--bg-subtle) 0%,
        var(--bg) 60%,
        var(--bg-subtle) 100%);
    border-right: 1px solid var(--border);
}

.lp-chain-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse 80% 70% at center, #000 30%, transparent 90%);
    pointer-events: none;
    z-index: 1;
}

.lp-constellation {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: block;
    pointer-events: auto;
}

/* ---- Legenda institucional (fundo do painel) ---- */

.lp-chain-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: var(--sp-8) var(--sp-12) var(--sp-10);
    z-index: 5;
    background: linear-gradient(180deg,
                                transparent 0%,
                                var(--bg) 60%,
                                var(--bg) 100%);
    color: var(--text);
}

.lp-brand-row {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-bottom: var(--sp-5);
}

.lp-mark {
    width: 56px;
    height: 48px;
    flex-shrink: 0;
    display: block;
    color: var(--text);
}

.lp-brand-text h2 {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-tight);
    margin: 0;
    color: var(--text-emphasis);
}

.lp-brand-text p {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin: 2px 0 0;
    letter-spacing: 0.01em;
}

/* =============================================================
   PAINEL DIREITO — FORMULÁRIO (usa .card + .form-*)
   ============================================================= */

.lp-form-panel {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    padding: var(--sp-8) var(--sp-6);
    position: relative;
    z-index: 5;
    background:
        radial-gradient(ellipse 70% 50% at 50% 30%,
                        var(--accent-tint) 0%, transparent 60%),
        var(--bg);
}

.lp-form-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-4);
    padding: var(--sp-8) var(--sp-8) var(--sp-6);
    box-shadow: var(--shadow-lg);
    animation: lp-card-enter 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes lp-card-enter {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Brand compacto apenas no mobile */
.lp-mobile-brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding-bottom: var(--sp-6);
    margin-bottom: var(--sp-6);
    border-bottom: 1px solid var(--divider);
}

.lp-mark-sm {
    width: 48px;
    height: 40px;
    flex-shrink: 0;
    display: block;
    color: var(--text);
}

.lp-mobile-brand h2 {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-tight);
    margin: 0;
    color: var(--text-emphasis);
}

.lp-mobile-brand p {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin: 1px 0 0;
}

/* Cabeçalho do formulário */

.lp-form-header {
    margin-bottom: var(--sp-6);
}

.lp-form-header h1 {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    letter-spacing: var(--tracking-tight);
    color: var(--text-emphasis);
    margin: 0 0 var(--sp-2);
    line-height: 1.2;
}

.lp-form-header p {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    line-height: var(--lh-base);
    margin: 0;
}

/* Caixa de erro — reutiliza .login-error global (main.css) */
.lp-error { /* compat: alguns scripts toggle esta classe; mapeia para .login-error */
    background: var(--danger-tint);
    color: var(--danger);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r-2);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-4);
    display: none;
}
.lp-error.visible {
    display: block;
    animation: lp-error-in 0.3s ease-out both;
}
@keyframes lp-error-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Formulário */

.lp-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.lp-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 18px;
    margin-bottom: var(--sp-2);
}

.lp-caps-warn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--fs-micro);
    font-weight: var(--fw-medium);
    color: var(--warning);
    letter-spacing: 0.02em;
    animation: lp-fade-in 0.2s ease-out;
}

.lp-caps-warn svg {
    width: 12px;
    height: 12px;
}

@keyframes lp-fade-in {
    from { opacity: 0; transform: translateY(-2px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Input com ícone à esquerda + (opcional) botão à direita ------- */

.lp-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.lp-input-icon {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--t-fast) var(--ease);
    z-index: 1;
}

/* Reutiliza .form-input do design system + padding extra para o ícone */
.lp-form .form-input {
    padding-left: var(--sp-10);
}

.lp-input-wrap:focus-within .lp-input-icon {
    color: var(--accent);
}

/* Botão toggle palavra-passe */

.lp-pw-toggle {
    position: absolute;
    right: 6px;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    border-radius: var(--r-2);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--t-fast) var(--ease),
                background var(--t-fast) var(--ease);
    z-index: 2;
}

.lp-pw-toggle:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.lp-pw-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    color: var(--accent);
}

.lp-eye {
    width: 18px;
    height: 18px;
}

/* Botão submit — reutiliza .btn .btn-primary .btn-lg .btn-block, com
   variante "hero" que adiciona o selo luminoso (shine) como personalidade. */

.btn-hero {
    position: relative;
    overflow: hidden;
}

.btn-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.18) 50%,
        transparent 100%);
    transition: left 0.6s ease;
    pointer-events: none;
}

.btn-hero:hover:not(:disabled)::before { left: 100%; }

.btn-hero .btn-arrow {
    width: 16px;
    height: 16px;
    transition: transform var(--t-fast) var(--ease);
}

.btn-hero:hover:not(:disabled) .btn-arrow {
    transform: translateX(3px);
}

/* Link "Esqueceu a palavra-passe?" */

.lp-forgot {
    display: block;
    text-align: center;
    margin-top: var(--sp-1);
    font-size: var(--fs-sm);
    color: var(--text-muted);
    text-decoration: none;
    transition: color var(--t-fast) var(--ease);
}

.lp-forgot:hover {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.lp-forgot:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: var(--r-1);
}

/* Rodapé do cartão */

.lp-form-footer {
    margin-top: var(--sp-6);
    padding-top: var(--sp-5);
    border-top: 1px solid var(--divider);
    text-align: center;
}

.lp-version {
    font-size: var(--fs-micro);
    color: var(--text-subtle);
    letter-spacing: 0.02em;
}

.lp-mono {
    font-family: var(--font-mono);
    font-size: var(--fs-micro);
    color: var(--text-muted);
}

/* =============================================================
   RESPONSIVE — Desktop split, Mobile card único
   ============================================================= */

@media (min-width: 1024px) {
    .lp-chain-panel {
        display: block;
        max-width: 50%;
        flex: 1;
    }
    .lp-form-panel {
        max-width: 50%;
        flex: 1;
    }
    .lp-mobile-brand {
        display: none;
    }
    .lp-form-card {
        padding: var(--sp-10) var(--sp-10) var(--sp-8);
        max-width: 440px;
    }
    .lp-form-header h1 {
        font-size: var(--fs-2xl);
    }
}

@media (min-width: 1280px) {
    .lp-chain-caption {
        padding: var(--sp-8) var(--sp-16) var(--sp-10);
    }
    .lp-brand-text h2 {
        font-size: var(--fs-xl);
    }
}

/* =============================================================
   Acessibilidade — respeitar prefers-reduced-motion
   ============================================================= */

@media (prefers-reduced-motion: reduce) {
    .lp-form-card,
    .lp-error,
    .btn-hero::before {
        animation: none !important;
        transition: none !important;
    }
}

/* Autofill em fundo escuro — preservar visual do input */
.lp-form .form-input:-webkit-autofill,
.lp-form .form-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
    -webkit-text-fill-color: var(--text);
    transition: background-color 9999s;
    caret-color: var(--text);
}
