/* ═══════════════════════════════════════════════════
   AI Terminal Login — Terminal/Cyberpunk Theme v2
   Enhanced: accessibility, reduced-motion, focus
   ═══════════════════════════════════════════════════ */

/* ── Font ── */
@font-face {
    font-family: 'Terminal';
    src: url('/static/FZXS16.ttf') format('truetype');
    font-display: swap;
    font-weight: normal;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: Terminal, 'Courier New', monospace;
    background: #08080e;
    color: #c8d6c0;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    line-height: 1.6;
}

/* ── CRT scanlines (subtle, static overlay) ── */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    background:
        repeating-linear-gradient(0deg,
            transparent, transparent 2px,
            rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
    opacity: 0.3;
}

/* ── Terminal window ── */
.terminal-window {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, #0d0d1a 0%, #0a0a14 100%);
    border: 1px solid #1e2a3a;
    border-radius: 6px;
    box-shadow:
        0 0 40px rgba(74, 222, 128, 0.05),
        0 8px 32px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: terminalIn 0.4s ease-out;
}

@keyframes terminalIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Title bar ── */
.term-titlebar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #12122a;
    border-bottom: 1px solid #1e2a3a;
}

.term-dots {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.term-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.term-dot.red   { background: #ff5f57; box-shadow: 0 0 6px rgba(255,95,87,0.4); }
.term-dot.amber { background: #febc2e; box-shadow: 0 0 6px rgba(254,188,46,0.4); }
.term-dot.green { background: #28c840; box-shadow: 0 0 6px rgba(40,200,64,0.4); }

.term-title {
    font-size: 0.72rem;
    color: #62728a;
    letter-spacing: 0.04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Body ── */
.term-body {
    padding: 20px 18px 18px;
    font-size: 0.78rem;
}

/* ── ASCII banner ── */
.ascii-banner {
    font-size: 0.38rem;
    line-height: 1.1;
    white-space: pre;
    text-align: center;
    color: #4ade80;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.35);
    margin-bottom: 4px;
    user-select: none;
}

.banner-sub {
    text-align: center;
    font-size: 0.6rem;
    color: #7c3aed;
    letter-spacing: 0.25em;
    text-shadow: 0 0 6px rgba(124, 58, 237, 0.3);
    margin-bottom: 16px;
    user-select: none;
}

/* ── Terminal line ── */
.term-line {
    font-size: 0.68rem;
    color: #829aa0;
    margin-bottom: 14px;
    padding-left: 2px;
}
.prompt        { color: #4ade80; }
.prompt-user   { color: #7c3aed; text-shadow: 0 0 4px rgba(124,58,237,0.3); }

/* ── Form fields ── */
.form-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-label {
    font-size: 0.65rem;
    color: #62728a;
    letter-spacing: 0.05em;
    padding-left: 2px;
}

.input-group input[type="tel"],
.input-group input[type="password"],
.input-group input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    background: #0a0a18;
    border: 1px solid #1e2a3a;
    border-radius: 4px;
    font-family: Terminal, 'Courier New', monospace;
    font-size: 0.82rem;
    color: #c8d6c0;
    caret-color: #4ade80;
    transition: border-color 200ms ease, box-shadow 200ms ease, background-color 200ms ease;
    outline: none;
}

.input-group input::placeholder {
    color: #3a4a5a;
    opacity: 1;
}

.input-group input:hover {
    border-color: #2a3a4a;
    background: #0d0d1f;
}

.input-group input:focus-visible {
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.12), 0 0 16px rgba(74, 222, 128, 0.06);
    background: #0d0d1f;
}

.input-group input.input-error-state {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input-error {
    font-size: 0.6rem;
    color: #ef4444;
    min-height: 1.2em;
    padding-left: 2px;
    transition: opacity 200ms ease;
}

/* ── Password wrapper ── */
.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap input {
    padding-right: 44px !important;
}

.pw-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a5a6a;
    font-size: 0.85rem;
    border-radius: 4px;
    transition: color 200ms ease, background-color 200ms ease;
    line-height: 1;
}
.pw-toggle:hover {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.06);
}

/* ── Login button ── */
.login-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #1a2a1a 0%, #0d1a0d 100%);
    border: 1px solid #1e3a2a;
    border-radius: 4px;
    font-family: Terminal, 'Courier New', monospace;
    font-size: 0.82rem;
    color: #4ade80;
    cursor: pointer;
    letter-spacing: 0.15em;
    text-shadow: 0 0 6px rgba(74, 222, 128, 0.3);
    transition:
        background-color 200ms ease,
        border-color 200ms ease,
        box-shadow 200ms ease,
        color 200ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
}

.login-btn:hover {
    background: linear-gradient(135deg, #1e3e1e 0%, #111e11 100%);
    border-color: #2a4a2a;
    box-shadow: 0 0 24px rgba(74, 222, 128, 0.1);
    color: #5dfc8c;
}

.login-btn:focus-visible {
    outline: none;
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15), 0 0 24px rgba(74, 222, 128, 0.08);
}

.login-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* ── Button spinner ── */
.btn-text    { display: inline; }
.btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(74,222,128,0.25);
    border-top-color: #4ade80;
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}
.login-btn.loading .btn-text    { display: none; }
.login-btn.loading .btn-spinner { display: inline-block; }

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

/* ── Message ── */
.message {
    min-height: 1.4em;
    margin-top: 12px;
    font-size: 0.65rem;
    letter-spacing: 0.03em;
    transition: color 200ms ease;
}
.message.success { color: #4ade80; }
.message.error   { color: #ef4444; }

/* ── Footer ── */
.term-footer {
    margin-top: 18px;
    text-align: center;
    font-size: 0.55rem;
    color: #3a4a5a;
    letter-spacing: 0.06em;
}

.blink {
    color: #4ade80;
    animation: blink-cursor 1s step-end infinite;
}
@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    body::after { opacity: 0; }
    .terminal-window { animation: none; }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    body { padding: 0.5rem; }
    .terminal-window { max-width: 100%; border-radius: 4px; }
    .term-body { padding: 16px 14px 14px; }
    .ascii-banner { font-size: 0.32rem; }
    .input-group input[type="tel"],
    .input-group input[type="password"],
    .input-group input[type="text"] {
        padding: 14px 12px;
        font-size: 1rem; /* prevent iOS zoom on focus */
    }
    .login-btn { padding: 16px; font-size: 0.9rem; }
}
