/**
 * Escola 360 — Login (Fase R3 da reconciliação VPS → baseline seguro)
 *
 * Visual de referência: index.html implantado na VPS (layout dividido com
 * painel institucional escuro + painel branco de autenticação). Estilos
 * externos para manter a página compatível com CSP estrita (zero <style>).
 * Ajustes deliberados sobre a referência: tons de cinza dos textos auxiliares
 * escurecidos para contraste WCAG AA e foco visível em todos os controles.
 */

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

:root {
    --ink: #0f172a;
    --ink-2: #334155;
    --ink-3: #64748b;
    --line: #e4e8f0;
    --brand: #4f46e5;
    --brand-ink: #3730a3;
    --surface: #ffffff;
    --canvas: #f7f8fc;
    --danger: #dc2626;
    --focus: 0 0 0 3px rgba(79, 70, 229, 0.16);
}

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--canvas);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.auth-shell {
    display: grid;
    grid-template-columns: minmax(34rem, 1.06fr) minmax(31rem, 0.94fr);
    min-height: 100dvh;
}

/* ==========================================================
   PAINEL INSTITUCIONAL (esquerda)
   ========================================================== */
.brand-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(2.5rem, 6vw, 6.5rem);
    isolation: isolate;
    background:
        radial-gradient(ellipse at 78% 18%, rgba(24, 109, 255, 0.42) 0%, rgba(13, 70, 178, 0.16) 34%, transparent 64%),
        radial-gradient(ellipse at 18% 86%, rgba(0, 86, 255, 0.16) 0%, transparent 48%),
        linear-gradient(145deg, #020916 0%, #06142f 46%, #0b2f6f 100%);
    color: #fff;
    overflow: hidden;
}

/* Malha técnica: linhas e pontos são CSS, leves e independentes de imagem. */
.brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -2;
    background-image:
        radial-gradient(circle, rgba(31, 132, 255, 0.72) 1px, transparent 1.6px),
        linear-gradient(rgba(48, 133, 255, 0.095) 1px, transparent 1px),
        linear-gradient(90deg, rgba(48, 133, 255, 0.095) 1px, transparent 1px);
    background-size: 48px 48px, 48px 48px, 48px 48px;
    background-position: 0 0, 0 0, 0 0;
    mask-image: linear-gradient(90deg, transparent 0%, #000 20%, #000 82%, transparent 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 20%, #000 82%, transparent 100%);
    pointer-events: none;
}

.brand-panel::after {
    content: '';
    position: absolute;
    z-index: -1;
    width: min(58vw, 54rem);
    aspect-ratio: 1;
    top: -38%;
    right: -42%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(25, 112, 255, 0.4) 0%, rgba(17, 79, 195, 0.12) 46%, transparent 70%);
    filter: blur(2px);
    pointer-events: none;
}

.brand-panel > * { position: relative; }

.brand-atmosphere {
    position: absolute;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.brand-atmosphere__arc {
    position: absolute;
    width: 37rem;
    height: 37rem;
    top: 4%;
    right: -27rem;
    border: 1px solid rgba(49, 140, 255, 0.42);
    border-radius: 5rem;
    transform: rotate(45deg);
    box-shadow: 0 0 42px rgba(20, 105, 255, 0.08);
}

.brand-atmosphere__arc--inner {
    width: 33rem;
    height: 33rem;
    top: 7%;
    right: -24.5rem;
    border-color: rgba(81, 158, 255, 0.26);
}

.brand-atmosphere__beam {
    position: absolute;
    height: 1px;
    background: linear-gradient(90deg, transparent, #2a9cff 28%, rgba(45, 148, 255, 0.16) 68%, transparent);
    box-shadow: 0 0 12px rgba(42, 156, 255, 0.85);
}

.brand-atmosphere__beam--top {
    width: 52%;
    top: 8%;
    left: 7%;
    opacity: 0.42;
}

.brand-atmosphere__beam--bottom {
    width: 66%;
    left: 8%;
    bottom: 10%;
    opacity: 0.68;
}

.brand-content {
    display: flex;
    flex-direction: column;
    gap: clamp(3.25rem, 7vh, 5.75rem);
    width: min(100%, 43rem);
}

.brand-partners {
    display: flex;
    align-items: stretch;
    gap: clamp(1rem, 2vw, 1.6rem);
}

.brand-copy { max-width: 42rem; }

.brand-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    font-size: 0.82rem;
    font-weight: 650;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #bfd7ff;
    margin-bottom: 1.3rem;
}

.brand-eyebrow i {
    display: inline-grid;
    place-items: center;
    width: 2.55rem;
    height: 2.55rem;
    border: 1px solid rgba(79, 164, 255, 0.76);
    border-radius: 0.9rem;
    color: #62b2ff;
    font-size: 1.25rem;
    background: rgba(18, 93, 201, 0.16);
    box-shadow: inset 0 0 18px rgba(47, 139, 255, 0.08), 0 0 24px rgba(35, 129, 255, 0.1);
}

/* Cor explícita: os CSS base do sistema definem h1 em tom escuro */
.brand-copy h1 {
    max-width: 42rem;
    font-size: clamp(3rem, 5vw, 5.3rem);
    line-height: 0.98;
    font-weight: 800;
    letter-spacing: -0.045em;
    color: #ffffff;
    text-wrap: balance;
    text-shadow: 0 2px 22px rgba(0, 24, 74, 0.56);
}

.brand-copy__rule {
    display: block;
    width: min(22rem, 64%);
    height: 1px;
    margin-top: clamp(2rem, 4vh, 3.2rem);
    background: linear-gradient(90deg, transparent 0%, #209aff 18%, #4cb0ff 66%, transparent 100%);
    box-shadow: 0 0 13px rgba(40, 158, 255, 0.9);
}

/* Chip branco: as marcas são coloridas e não têm contraste sobre o escuro */
.brand-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(10rem, 13vw, 12.5rem);
    aspect-ratio: 1.08 / 1;
    min-height: 9.5rem;
    background: linear-gradient(145deg, #ffffff 0%, #f4f8ff 100%);
    border: 1px solid rgba(190, 218, 255, 0.92);
    border-radius: 1.5rem;
    padding: 1rem;
    line-height: 0;
    box-shadow:
        0 20px 45px rgba(0, 6, 25, 0.45),
        0 0 28px rgba(49, 146, 255, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.brand-chip img { display: block; width: auto; height: auto; }
.brand-chip--semec img { width: min(100%, 9.5rem); }
.brand-chip--govex img { width: min(100%, 10rem); }

/* ==========================================================
   PAINEL DE ACESSO (direita)
   ========================================================== */
.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: clamp(1.5rem, 4vh, 2.75rem) clamp(2rem, 6vw, 5rem);
    background: var(--surface);
    overflow-y: auto;
}

.login-wrapper {
    width: 100%;
    max-width: 25.5rem;
    margin: auto;
}

.login-head { margin-bottom: 1.45rem; }

.login-head__mark {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

/* A marca do produto identifica o formulário; as marcas institucionais ficam
   no painel esquerdo, cada uma aparecendo uma única vez. */
.login-head__mark img { width: 9.4rem; height: auto; display: block; }

.login-head h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.login-head p {
    margin-top: 0.4rem;
    font-size: 0.9rem;
    color: var(--ink-3);
}

/* ---------- Formulário ---------- */
.login-form { display: flex; flex-direction: column; gap: 0.9rem; }

.field label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 0.4rem;
}

.field__control { position: relative; }

.field__control input {
    width: 100%;
    height: 46px;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 0 2.75rem 0 0.9rem;
    font: 400 0.94rem 'Inter', sans-serif;
    color: var(--ink);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.field__control input::placeholder { color: #8b95a9; }

.field__control input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--focus);
}

.field__control input.error { border-color: var(--danger); }

.field__icon {
    position: absolute;
    top: 50%;
    right: 0.85rem;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 1.05rem;
    line-height: 0;
    background: none;
    border: none;
    padding: 0;
}

button.field__icon {
    cursor: pointer;
    /* alvo de toque mínimo sem alterar o desenho do campo */
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    right: 0.15rem;
}

button.field__icon:hover { color: var(--ink-2); }

.field__error {
    display: none;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--danger);
}

.field__error.visible { display: block; }

/* Erro do formulário (falha de credencial/conexão), próximo ao botão */
.form-feedback {
    display: none;
    padding: 0.65rem 0.8rem;
    border: 1px solid #fecaca;
    border-radius: 11px;
    background: #fef2f2;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #991b1b;
}

.form-feedback.visible { display: block; }

.form-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.84rem;
}

.form-check {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    color: var(--ink-2);
    cursor: pointer;
}

.form-check input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }

.form-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--brand);
    font-weight: 500;
    text-decoration: none;
}

.form-link:hover { text-decoration: underline; }

.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    height: 46px;
    margin-top: 0.35rem;
    border: none;
    border-radius: 11px;
    background: var(--brand);
    color: #fff;
    font: 600 0.94rem 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.btn-submit:hover { background: var(--brand-ink); }
.btn-submit:active { transform: translateY(1px); }
.btn-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* Foco visível por teclado em todos os controles interativos */
.btn-submit:focus-visible,
.btn-face:focus-visible,
button.field__icon:focus-visible,
.form-link:focus-visible,
.form-check input:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ---------- Acesso alternativo (reconhecimento facial) ---------- */
.login-divider {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1.1rem 0 0.75rem;
    color: var(--ink-3);
    font-size: 0.75rem;
    font-weight: 600;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--line);
}

.btn-face {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 46px;
    border: 1.5px solid #d0d7e2;
    border-radius: 12px;
    background: #fff;
    color: #1d4ed8;
    font: 700 0.9rem 'Inter', sans-serif;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.btn-face:hover:not(:disabled) { border-color: var(--brand); background: #f8f9ff; }

.btn-face:disabled {
    color: var(--ink-3);
    border-style: dashed;
    cursor: not-allowed;
    background: #f8fafc;
}

.face-hint {
    margin-top: 0.45rem;
    font-size: 0.76rem;
    line-height: 1.5;
    color: var(--ink-3);
    text-align: center;
}

.face-modal[hidden] { display: none; }

.face-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: radial-gradient(1200px 800px at 50% 0%, #12224f 0%, #070e24 60%, #05091a 100%);
}

.face-card {
    width: min(100%, 390px);
    padding: 1.25rem;
    border: 1px solid rgba(120, 170, 255, 0.22);
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(30, 52, 102, 0.65), rgba(12, 22, 52, 0.86));
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.face-card__head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.9rem;
}

.face-card__head img {
    width: auto;
    height: 42px;
    padding: 0.35rem 0.55rem;
    border-radius: 10px;
    background: #fff;
}

.face-card__head h3 {
    margin: 0;
    color: #fff;
    font-size: 1rem;
}

.face-card__close {
    width: 34px;
    height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    color: #dbeafe;
    cursor: pointer;
    font-size: 1.25rem;
}

#faceFrame {
    display: block;
    width: 100%;
    height: 400px;
    border: 0;
    border-radius: 20px;
    background: #0a1330;
}

.face-progress {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.8rem;
    text-align: center;
    color: #9fb3d9;
    font-size: 0.82rem;
}

.face-progress strong { color: #2dd4eb; font-size: 1.35rem; }
.face-progress .face-error { color: #fca5a5; }

.face-progress__track {
    height: 8px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.1);
}

.face-progress__bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #22d3ee, #3b82f6);
    transition: width 0.25s ease;
}

.face-success {
    display: grid;
    gap: 0.45rem;
    justify-items: center;
    padding: 2rem 0.5rem;
    text-align: center;
    color: #dbeafe;
}

.face-success[hidden] { display: none; }
.face-success > i { color: #2dd4eb; font-size: 3rem; }
.face-success h3 { margin: 0; color: #2dd4eb; }
.face-success p { margin: 0 0 0.5rem; color: #9fb3d9; }
.face-success strong { color: #fff; font-size: 1.05rem; }
.face-success span { color: #9fb3d9; font-size: 0.82rem; }

.login-note {
    margin-top: 1.1rem;
    font-size: 0.76rem;
    line-height: 1.55;
    color: var(--ink-3);
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.1rem;
    border-radius: 11px;
    font-size: 0.86rem;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
    animation: toastIn 0.22s ease;
}

.toast--success { background: #059669; }
.toast--error { background: #dc2626; }
.toast--info { background: #1d4ed8; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

.shake { animation: shake 0.32s ease; }

@keyframes shake {
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ==========================================================
   RESPONSIVO
   ========================================================== */
@media (max-width: 1100px) {
    .auth-shell { grid-template-columns: 1fr; }
    .brand-panel {
        min-height: auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        padding: 1rem 1.5rem;
    }
    .brand-panel::before { background-size: 40px 40px; }
    .brand-panel::after,
    .brand-atmosphere { display: none; }
    .brand-content { width: auto; gap: 0; }
    .brand-partners { gap: 0.65rem; }
    .brand-copy { display: none; }
    .brand-chip { width: 6.2rem; min-height: 4.4rem; aspect-ratio: auto; padding: 0.4rem; border-radius: 10px; }
    .brand-chip--semec img { width: 4.7rem; }
    .brand-chip--govex img { width: 4.2rem; }
    .login-panel { padding: 2rem 1.25rem; background: var(--canvas); }
    .login-wrapper {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 18px;
        padding: 2rem 1.75rem;
        box-shadow: 0 18px 50px rgba(15, 23, 42, 0.07);
    }
}

@media (max-width: 420px) {
    .brand-panel { padding: 0.7rem 1rem; }
    .brand-partners { gap: 0.5rem; }
    .brand-chip { width: 5.7rem; min-height: 4rem; }
    .brand-chip--semec img { width: 4.25rem; }
    .brand-chip--govex img { width: 3.8rem; }
    .login-panel { padding: 1rem; }
    .login-wrapper { padding: 1.4rem 1.2rem; }
    .login-head h2 { font-size: 1.42rem; }
    .form-row { flex-wrap: wrap; }
}

@media (min-width: 421px) and (max-width: 1100px) and (max-height: 800px) {
    .brand-panel { padding-top: 0.65rem; padding-bottom: 0.65rem; }
    .brand-chip { min-height: 4rem; }
    .brand-chip--semec img { width: 4.4rem; }
    .brand-chip--govex img { width: 3.9rem; }
    .login-panel { padding-top: 1rem; padding-bottom: 1rem; }
    .login-wrapper { padding-top: 1.35rem; padding-bottom: 1.35rem; }
    .login-head { margin-bottom: 1rem; }
    .login-head__mark { margin-bottom: 0.65rem; }
    .login-head__mark img { width: 8.5rem; }
    .login-form { gap: 0.75rem; }
    .login-divider { margin-top: 0.8rem; margin-bottom: 0.6rem; }
    .login-note { margin-top: 0.75rem; }
}

@media (max-height: 760px) and (min-width: 1101px) {
    .brand-panel { padding-top: 2rem; padding-bottom: 2rem; }
    .login-panel { align-items: flex-start; padding-top: 1.5rem; padding-bottom: 1.5rem; }
    .login-head { margin-bottom: 1.1rem; }
    .login-head__mark { margin-bottom: 0.7rem; }
    .login-note { margin-top: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    .brand-panel *,
    .brand-panel *::before,
    .brand-panel *::after {
        animation: none !important;
        transition: none !important;
    }
}
