/**
 * Shared shell for out-of-app pages (login, loading, session-ended, security).
 * Tokens mirror the portal Aura theme so these screens feel continuous with the app.
 */
:root {
    --auth-bg: #f4f7f6;
    --auth-bg-dark: hsl(140, 15%, 15%);
    --auth-surface: #ffffff;
    --auth-surface-dark: hsl(140, 12%, 18%);
    --auth-accent: #13795b;
    --auth-accent-hover: #0f684e;
    --auth-accent-soft: color-mix(in srgb, #13795b 12%, transparent);
    --auth-ink: #1b2e2a;
    --auth-ink-secondary: #5b6f6a;
    --auth-border: #d9e3e0;
    --auth-warning-bg: #fff8eb;
    --auth-warning-text: #7a4b00;
    --auth-warning-border: #f0d7a0;
    --auth-error-bg: #fef2f2;
    --auth-error-text: #8a1f1f;
    --auth-error-border: #f0c2c2;
    --auth-success-bg: #edf8f3;
    --auth-success-text: #0f5c45;
    --auth-success-border: #b7e2d1;
    --auth-radius-m: 6px;
    --auth-radius-l: 8px;
    --auth-shadow: 0 8px 28px rgba(27, 46, 42, 0.08);
    --auth-font: "Instrument Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/*
 * Theme resolution (auth-theme.js):
 *   html.auth-theme-dark  → portal cookie darkMode=true (or default)
 *   html.auth-theme-light → portal cookie darkMode=false
 *   no class              → OS prefers-color-scheme (fallback)
 */
/* Forced dark from portal cookie (auth-theme.js) */
html.auth-theme-dark {
    --auth-bg: var(--auth-bg-dark);
    --auth-surface: var(--auth-surface-dark);
    --auth-accent: #42c99a;
    --auth-accent-hover: #5ad4a9;
    --auth-accent-soft: color-mix(in srgb, #42c99a 16%, transparent);
    --auth-ink: #e8f2ef;
    --auth-ink-secondary: #a8bbb5;
    --auth-border: hsl(140, 10%, 28%);
    --auth-warning-bg: color-mix(in srgb, #f0a500 16%, transparent);
    --auth-warning-text: #ffd999;
    --auth-warning-border: color-mix(in srgb, #f0a500 35%, transparent);
    --auth-error-bg: color-mix(in srgb, #e05a5a 16%, transparent);
    --auth-error-text: #ffb4b4;
    --auth-error-border: color-mix(in srgb, #e05a5a 35%, transparent);
    --auth-success-bg: color-mix(in srgb, #42c99a 14%, transparent);
    --auth-success-text: #9de8cb;
    --auth-success-border: color-mix(in srgb, #42c99a 35%, transparent);
    --auth-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

/* Forced light from portal cookie */
html.auth-theme-light {
    --auth-bg: #f4f7f6;
    --auth-surface: #ffffff;
    --auth-accent: #13795b;
    --auth-accent-hover: #0f684e;
    --auth-accent-soft: color-mix(in srgb, #13795b 12%, transparent);
    --auth-ink: #1b2e2a;
    --auth-ink-secondary: #5b6f6a;
    --auth-border: #d9e3e0;
    --auth-warning-bg: #fff8eb;
    --auth-warning-text: #7a4b00;
    --auth-warning-border: #f0d7a0;
    --auth-error-bg: #fef2f2;
    --auth-error-text: #8a1f1f;
    --auth-error-border: #f0c2c2;
    --auth-success-bg: #edf8f3;
    --auth-success-text: #0f5c45;
    --auth-success-border: #b7e2d1;
    --auth-shadow: 0 8px 28px rgba(27, 46, 42, 0.08);
    color-scheme: light;
}

/* OS preference only when JS has not forced a portal theme class */
@media (prefers-color-scheme: dark) {
    html:not(.auth-theme-light):not(.auth-theme-dark) {
        --auth-bg: var(--auth-bg-dark);
        --auth-surface: var(--auth-surface-dark);
        --auth-accent: #42c99a;
        --auth-accent-hover: #5ad4a9;
        --auth-accent-soft: color-mix(in srgb, #42c99a 16%, transparent);
        --auth-ink: #e8f2ef;
        --auth-ink-secondary: #a8bbb5;
        --auth-border: hsl(140, 10%, 28%);
        --auth-warning-bg: color-mix(in srgb, #f0a500 16%, transparent);
        --auth-warning-text: #ffd999;
        --auth-warning-border: color-mix(in srgb, #f0a500 35%, transparent);
        --auth-error-bg: color-mix(in srgb, #e05a5a 16%, transparent);
        --auth-error-text: #ffb4b4;
        --auth-error-border: color-mix(in srgb, #e05a5a 35%, transparent);
        --auth-success-bg: color-mix(in srgb, #42c99a 14%, transparent);
        --auth-success-text: #9de8cb;
        --auth-success-border: color-mix(in srgb, #42c99a 35%, transparent);
        --auth-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
        color-scheme: dark;
    }
}

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

html,
body {
    min-height: 100%;
}

body.auth-page,
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--auth-bg);
    color: var(--auth-ink);
    font-family: var(--auth-font);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.auth-shell {
    width: min(26rem, 100%);
    animation: auth-fade-in 0.4s ease-out;
}

.auth-card {
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-l);
    box-shadow: var(--auth-shadow);
    padding: 1.75rem 1.5rem 1.5rem;
    text-align: center;
}

.auth-logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    margin: 0 auto 0.75rem;
    display: block;
    border-radius: var(--auth-radius-m);
}

.auth-brand {
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--auth-accent);
    margin-bottom: 1.25rem;
}

.auth-title {
    font-size: 1.25rem;
    font-weight: 650;
    color: var(--auth-ink);
    margin-bottom: 0.5rem;
    line-height: 1.3;
}

.auth-message {
    color: var(--auth-ink-secondary);
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 1.15rem;
}

.auth-alert {
    display: none;
    text-align: left;
    border-radius: var(--auth-radius-m);
    border: 1px solid transparent;
    padding: 0.75rem 0.9rem;
    margin-bottom: 1.15rem;
    font-size: 0.9rem;
    line-height: 1.45;
}

.auth-alert.is-visible {
    display: block;
}

.auth-alert--warning {
    background: var(--auth-warning-bg);
    color: var(--auth-warning-text);
    border-color: var(--auth-warning-border);
}

.auth-alert--error {
    background: var(--auth-error-bg);
    color: var(--auth-error-text);
    border-color: var(--auth-error-border);
}

.auth-alert--success {
    background: var(--auth-success-bg);
    color: var(--auth-success-text);
    border-color: var(--auth-success-border);
}

.auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.55rem 1rem;
    border: none;
    border-radius: var(--auth-radius-m);
    background: var(--auth-accent);
    color: #ffffff;
    text-decoration: none;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.auth-button:hover {
    background: var(--auth-accent-hover);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--auth-accent) 28%, transparent);
}

.auth-button:active {
    transform: translateY(1px);
}

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

.auth-button svg {
    width: 1.05rem;
    height: 1.05rem;
    flex-shrink: 0;
}

.auth-footer {
    margin-top: 1rem;
    color: var(--auth-ink-secondary);
    font-size: 0.82rem;
    line-height: 1.45;
}

.auth-timer {
    margin-top: 0.35rem;
    color: var(--auth-ink-secondary);
    font-size: 0.82rem;
}

/* Loading variant: compact, no heavy card chrome */
.auth-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}

.auth-spinner {
    width: 2rem;
    height: 2rem;
    border: 2.5px solid var(--auth-border);
    border-top-color: var(--auth-accent);
    border-radius: 50%;
    animation: auth-spin 0.75s linear infinite;
}

.auth-loading-label {
    color: var(--auth-ink-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

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

@keyframes auth-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 480px) {
    body.auth-page,
    .auth-page {
        padding: 1rem;
    }

    .auth-card {
        padding: 1.4rem 1.1rem 1.2rem;
    }
}
