﻿/* Tela de login (e telas irmas: EsqueciSenha, RecuperacaoSenha).
 * Card horizontal com painel de arte a esquerda e formulario a direita.
 * Tokens adicionais escopados em .ns-login-body para nao vazar para o resto
 * do app — EMNG.css ja define --primary, --radius, --secondary-*, --danger,
 * --warning-* etc. Aqui completamos os que faltam (--text*, --surface-border,
 * --shadow-*, --radius-md). */

/* Box-sizing reset local — robustez contra falha de CDN do Bootstrap reboot.
 * Sem isso, width:100% + padding empurra o ns-login-form-side alem da viewport. */
.ns-login-body,
.ns-login-body *,
.ns-login-body *::before,
.ns-login-body *::after {
    box-sizing: border-box;
}

.ns-login-body {
    --text: rgb(30, 41, 59);
    --text-light: rgb(71, 85, 105);
    --text-muted: rgb(100, 116, 139);
    --surface-border: rgb(220, 224, 238);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
    --radius-md: 8px;
    --login-bg: #F1F5F9;

    min-height: 100vh;
    margin: 0;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--login-bg) !important;
    color: var(--text);
}

/* Tema escuro — sobrescreve os tokens scoped do .ns-login-body
 * (que tem precedencia sobre [data-theme="dark"] :root). */
[data-theme="dark"] .ns-login-body {
    --text: #e2e8f0;
    --text-light: #cbd5e1;
    --text-muted: #94a3b8;
    --surface-border: #334155;
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.50);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.60);
    --login-bg: #0f172a;
}

.ns-login-body .container {
    max-width: none !important;
    padding: 0;
}

.ns-login-body main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ns-login-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.ns-login-page {
    display: flex;
    width: 100%;
    max-width: 1040px;
    min-height: 520px;
    background: var(--content);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg), 0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--surface-border);
    margin: 0 auto;
}

.ns-login-orientacoes {
    width: 100%;
    max-width: 1040px;
    background: var(--content);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--surface-border);
    padding: 1.5rem 2rem;
}

.ns-login-orientacoes h2 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
    margin: 0 0 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ns-login-orientacoes h2 i {
    color: var(--primary);
}

.ns-login-orientacoes ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.55;
}

.ns-login-orientacoes ul li {
    margin-bottom: 0.4rem;
}

.ns-login-orientacoes a {
    color: var(--primary);
    word-break: break-all;
}

.ns-login-orientacoes a:hover {
    text-decoration: underline !important;
}

.ns-login-side {
    flex: 1;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.ns-login-side__bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.ns-login-side__logo-link {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    max-width: 360px;
    display: block;
    line-height: 0;
    border-radius: var(--radius-md);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.ns-login-side__logo-link:hover,
.ns-login-side__logo-link:focus-visible {
    transform: translate(-50%, -50%) scale(1.02);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
    outline: none;
}

.ns-login-side__logo {
    width: 100%;
    height: auto;
    display: block;
}

.ns-login-form-side {
    width: 460px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem;
    background: var(--content);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.ns-login-form-inner {
    width: 100%;
    max-width: 380px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ns-login-form-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ns-login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1.25rem;
    text-align: center;
    margin-bottom: 2rem;
}

.ns-login-logo__escola {
    max-width: 340px;
    max-height: 110px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

/* Logo Escolar Manager ao lado da logo da escola — visivel apenas no
 * breakpoint mobile/tablet (mesmo ponto onde .ns-login-side fica oculto),
 * pra preservar a identidade visual da EM no login quando o painel
 * lateral nao aparece. */
.ns-login-logo__em {
    display: none;
    line-height: 0;
    border-radius: var(--radius-md);
    transition: transform 0.15s ease, filter 0.15s ease;
}

.ns-login-logo__em img {
    max-width: 160px;
    max-height: 70px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.ns-login-logo__em:hover,
.ns-login-logo__em:focus-visible {
    transform: scale(1.04);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
    outline: none;
}

.ns-login-title {
    text-align: center;
    margin-bottom: 1.75rem;
}

.ns-login-title h1 {
    font-size: 18px;
    font-weight: 400;
    color: var(--text);
    margin: 0 0 0.2rem;
}

.ns-login-title p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.ns-login-field {
    margin-bottom: 1.25rem;
}

.ns-login-label {
    display: block;
    font-size: 13px;
    font-weight: 400 !important;
    color: var(--text-light);
    margin-bottom: 0.35rem;
    cursor: default;
}

.ns-login-input-wrap {
    display: flex;
    align-items: center;
    border: 1px solid var(--surface-border);
    border-radius: var(--radius);
    background: var(--content);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ns-login-input-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.ns-login-input-wrap__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.ns-login-input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.6rem 0.5rem 0.6rem 0;
    font-size: 14px;
    color: var(--text);
    background: transparent;
    width: 100%;
    min-width: 0;
}

.ns-login-input-wrap input::placeholder {
    color: var(--text-muted);
}

.ns-login-input-wrap__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
}

.ns-login-input-wrap__toggle:hover {
    color: var(--text-light);
}

.ns-login-input-wrap.is-invalid {
    border-color: var(--danger);
    animation: ns-login-shake 0.4s ease;
}

.ns-login-btn,
.ns-login-btn:focus,
.ns-login-btn:active {
    width: 100%;
    padding: 0.75rem;
    font-size: 14px;
    color: #FFFFFF;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    margin-top: 0.5rem;
    transition: background 0.2s, box-shadow 0.25s, transform 0.15s;
}

.ns-login-btn__text,
.ns-login-btn__text i {
    color: #FFFFFF !important;
}

.ns-login-btn__text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 14px;
}

.ns-login-btn__text i {
    font-size: 14px;
    transition: transform 0.25s;
}

.ns-login-btn:hover {
    background: var(--primary-dark);
    box-shadow: 0 8px 18px rgba(0, 123, 255, 0.32);
    transform: translateY(-1px);
}

.ns-login-btn:hover .ns-login-btn__text i {
    transform: translateX(3px);
}

.ns-login-btn:active {
    transform: translateY(0) scale(0.99);
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.25);
}

.ns-login-btn[disabled] {
    opacity: 0.8;
    cursor: progress;
}

.ns-login-btn.is-loading .ns-login-btn__text {
    visibility: hidden;
}

.ns-login-btn.is-loading .ns-login-btn__spinner {
    display: block;
}

.ns-login-btn__spinner {
    display: none;
    position: absolute;
    inset: 0;
    margin: auto;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: ns-login-spin 0.6s linear infinite;
}

.ns-login-link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: -0.25rem 0 1rem;
}

.ns-login-link-row a {
    font-size: 13px;
    color: var(--primary);
}

/* Variante usada quando so' o link "Esqueceu a senha?" existe (apos a
 * remocao do "Manter-me conectado") — alinha o link a direita. */
.ns-login-link-row--end {
    justify-content: flex-end;
}

.ns-login-link-row a:hover {
    text-decoration: underline !important;
}

.ns-login-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding-top: 1.5rem;
    font-size: 12px;
    color: var(--text-muted);
}

.ns-login-footer a {
    color: var(--text-muted);
}

.ns-login-footer a:hover {
    color: var(--primary);
    text-decoration: underline !important;
}

.ns-login-version {
    font-size: 10px;
    color: var(--text-muted);
    padding-top: 4px;
}

@keyframes ns-login-spin {
    to { transform: rotate(360deg); }
}

@keyframes ns-login-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

@media (max-width: 960px) {
    .ns-login-body { padding: 1rem; }
    .ns-login-page { max-width: 480px; min-height: 0; }
    .ns-login-side { display: none; }
    .ns-login-form-side { width: 100%; }

    /* Painel lateral (onde a logo EM aparece no desktop) esta oculto —
     * mostramos as duas logos EMPILHADAS no header do form:
     *   - EM em cima (maior, identidade principal)
     *   - escola embaixo (menor) */
    .ns-login-logo {
        flex-direction: column;
        gap: 0.85rem;
    }
    .ns-login-logo__em {
        display: inline-block;
        order: 0;
    }
    .ns-login-logo__em img {
        max-width: 220px;
        max-height: 80px;
    }
    .ns-login-logo__escola {
        order: 1;
        max-width: 160px;
        max-height: 70px;
    }
}

/* Em telas bem estreitas, reduz um pouco mais ambas as logos pra nao
 * empurrar o form pra baixo. */
@media (max-width: 420px) {
    .ns-login-logo__em img {
        max-width: 180px;
        max-height: 68px;
    }
    .ns-login-logo__escola {
        max-width: 130px;
        max-height: 58px;
    }
    .ns-login-logo {
        gap: 0.6rem;
    }
}

@media (max-width: 480px) {
    .ns-login-body { padding: 0; }
    .ns-login-page { border-radius: 0; min-height: 100vh; box-shadow: none; border: none; }
    .ns-login-form-side { padding: 2rem 1.5rem; }
    .ns-login-form-inner { max-width: 100%; }
    .ns-login-orientacoes { border-radius: 0; border-left: none; border-right: none; padding: 1.25rem 1.5rem; }
}
