/* ──────────────────────────────────────────────────────────────
   Auth pages (login / forgot-password / reset-password).
   Two-panel split: branded gradient panel + clean form panel.

   Self-contained on purpose, exactly like the setup wizard: these pages are
   served before there is a session, so they must not depend on any shared
   application CSS. The palette and typefaces mirror setup.css so the wizard
   and the sign-in page read as one product.
   ────────────────────────────────────────────────────────────── */

:root {
    /* The calm institutional palette of the app screens (css/app/aw-theme.css, tasks/todo-ui-refresh.md). */
    --auth-primary:        #2453C4;
    --auth-primary-hover:  #1C449F;
    --auth-primary-ring:   rgba(36, 83, 196, .20);
    --auth-primary-soft:   rgba(36, 83, 196, .07);
    --auth-bg:             #ffffff;
    --auth-input-bg:       #ffffff;
    --auth-border:         #e3e7ed;
    --auth-border-strong:  #cbd3dd;
    --auth-text:           #0f172a;
    --auth-text-secondary: #475569;
    --auth-text-muted:     #64748b;
    --auth-danger:         #b91c1c;
    --auth-danger-bg:      #fef2f2;
    --auth-success:        #15803d;
    --auth-success-bg:     #f0fdf4;
    --auth-warning:        #b45309;
    --auth-info:           #2453C4;
    --auth-info-bg:        #eef2fb;
    --auth-serif:          "Instrument Serif", Georgia, "Times New Roman", serif;
    --auth-sans:           'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    --auth-mono:           "IBM Plex Mono", "SFMono-Regular", "SF Mono", Menlo, monospace;
}

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

body.auth-body {
    font-family: var(--auth-sans);
    color: var(--auth-text);
    background: var(--auth-bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Split layout ───────────────────────────────────────────── */
.auth-split {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}

/* ── Brand panel (left) ─────────────────────────────────────── */
.auth-brand {
    position: relative;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(160deg, #2A41AE 0%, #1B2F8F 55%, #142270 100%);
    display: flex;
    flex-direction: column;
    padding: 48px 56px;
}
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 70% 80%, rgba(255, 255, 255, .07), transparent 60%);
    pointer-events: none;
}

.auth-brand-head {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: #fff;
}
.auth-brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 11px;
    background: rgba(255, 255, 255, .14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-brand-mark i { font-size: 1.625rem; line-height: 1; color: #fff; }
/* An uploaded logo (/admin/branding) in place of the built-in mark: fitted, never cropped. */
.auth-brand-logo { overflow: hidden; padding: 5px; }
.auth-brand-logo img { display: block; width: 100%; height: 100%; object-fit: contain; }
.auth-brand-name { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.01em; }

.auth-brand-body {
    position: relative;
    z-index: 2;
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.auth-brand-quote {
    font-family: var(--auth-serif);
    font-style: italic;
    font-weight: 500;
    font-size: 2.125rem;
    line-height: 1.2;
    letter-spacing: -0.01em;
    max-width: 16em;
    color: #fff;
}
.auth-brand-sub {
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, .6);
    text-transform: uppercase;
    font-weight: 600;
}

/* Decorative tile field */
.auth-tiles {
    position: absolute;
    top: 13%;
    right: -40px;
    width: 64%;
    max-width: 440px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    transform: rotate(-6deg);
    pointer-events: none;
    z-index: 1;
}
.auth-tiles i {
    aspect-ratio: 1;
    border-radius: 5px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .05);
}
.auth-tiles i.on    { background: rgba(125, 156, 255, .32); border-color: rgba(147, 178, 255, .48); }
.auth-tiles i.pulse { background: rgba(255, 255, 255, .20); border-color: rgba(255, 255, 255, .30); animation: authTilePulse 3.6s ease-in-out infinite; }
@keyframes authTilePulse {
    0%, 100% { background: rgba(255, 255, 255, .12); }
    50%      { background: rgba(255, 255, 255, .28); }
}

/* ── Form panel (right) ─────────────────────────────────────── */
.auth-form-side {
    display: flex;
    flex-direction: column;
    padding: 28px 24px;
    background: var(--auth-bg);
}
.auth-form-head {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--auth-text-secondary);
}
.auth-form-head > i { font-size: 0.9375rem; }
.auth-form-head a.link-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--auth-text-secondary);
    text-decoration: none;
    font-weight: 600;
}
.auth-form-head a.link-back:hover { color: var(--auth-text); }

.auth-form-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}
.auth-card-tight { width: 100%; max-width: 420px; }
.auth-card-tight h1 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.12;
    margin: 0 0 10px;
    color: var(--auth-text);
}
.auth-card-tight h1 em {
    display: block;
    font-family: var(--auth-serif);
    font-style: italic;
    font-weight: 500;
}
.auth-sub {
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--auth-text-secondary);
    margin: 0 0 26px;
}

/* ── Form controls ──────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--auth-text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    height: 44px;
    background: var(--auth-input-bg);
    border: 1px solid var(--auth-border-strong);
    color: var(--auth-text);
    padding: 0 14px;
    border-radius: 9px;
    font-size: 0.9375rem;
    font-family: inherit;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control::placeholder { color: var(--auth-text-muted); }
.form-control:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px var(--auth-primary-ring);
}
.form-control.is-invalid { border-color: var(--auth-danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(222, 53, 11, .15); }
.form-control.is-valid { border-color: var(--auth-success); }

/* Input with trailing toggle (password) */
.input-group { position: relative; }
.input-group .form-control { padding-right: 44px; }
.input-group-append {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
}
.btn-toggle-password {
    background: transparent;
    border: none;
    color: var(--auth-text-muted);
    cursor: pointer;
    padding: 6px;
    line-height: 1;
    border-radius: 6px;
}
.btn-toggle-password:hover { color: var(--auth-text); }
.btn-toggle-password i { font-size: 1.05rem; }

/* Row: remember-me + forgot link */
.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
}
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input {
    width: 16px;
    height: 16px;
    accent-color: var(--auth-primary);
    cursor: pointer;
}
.form-check-label { font-size: 0.875rem; color: var(--auth-text-secondary); cursor: pointer; }

.link {
    color: var(--auth-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}
.link:hover { text-decoration: underline; }
/* A lone link under a submit button (the code step's "use a different account"). */
.form-row-center { justify-content: center; margin-top: 16px; margin-bottom: 0; }

/* ── Primary button ─────────────────────────────────────────── */
.btn-primary {
    width: 100%;
    height: 46px;
    background: var(--auth-primary);
    border: none;
    color: #fff;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background .12s ease, box-shadow .12s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover { background: var(--auth-primary-hover); }
.btn-primary:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--auth-primary-ring); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; }
.btn-primary .spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: authSpin .7s linear infinite;
}
.btn-primary.loading .spinner { display: block; }
.btn-primary.loading .btn-text { display: none; }
@keyframes authSpin { to { transform: rotate(360deg); } }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 11px 13px;
    border-radius: 9px;
    font-size: 0.875rem;
    margin-bottom: 18px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
}
.alert i { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--auth-danger-bg);  border: 1px solid rgba(222, 53, 11, .2); color: var(--auth-danger); }
.alert-success { background: var(--auth-success-bg); border: 1px solid rgba(31, 138, 85, .2); color: var(--auth-success); }
.alert-info    { background: var(--auth-info-bg);    border: 1px solid rgba(46, 75, 201, .2); color: var(--auth-info); }

.field-error {
    font-size: 0.75rem;
    color: var(--auth-danger);
    margin-top: 5px;
    display: none;
}
.field-error.show { display: block; }

/* ── Password strength meter + requirements (reset page) ────── */
.password-strength { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.strength-bar {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: var(--auth-border);
    overflow: hidden;
}
.strength-fill {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: width .16s ease, background .16s ease;
}
.strength-fill.weak   { width: 30%;  background: var(--auth-danger); }
.strength-fill.fair   { width: 55%;  background: var(--auth-warning); }
.strength-fill.good   { width: 80%;  background: #2E7DC9; }
.strength-fill.strong { width: 100%; background: var(--auth-success); }
.strength-text { font-size: 0.75rem; font-weight: 600; min-width: 3.5em; }
.strength-text.weak   { color: var(--auth-danger); }
.strength-text.fair   { color: var(--auth-warning); }
.strength-text.good   { color: #2E7DC9; }
.strength-text.strong { color: var(--auth-success); }

.password-requirements {
    display: grid;
    gap: 6px;
    padding: 12px 14px;
    border: 1px solid var(--auth-border);
    border-radius: 9px;
    background: #fafbfd;
}
.requirement {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--auth-text-secondary);
}
.requirement i { font-size: 0.9rem; color: var(--auth-text-muted); }
.requirement.met { color: var(--auth-success); }
.requirement.met i { color: var(--auth-success); }

/* ── Section toggles + success / error states ───────────────── */
.request-section.hide,
.reset-section.hide,
.login-section.hide { display: none; }

.success-section { display: none; text-align: center; }
.success-section.show { display: block; }
.invalid-token-section { text-align: center; }

.success-icon,
.error-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}
.success-icon { background: var(--auth-success-bg); }
.success-icon i { font-size: 2rem; color: var(--auth-success); }
.error-icon { background: var(--auth-danger-bg); }
.error-icon i { font-size: 2rem; color: var(--auth-danger); }

.success-title,
.error-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 8px; }
.success-message,
.error-message { font-size: 0.875rem; color: var(--auth-text-secondary); line-height: 1.6; margin-bottom: 16px; }
.success-email { font-family: var(--auth-mono); color: var(--auth-primary); }

/* ── Footer ─────────────────────────────────────────────────── */
.auth-foot {
    text-align: center;
    margin-top: 22px;
    font-size: 0.875rem;
    color: var(--auth-text-muted);
}
.auth-foot a { color: var(--auth-primary); text-decoration: none; font-weight: 500; }
.auth-foot a:hover { text-decoration: underline; }
.version-badge { font-size: 0.6875rem; color: var(--auth-text-muted); margin-top: 8px; }

/* ── Responsive: collapse to single column ──────────────────── */
@media (max-width: 992px) {
    .auth-split { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-form-side { padding: 24px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-tiles i.pulse { animation: none; background: rgba(255, 255, 255, .20); }
}
