/*
   ============================================================
   SETH — Auth Styles
   ============================================================
   File    : static/auth.css
   Purpose : Standalone auth pages: login, register, 2FA, password reset (cards, forms, honeypot).
   ============================================================
*/

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,400;6..72,500;6..72,600&display=swap");

/* ============================================
   AUTH.CSS - Modern Authentication Pages
   Matches the main chat interface aesthetic
   ============================================ */

/* Import variables from main design system */
/* Night Before Dawn — unified design tokens (Phase 1 — 2026-05-29).
   Mirrors static/css-split/1-variables.css so every standalone page (admin,
   auth, persona, capture/journal pages) inherits the same midnight-navy + warm
   amber palette as the main chat UI. Edit ONCE in 1-variables.css, then re-run
   bin/sync_tokens.py (or hand-paste this block) to keep these in sync. */
:root {
    /* ── Backgrounds — midnight navy ladder ── */
    --color-bg-primary:    #0A1428;
    --color-bg-secondary:  #102038;
    --color-bg-tertiary:   #142840;
    --color-bg-hover:      #1B3352;
    --color-bg-accent:     #1A2B45;
    /* ── Borders ── */
    --color-border:        #1F3252;
    --color-border-light:  #2A4470;
    /* ── Text ── */
    --color-text-primary:   #E8ECF2;
    --color-text-secondary: #B6C2D6;
    --color-text-muted:     #7A8AA3;
    /* ── Primary accent — warm amber (first light) ── */
    --color-accent:        #E8B872;
    --color-accent-hover:  #F0C68A;
    --color-accent-muted:  rgba(232, 184, 114, 0.14);
    /* ── Secondary accent — soft moonlight steel-blue ── */
    --color-accent-blue:        #6FA0D6;
    --color-accent-blue-hover:  #8AB6E4;
    --color-accent-blue-muted:  rgba(111, 160, 214, 0.14);
    /* ── Tertiary — burnished gold (admin / financial) ── */
    --color-accent-gold:        #C9A84C;
    --color-accent-gold-hover:  #D6B863;
    /* ── Status ── */
    --color-success:        #4ADE80;
    --color-success-hover:  #22C55E;
    --color-warning:        #F5B547;
    --color-warning-hover:  #E89A2B;
    --color-danger:         #F87171;
    --color-danger-hover:   #EF4444;
    --color-info:           #6FA0D6;
    --color-info-hover:     #8AB6E4;
    /* ── Typography ── */
    --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-ui:      var(--font-body);
    --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
    --font-mono:    'JetBrains Mono', 'IBM Plex Mono', 'SF Mono', 'Fira Code', Consolas, Monaco, monospace;
    /* ── Spacing ── */
    --space-1:  4px;
    --space-2:  8px;
    --space-3:  12px;
    --space-4:  16px;
    --space-5:  20px;
    --space-6:  24px;
    --space-8:  32px;
    --space-10: 40px;
    --space-12: 48px;
    /* ── Radius ── */
    --radius-sm:   6px;
    --radius-md:   10px;
    --radius-lg:   14px;
    --radius-xl:   18px;
    --radius-2xl:  24px;
    --radius-full: 9999px;
    /* ── Shadows + amber glow ── */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.45);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.55);
    --color-glow:    0 0 22px rgba(232, 184, 114, 0.18);
    --color-glow-lg: 0 0 38px rgba(232, 184, 114, 0.28);
    /* ── Motion ── */
    --transition:        220ms cubic-bezier(.4,0,.2,1);
    --transition-fast:   140ms cubic-bezier(.4,0,.2,1);
    --transition-normal: 220ms cubic-bezier(.4,0,.2,1);
    --transition-slow:   320ms cubic-bezier(.4,0,.2,1);
}

/* ===== BODY & CONTAINER ===== */

.auth-body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Subtle amber glow at top-left and bottom-right corners — "first light"
       just barely visible against the midnight navy. */
    background-image:
        radial-gradient(at 20% 30%, rgba(232, 184, 114, 0.05) 0px, transparent 50%),
        radial-gradient(at 80% 70%, rgba(232, 184, 114, 0.03) 0px, transparent 50%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: var(--space-6);
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== FORM CARD ===== */

.auth-form {
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    box-shadow: var(--shadow-lg);
}

/* ===== BRAND & HEADERS ===== */

.auth-brand {
    text-align: center;
    margin-bottom: var(--space-6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.auth-brand h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 500;
    margin: 0;
    color: var(--color-text-primary);
    letter-spacing: -0.02em;
    line-height: 1;
    /* Tiny amber underline accent — the "first light", matching the sidebar
       header in the main chat UI. */
    position: relative;
    padding-bottom: 10px;
}
.auth-brand h1::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 32px;
    height: 2px;
    background: var(--color-accent);
    border-radius: var(--radius-full);
    opacity: 0.75;
}

/* Glowing star/icon above the brand name. */
.auth-brand-mark {
    font-size: 2.2rem;
    color: var(--color-accent);
    text-shadow: 0 0 18px rgba(232, 184, 114, 0.45);
    line-height: 1;
}

/* "an honest mirror" — small caps subtitle under the name. */
.auth-brand-sub {
    color: var(--color-text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    margin: 0;
}

.auth-form h2 {
    text-align: center;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 500;
    color: var(--color-text-primary);
    margin: 0 0 var(--space-6) 0;
    letter-spacing: -0.005em;
}

/* Variant: centered form (used by security_onboarding for a calmer feel). */
.auth-form--centered { text-align: center; }
/* Variant: inner sub-form inside a parent .auth-form (verify_2fa).
   Removes the box-in-box visual by stripping the panel background/border. */
.auth-form--inner {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    margin: 0;
}

/* ===== INPUT GROUPS ===== */

.input-group {
    margin-bottom: var(--space-5);
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
}

.modal-input,
input[type="text"],
input[type="email"],
input[type="password"] {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 0.9375rem;
    font-family: var(--font-body);
    transition: all var(--transition-normal);
    box-sizing: border-box;
}

.modal-input:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover {
    border-color: var(--color-border-light);
    background: var(--color-bg-hover);
}

.modal-input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--color-accent);
    background: var(--color-bg-hover);
    box-shadow: 0 0 0 3px var(--color-accent-muted);
}

.modal-input::placeholder,
input::placeholder {
    color: var(--color-text-muted);
}

/* ===== BUTTONS ===== */

.primary-btn,
button[type="submit"] {
    width: 100%;
    padding: var(--space-3) var(--space-5);
    background: var(--color-accent);
    color: #0A1428;                  /* dark navy on amber — matches chat send button */
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: var(--font-body);
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    box-sizing: border-box;
    transition: background var(--transition-fast),
                box-shadow var(--transition-fast),
                transform var(--transition-fast);
    box-shadow: var(--color-glow);
}

.primary-btn:hover,
button[type="submit"]:hover {
    background: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--color-glow-lg);
}

.primary-btn:active,
button[type="submit"]:active {
    transform: translateY(0);
}

.secondary-btn,
a.secondary-btn {
    display: block;
    width: 100%;
    padding: var(--space-3) var(--space-5);
    background: transparent;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-sizing: border-box;
}

.secondary-btn:hover,
a.secondary-btn:hover {
    background: var(--color-bg-tertiary);
    border-color: var(--color-border-light);
    transform: translateY(-1px);
}

/* ===== DIVIDER ===== */

.auth-divider {
    position: relative;
    text-align: center;
    margin: var(--space-6) 0;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 45%;
    height: 1px;
    background: var(--color-border);
}

.auth-divider::before {
    left: 0;
}

.auth-divider::after {
    right: 0;
}

/* ===== LINKS =====
   The :not(...) guard EXCLUDES links that are styled as buttons (primary /
   secondary / danger / auth-link-block). Without it, the generic amber
   link colour wins against the button rules and you get amber text on an
   amber button (invisible) — which is exactly what bit the "🛡️ Setup
   2FA Now" link on security_onboarding before the fix (Phase 8.5). */

.auth-form a:not(.primary-btn):not(.secondary-btn):not(.danger-btn):not(.auth-btn--full) {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition-normal);
}

.auth-form a:not(.primary-btn):not(.secondary-btn):not(.danger-btn):not(.auth-btn--full):hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* Forgot password link */
.auth-form .forgot-password-link {
    text-align: right;
    margin-top: -10px;
    margin-bottom: var(--space-5);
}

.auth-form .forgot-password-link a {
    font-size: 0.875rem;
    color: var(--color-accent);
}

/* ===== MESSAGES & ALERTS ===== */

.success-message,
.error-message,
.info-message,
.warning-message,
.error,
.success,
.info,
.warning {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: var(--space-4);
    border-left: 3px solid;
}

.success-message,
.success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
    border-left-color: var(--color-success);
}

.error-message,
.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
    border-left-color: var(--color-danger);
}

.info-message,
.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--color-info);
    border-left-color: var(--color-info);
}

.warning-message,
.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
    border-left-color: var(--color-warning);
}

/* ===== 2FA SPECIFIC STYLES ===== */

.qr-code-container {
    text-align: center;
    padding: var(--space-6);
    background: white;
    border-radius: var(--radius-lg);
    margin: var(--space-6) 0;
}

.qr-code-container img  {
    max-width: 250px;
    height: auto;
}

.qr-code {
    text-align: center;
    margin: 20px 0;
    padding: 20px;
    background: var(--text-primary);
    border-radius: 12px;
    border: 2px solid var(--card-border);
    max-width: 100%;
    overflow: hidden;
}

.qr-code img {
    max-width: 100%;
    width: auto;
    height: auto;
    max-height: 280px;
    border: 3px solid var(--bg-primary);
    border-radius: 8px;
    background: white;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: block;
    margin: 0 auto;
}

.backup-codes-container {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin: var(--space-5) 0;
}

.backup-codes-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    font-family: var(--font-mono, monospace);
    font-size: 0.875rem;
    color: var(--color-text-primary);
    list-style: none;
    padding: 0;
    margin: var(--space-4) 0;
}

.backup-codes-list li {
    background: var(--color-bg-secondary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
}

.code-input-group {
    display: flex;
    gap: var(--space-2);
    justify-content: center;
    margin: var(--space-6) 0;
}

.code-input-group input {
    width: 50px;
    height: 50px;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font-mono, monospace);
}

/* ===== ACTION BUTTONS (2FA, Admin) ===== */

.action-buttons {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.action-buttons button {
    flex: 1;
}

.danger-btn {
    background: var(--color-danger);
    color: white;
    border: none;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.danger-btn:hover {
    background: var(--color-danger-hover);
    transform: translateY(-1px);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 480px) {
    .auth-container {
        padding: var(--space-4);
    }
    
    .auth-form {
        padding: var(--space-6);
    }
    
    .auth-brand h1 {
        font-size: 1.5rem;
    }
    
    .backup-codes-list {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
}

/* ===== LOADING STATES ===== */

.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--color-text-muted);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== ACCESSIBILITY ===== */

.auth-form *:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
/* ════════════════════════════════════════════════════════════════
   PHASE 8.5 — Auth pages polish (2026-05-29)
   Classes added when the 10 auth templates were de-inlined and the
   broken nested-<form> structures on the 2FA pages were rebuilt.
   Grouped here so the long historical block above stays untouched.
   ════════════════════════════════════════════════════════════════ */

/* Full-width auth button utility (replaces inline `style="width:100%"`
   sprinkled across most templates). Apply alongside .primary-btn /
   .secondary-btn / .danger-btn. */
.auth-btn--full { width: 100%; display: block; text-align: center; box-sizing: border-box; }
/* A quieter, lower-stakes secondary button — used for "Skip for now". */
.auth-btn--quiet { opacity: 0.8; }
.auth-btn--quiet:hover { opacity: 1; }

/* Short helper paragraph under a heading (was inline `color: #9ca3af; text-align: center;`). */
.auth-help-text {
    color: var(--color-text-secondary);
    text-align: center;
    font-size: 0.95rem;
    margin: 0 0 var(--space-5) 0;
    line-height: 1.55;
}
.auth-fine-print {
    margin-top: var(--space-5);
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

/* Stacked form actions (column) vs row layout. */
.form-actions--stacked { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-4); }
.form-actions--row     { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.form-actions--row .primary-btn,
.form-actions--row .secondary-btn { width: auto; flex: 1 1 160px; }

/* Status card inline tweak — used by security_onboarding under the brand. */
.status-card--inline {
    text-align: left;
    margin-bottom: var(--space-5);
}

/* TOTP input — big, monospaced, spacious for the 6-digit code. */
.totp-input {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.4rem !important;
    letter-spacing: 0.35em;
    padding: var(--space-4) !important;
}

/* Trust-this-device checkbox row (replaces brittle inline flex). */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: var(--space-3) 0 var(--space-5) 0;
}
.checkbox-group input[type="checkbox"] {
    width: auto !important;
    margin: 0;
    cursor: pointer;
    accent-color: var(--color-accent);
}
.checkbox-group label {
    margin: 0;
    font-weight: normal;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    cursor: pointer;
}

/* Language selector — moved here from register.html's inline <style> block
   (was using its own coral fallback tokens that broke on the navy palette). */
.language-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    /* Moonlight-blue caret (matches our --color-accent-blue token). */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236FA0D6' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.language-select:hover  { border-color: var(--color-border-light); }
.language-select:focus  {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-muted), var(--color-glow);
}
.language-select option {
    background-color: var(--color-bg-secondary);
    color: var(--color-text-primary);
    padding: 8px;
}
.language-hint {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.language-hint .globe-icon { font-size: 1rem; }
