/* ============================================================
   Login · Autenticação · MALVSCODE
   Padrão visual unificado com o Sistema de Atendimento
   ============================================================ */

:root {
    --blue-900:         #0F1E3D;
    --blue-800:         #142A57;
    --blue-700:         #1E3A8A;
    --blue-600:         #1E40AF;
    --blue-500:         #2563EB;
    --blue-400:         #3B82F6;
    --blue-100:         #93C5FD;

    --primary:          #1E40AF;
    --primary-hover:    #2563EB;
    --primary-light:    rgba(37, 99, 235, 0.1);
    --primary-border:   rgba(37, 99, 235, 0.2);

    --bg-primary:       #FFFFFF;
    --bg-secondary:     #F5F6F8;
    --bg-card:          #FFFFFF;
    --text-primary:     #1A1A1A;
    --text-secondary:   #6B7280;
    --text-tertiary:    #9CA3AF;
    --border-color:     #E5E7EB;
    --border-soft:      #EEF0F3;
    --input-bg:         #F7F8FA;
    --card-shadow:      0 1px 2px rgba(15, 23, 42, 0.04);

    --success-color:    #22C55E;
    --danger-color:     #EF4444;

    --font-sans:        'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono:        'IBM Plex Mono', ui-monospace, monospace;

    --safe-top:         env(safe-area-inset-top, 0px);
    --safe-bottom:      env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary:     #0E0E10;
        --bg-secondary:   #08080A;
        --bg-card:        #17171A;
        --text-primary:   #F5F5F7;
        --text-secondary: #A0A0A0;
        --text-tertiary:  #6E6E72;
        --border-color:   #26262A;
        --border-soft:    #1F1F23;
        --input-bg:       #1C1C1F;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }

html, body {
    height: 100%;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overscroll-behavior-y: contain;
}
body { overflow-x: hidden; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
.hidden { display: none !important; }

/* ============================================================
   VOLTAR AO SITE — flutuante, igual ao Atendimento
   ============================================================ */
.back-link {
    position: fixed;
    top: calc(var(--safe-top) + 0.75rem);
    left: 0.75rem;
    z-index: 950;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all 0.15s ease;
    box-shadow: var(--card-shadow);
    white-space: nowrap;
}
.back-link:hover {
    background: #ffffff;
    border-color: var(--primary-border);
    color: var(--primary);
}
.back-link:active {
    transform: scale(0.97);
    background: #ffffff;
    border-color: var(--primary);
    color: var(--primary);
}

@media (prefers-color-scheme: dark) {
    .back-link {
        background: rgba(20, 20, 22, 0.95);
    }
    .back-link:hover,
    .back-link:active {
        background: #1C1C1F;
    }
}

/* Em telas largas, o botão fica um pouco maior */
@media (min-width: 900px) {
    .back-link {
        top: 1.25rem;
        left: 1.25rem;
        padding: 0.55rem 1rem;
        font-size: 0.85rem;
    }
}

/* ============================================================
   LINHAS ANIMADAS (fundo)
   ============================================================ */
.line { position: absolute; pointer-events: none; z-index: 1; }
.line-h {
    left: 0; width: 100%; height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(147,197,253,0) 15%, rgba(147,197,253,0.35) 50%, rgba(147,197,253,0) 85%, transparent 100%);
    animation: slideH linear infinite;
}
.line-v {
    top: 0; height: 100%; width: 1px;
    background: linear-gradient(180deg, transparent 0%, rgba(147,197,253,0) 15%, rgba(147,197,253,0.35) 50%, rgba(147,197,253,0) 85%, transparent 100%);
    animation: slideV linear infinite;
}
@keyframes slideH { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes slideV { 0% { transform: translateY(-100%); } 100% { transform: translateY(100%); } }

.line-h:nth-child(1) { top: 18%;  animation-duration: 11s; animation-delay: 0s;   }
.line-h:nth-child(2) { top: 42%;  animation-duration: 14s; animation-delay: -3s;  }
.line-h:nth-child(3) { top: 68%;  animation-duration: 10s; animation-delay: -6s;  }
.line-h:nth-child(4) { top: 88%;  animation-duration: 16s; animation-delay: -9s;  }
.line-v:nth-child(5) { left: 12%;  animation-duration: 13s; animation-delay: -2s;  }
.line-v:nth-child(6) { left: 38%;  animation-duration: 11s; animation-delay: -5s;  }
.line-v:nth-child(7) { left: 62%;  animation-duration: 15s; animation-delay: -8s;  }
.line-v:nth-child(8) { left: 86%;  animation-duration: 12s; animation-delay: -11s; }

/* ============================================================
   TELA 1 — INTRODUÇÃO
   ============================================================ */
.intro-screen {
    position: relative;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(155deg, var(--blue-900) 0%, var(--blue-800) 55%, var(--blue-700) 100%);
    color: #ffffff;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: calc(4.5rem + var(--safe-top)) 1.5rem 2.5rem;
    overflow: hidden;
}
@keyframes introFadeIn { from { opacity: 0; } to { opacity: 1; } }
.intro-screen { animation: introFadeIn 0.5s ease; }

.intro-inner {
    position: relative; z-index: 2;
    max-width: 520px; width: 100%;
    text-align: center;
    animation: introLift 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes introLift { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

.intro-inner .eyebrow {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: var(--blue-100);
    margin-bottom: 1.25rem;
}

.intro-title {
    font-size: clamp(1.9rem, 8vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 2.25rem;
    color: #ffffff;
}

.intro-features {
    display: flex; flex-direction: column;
    gap: 0.9rem;
    align-items: flex-start;
    max-width: 460px;
    margin: 0 auto 2rem;
    text-align: left;
}
.intro-features .feature-line {
    display: flex; align-items: baseline;
    gap: 0.85rem;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.88);
}
.intro-features .feature-index {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--blue-100);
    flex-shrink: 0;
    letter-spacing: 0.05em;
}

.intro-instructions {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 1.5rem;
    max-width: 460px;
    margin: 0 auto 2.25rem;
    text-align: left;
}
.intro-instructions .instructions-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 0.55rem;
}
.intro-instructions p {
    font-size: 0.85rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 300;
}

/* Botão "Vamos começar?" */
.btn-start {
    display: inline-flex; align-items: center; gap: 0.6rem;
    padding: 1rem 1.75rem;
    background: #ffffff;
    color: var(--blue-700);
    border: none; border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    min-height: 52px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}
.btn-start:hover {
    transform: translateY(-2px);
    background: #F1F5F9;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.25);
}
.btn-start:active { transform: scale(0.98); background: #E8EDF5; }
.btn-start svg { transition: transform 0.2s ease; }
.btn-start:hover svg { transform: translateX(3px); }

/* ============================================================
   TELA 2 — LOGIN
   ============================================================ */
.login-screen {
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg-card);
    animation: introFadeIn 0.4s ease;
}

.login-aside {
    display: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(155deg, var(--blue-900) 0%, var(--blue-800) 55%, var(--blue-700) 100%);
}

.login-aside-message {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    width: calc(100% - 4rem);
    max-width: 380px;
    text-align: center;
    font-family: var(--font-sans);
    font-size: clamp(1.05rem, 1.6vw, 1.35rem);
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: -0.01em;
    color: rgba(255, 255, 255, 0.9);
}

@media (min-width: 900px) {
    .login-screen { grid-template-columns: 1.05fr 1fr; }
    .login-aside { display: block; }
}
@media (orientation: landscape) and (min-height: 480px) and (min-width: 720px) {
    .login-screen { grid-template-columns: 1fr 1fr; }
    .login-aside { display: block; }
}

.login-form-side {
    display: flex; align-items: center; justify-content: center;
    padding: 3rem 1.5rem;
    background: var(--bg-card);
    overflow-y: auto;
    padding-top: calc(4.5rem + var(--safe-top));
}

.login-form-wrapper {
    width: 100%;
    max-width: 380px;
    animation: fadeUp 0.5s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Logo box */
.logo-box {
    position: relative;
    width: 220px;
    height: 90px;
    margin: 0 auto 2.5rem;
    display: flex; align-items: center; justify-content: center;
}
.logo-box .corner {
    position: absolute;
    width: 16px; height: 16px;
    border-color: var(--border-color);
    border-style: solid;
    border-width: 0;
}
.logo-box .corner.tl { top: 0; left: 0;  border-top-width: 1.5px; border-left-width: 1.5px; }
.logo-box .corner.tr { top: 0; right: 0; border-top-width: 1.5px; border-right-width: 1.5px; }
.logo-box .corner.bl { bottom: 0; left: 0;  border-bottom-width: 1.5px; border-left-width: 1.5px; }
.logo-box .corner.br { bottom: 0; right: 0; border-bottom-width: 1.5px; border-right-width: 1.5px; }
.logo-box-text {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 500;
}

.login-form-header {
    text-align: center;
    margin-bottom: 2rem;
}
.login-form-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Campos */
.field { margin-bottom: 1.25rem; }
.field label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.field input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.95rem;
    min-height: 48px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    outline: none;
}
.field input::placeholder { color: var(--text-tertiary); }
.field input:focus {
    border-color: var(--primary);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.9rem 1.25rem;
    background: var(--primary);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    min-height: 52px;
    transition: background 0.15s ease, transform 0.1s ease;
    letter-spacing: 0.01em;
    margin-top: 0.5rem;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.99); }

.btn-block { width: 100%; }

.login-form-footer {
    margin-top: 2rem;
    display: flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.status-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success-color);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

/* ============================================================
   SPLASH — carregamento
   ============================================================ */
.splash-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
}
.splash-inner {
    text-align: center;
    animation: fadeUp 0.5s ease;
    padding: 0 1.5rem;
    max-width: 480px;
    width: 100%;
}
.splash-greeting {
    font-size: clamp(1.4rem, 6vw, 1.75rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 2rem;
}
.splash-progress {
    width: 220px;
    max-width: 100%;
    height: 2px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}
.splash-progress span {
    display: block;
    height: 100%;
    width: 40%;
    background: var(--primary);
    border-radius: 2px;
    animation: progressSlide 1.6s ease-in-out infinite;
}
@keyframes progressSlide {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

/* ============================================================
   WHATSAPP
   ============================================================ */
.whatsapp-float {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 1rem);
    right: 1rem;
    z-index: 90;
    width: 52px; height: 52px;
    background: #25d366;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
    transition: transform 0.2s ease;
}
.whatsapp-float:active { transform: scale(0.94); }
.whatsapp-float svg { width: 26px; height: 26px; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 899px) {
    .login-form-side {
        padding: calc(4.5rem + var(--safe-top)) 1.5rem calc(2.5rem + var(--safe-bottom));
    }
}
@media (min-width: 900px) {
    .login-form-side {
        padding: 3rem;
    }
}
@media (min-width: 1280px) {
    .login-form-wrapper { max-width: 420px; }
    .login-aside-message { font-size: 1.5rem; max-width: 460px; }
    .logo-box { width: 240px; height: 96px; margin-bottom: 3rem; }
}
@media (orientation: landscape) and (max-height: 500px) and (max-width: 899px) {
    .intro-screen {
        padding: 3.5rem 1.5rem 2rem;
        justify-content: flex-start;
    }
    .intro-title { font-size: 1.5rem; margin-bottom: 1rem; }
    .intro-features { gap: 0.5rem; margin-bottom: 1rem; }
    .intro-features .feature-line { font-size: 0.78rem; }
    .intro-instructions { padding-top: 1rem; margin-bottom: 1.25rem; }
    .btn-start { padding: 0.75rem 1.25rem; font-size: 0.85rem; }

    .login-form-side { padding: 3rem 1.5rem 1.5rem; align-items: center; }
    .logo-box { width: 160px; height: 60px; margin-bottom: 1.25rem; }
    .login-form-header { margin-bottom: 1rem; }
    .field { margin-bottom: 0.85rem; }
    .login-form-footer { margin-top: 1rem; }
}
