/* ==========================================================================
   KCRF Unified Authentication Design System (Split-Screen, Light/Dark, WCAG AA)
   Reuses KCRF brand variables from Branding & PublicWebsiteSettings.
   ========================================================================== */

:root {
    --auth-primary: #ff6b00;
    --auth-primary-dark: #d95700;
    --auth-secondary: #1b5147;
    --auth-btn: var(--auth-primary);
    --auth-bg: #f6f4f0;
    --auth-surface: #ffffff;
    --auth-surface-muted: #f2efe9;
    --auth-ink: #172026;
    --auth-ink-muted: #52606d;
    --auth-border: rgba(23, 32, 38, 0.13);
    --auth-border-strong: rgba(23, 32, 38, 0.24);
    --auth-input-bg: #ffffff;
    --auth-shadow: 0 20px 50px rgba(15, 23, 42, 0.08), 0 4px 14px rgba(15, 23, 42, 0.04);
    --auth-focus-ring: color-mix(in srgb, var(--auth-primary) 26%, transparent);
    --auth-error: #c81e1e;
    --auth-error-bg: #fef2f2;
    --auth-error-border: #fecaca;
    --auth-success: #15803d;
    --auth-success-bg: #f0fdf4;
    --auth-success-border: #bbf7d0;
    --auth-warning: #a16207;
    --auth-warning-bg: #fefce8;
    --auth-warning-border: #fde68a;
    --auth-info: #1d4ed8;
    --auth-info-bg: #eff6ff;
    --auth-info-border: #bfdbfe;
    --auth-radius: 18px;
    --auth-radius-sm: 11px;
    --auth-font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --auth-font-serif: 'DM Serif Display', Georgia, serif;
}

html[data-theme="dark"] {
    --auth-bg: #0c1218;
    --auth-surface: #141d26;
    --auth-surface-muted: #1b2632;
    --auth-ink: #f1f5f9;
    --auth-ink-muted: #a6b4c3;
    --auth-border: rgba(255, 255, 255, 0.12);
    --auth-border-strong: rgba(255, 255, 255, 0.22);
    --auth-input-bg: #0f1720;
    --auth-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    --auth-error: #fca5a5;
    --auth-error-bg: rgba(239, 68, 68, 0.14);
    --auth-error-border: rgba(248, 113, 113, 0.32);
    --auth-success: #86efac;
    --auth-success-bg: rgba(34, 197, 94, 0.14);
    --auth-success-border: rgba(74, 222, 128, 0.30);
    --auth-warning: #fde047;
    --auth-warning-bg: rgba(234, 179, 8, 0.14);
    --auth-warning-border: rgba(250, 204, 21, 0.30);
    --auth-info: #93c5fd;
    --auth-info-bg: rgba(59, 130, 246, 0.14);
    --auth-info-border: rgba(96, 165, 250, 0.30);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: var(--auth-font);
    background: var(--auth-bg);
    color: var(--auth-ink);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

.auth-skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    z-index: 1000;
    padding: 10px 16px;
    background: var(--auth-primary);
    color: #fff;
    border-radius: 999px;
    font-weight: 600;
    text-decoration: none;
}
.auth-skip-link:focus { left: 12px; }

/* ── Split-Screen Shell ────────────────────────────────────────────────── */
.auth-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(380px, 47%) 1fr;
}

/* ── Left Branded Showcase Panel ───────────────────────────────────────── */
.auth-brand-panel {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(28px, 4vw, 52px);
    color: #ffffff;
    background: linear-gradient(
        145deg,
        color-mix(in srgb, var(--auth-secondary) 88%, #071210) 0%,
        #0f1f1c 58%,
        color-mix(in srgb, var(--auth-primary) 55%, #12171c) 100%
    );
}

.auth-slides {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.auth-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 1.1s ease-in-out;
}
.auth-slide.is-active { opacity: 1; }

.auth-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.auth-brand-scrim {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(9, 18, 22, 0.56) 0%,
        rgba(9, 18, 22, 0.48) 42%,
        rgba(9, 18, 22, 0.86) 100%
    );
    pointer-events: none;
}

.auth-brand-top,
.auth-brand-bottom {
    position: relative;
    z-index: 2;
}

.auth-brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    text-decoration: none;
    color: #ffffff;
}

.auth-logo-box {
    min-width: 60px;
    max-width: 180px;
    height: 64px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    padding: 6px 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    flex-shrink: 0;
}
.auth-logo-box img {
    max-width: 100%;
    max-height: 52px;
    width: auto;
    height: auto;
    object-fit: contain;
}
.auth-logo-monogram {
    width: 54px;
    height: 54px;
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: 14px;
    background: var(--auth-primary);
    color: #ffffff;
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    flex-shrink: 0;
}
.auth-brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.auth-org-name {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    display: block;
    line-height: 1.25;
    overflow-wrap: break-word;
}
.auth-org-short {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
    display: block;
    line-height: 1.3;
    overflow-wrap: break-word;
}

.auth-brand-bottom {
    max-width: 480px;
}

.auth-brand-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(8px);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.auth-brand-headline {
    font-family: var(--auth-font-serif);
    font-size: clamp(1.9rem, 2.8vw, 2.75rem);
    font-weight: 400;
    line-height: 1.15;
    margin: 0 0 14px;
    color: #ffffff;
}

.auth-brand-tagline {
    font-size: 0.98rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 22px;
}

.auth-slide-dots {
    display: flex;
    align-items: center;
    gap: 8px;
}
.auth-slide-dot {
    width: 24px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.35);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.25s ease, width 0.25s ease;
}
.auth-slide-dot.is-active {
    width: 40px;
    background: var(--auth-primary);
}
.auth-slide-dot:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ── Right Form Column ─────────────────────────────────────────────────── */
.auth-main {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    padding: clamp(18px, 3vw, 34px);
    background: var(--auth-bg);
}

.auth-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 520px;
    margin: 0 auto 18px;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    border-radius: 999px;
    border: 1px solid var(--auth-border);
    background: var(--auth-surface);
    color: var(--auth-ink);
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none;
    transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.auth-back-link i { color: var(--auth-primary); }
.auth-back-link:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
    transform: translateY(-1px);
}
.auth-back-link:focus-visible {
    outline: 3px solid var(--auth-focus-ring);
    outline-offset: 2px;
}

.auth-theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid var(--auth-border);
    background: var(--auth-surface);
    color: var(--auth-ink);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}
.auth-theme-btn:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
}
.auth-theme-btn:focus-visible {
    outline: 3px solid var(--auth-focus-ring);
    outline-offset: 2px;
}

/* Mobile-only compact brand header */
.auth-mobile-brand {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0 auto 18px;
    text-decoration: none;
    color: var(--auth-ink);
}

.auth-card-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}
.auth-card-wrap.auth-card-wide { max-width: 540px; }

.auth-card {
    background: var(--auth-surface);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    padding: clamp(24px, 4vw, 38px);
}

.auth-card-header { margin-bottom: 24px; }

.auth-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    background: color-mix(in srgb, var(--auth-primary) 12%, transparent);
    color: var(--auth-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 14px;
}
.auth-card-icon.is-success {
    background: var(--auth-success-bg);
    color: var(--auth-success);
}
.auth-card-icon.is-danger {
    background: var(--auth-error-bg);
    color: var(--auth-error);
}

.auth-title {
    font-family: var(--auth-font-serif);
    font-size: clamp(1.55rem, 2.2vw, 1.95rem);
    font-weight: 400;
    line-height: 1.2;
    margin: 0 0 6px;
    color: var(--auth-ink);
}

.auth-subtitle {
    margin: 0;
    font-size: 0.93rem;
    color: var(--auth-ink-muted);
}

.auth-welcome-note {
    margin-top: 14px;
    padding: 11px 14px;
    border-radius: var(--auth-radius-sm);
    background: var(--auth-surface-muted);
    border: 1px solid var(--auth-border);
    font-size: 0.86rem;
    color: var(--auth-ink-muted);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.auth-welcome-note i { color: var(--auth-primary); margin-top: 2px; flex-shrink: 0; }

/* ── Alerts ────────────────────────────────────────────────────────────── */
.auth-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--auth-radius-sm);
    border: 1px solid var(--auth-border);
    font-size: 0.88rem;
    line-height: 1.45;
    margin-bottom: 18px;
}
.auth-alert i { font-size: 1.05rem; margin-top: 1px; flex-shrink: 0; }
.auth-alert.is-error {
    background: var(--auth-error-bg);
    border-color: var(--auth-error-border);
    color: var(--auth-error);
}
.auth-alert.is-success {
    background: var(--auth-success-bg);
    border-color: var(--auth-success-border);
    color: var(--auth-success);
}
.auth-alert.is-warning {
    background: var(--auth-warning-bg);
    border-color: var(--auth-warning-border);
    color: var(--auth-warning);
}
.auth-alert.is-info {
    background: var(--auth-info-bg);
    border-color: var(--auth-info-border);
    color: var(--auth-info);
}

/* ── Form Controls ─────────────────────────────────────────────────────── */
.auth-field { margin-bottom: 18px; }
.auth-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.auth-label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--auth-ink);
    margin-bottom: 6px;
}

.auth-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input-icon {
    position: absolute;
    left: 14px;
    color: var(--auth-ink-muted);
    font-size: 1rem;
    pointer-events: none;
}

.auth-input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    font-family: var(--auth-font);
    font-size: 0.95rem;
    color: var(--auth-ink);
    background: var(--auth-input-bg);
    border: 1.5px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 46px;
}
.auth-input.has-toggle { padding-right: 46px; }
.auth-input::placeholder { color: var(--auth-ink-muted); opacity: 0.72; }
.auth-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3.5px var(--auth-focus-ring);
}
.auth-input[aria-invalid="true"] {
    border-color: var(--auth-error);
}
.auth-input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3.5px rgba(200, 30, 30, 0.2);
}

.auth-pw-toggle {
    position: absolute;
    right: 6px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--auth-ink-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    cursor: pointer;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.auth-pw-toggle:hover {
    color: var(--auth-ink);
    background: var(--auth-surface-muted);
}
.auth-pw-toggle:focus-visible {
    outline: 2.5px solid var(--auth-primary);
    outline-offset: 1px;
}

.auth-field-error {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--auth-error);
}
.auth-field-error i { margin-top: 2px; flex-shrink: 0; }

.auth-field-help {
    margin-top: 6px;
    font-size: 0.81rem;
    color: var(--auth-ink-muted);
}

/* ── Password Strength Meter ───────────────────────────────────────────── */
.pw-strength {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--auth-radius-sm);
    background: var(--auth-surface-muted);
    border: 1px solid var(--auth-border);
}
.pw-strength-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--auth-ink-muted);
}
.pw-strength-label[data-level="1"] { color: var(--auth-error); }
.pw-strength-label[data-level="2"] { color: #d97706; }
.pw-strength-label[data-level="3"] { color: #2563eb; }
.pw-strength-label[data-level="4"] { color: var(--auth-success); }

.pw-strength-bars {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}
.pw-strength-seg {
    height: 5px;
    border-radius: 999px;
    background: var(--auth-border-strong);
    transition: background-color 0.2s ease;
}
.pw-strength[data-level="1"] .pw-strength-seg:nth-child(-n+1) { background: #dc2626; }
.pw-strength[data-level="2"] .pw-strength-seg:nth-child(-n+2) { background: #d97706; }
.pw-strength[data-level="3"] .pw-strength-seg:nth-child(-n+3) { background: #2563eb; }
.pw-strength[data-level="4"] .pw-strength-seg:nth-child(-n+4) { background: #16a34a; }

.pw-rules {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    font-size: 0.76rem;
    color: var(--auth-ink-muted);
}
.pw-rules li {
    display: flex;
    align-items: center;
    gap: 5px;
}
.pw-rules li.is-met { color: var(--auth-success); font-weight: 500; }

.pw-match-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    min-height: 1.2em;
}
.pw-match-hint.is-match { color: var(--auth-success); }
.pw-match-hint.is-mismatch { color: var(--auth-error); }

/* ── Actions Row (Remember Me + Forgot Password) ───────────────────────── */
.auth-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin: 2px 0 22px;
}

.auth-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 0.88rem;
    color: var(--auth-ink);
    cursor: pointer;
    user-select: none;
}
.auth-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--auth-primary);
    border-radius: 4px;
    cursor: pointer;
    margin: 0;
}
.auth-checkbox input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--auth-focus-ring);
    outline-offset: 2px;
}

.auth-link {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    transition: opacity 0.15s ease;
}
.auth-link:hover { text-decoration: underline; }
.auth-link:focus-visible {
    outline: 2.5px solid var(--auth-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Primary & Secondary Buttons ───────────────────────────────────────── */
.auth-btn-primary {
    width: 100%;
    min-height: 48px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--auth-radius-sm);
    background: var(--auth-btn);
    color: var(--auth-btn-ink, #ffffff);
    font-family: var(--auth-font);
    font-size: 0.96rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 18px color-mix(in srgb, var(--auth-btn) 30%, transparent);
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.auth-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: brightness(0.95);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--auth-btn) 38%, transparent);
}
.auth-btn-primary:focus-visible {
    outline: 3px solid var(--auth-focus-ring);
    outline-offset: 2px;
}
.auth-btn-primary:disabled {
    opacity: 0.78;
    cursor: wait;
}

.auth-btn-secondary {
    width: 100%;
    min-height: 44px;
    padding: 10px 18px;
    border: 1.5px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    background: transparent;
    color: var(--auth-ink);
    font-family: var(--auth-font);
    font-size: 0.92rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: border-color 0.18s ease, color 0.18s ease;
}
.auth-btn-secondary:hover {
    border-color: var(--auth-primary);
    color: var(--auth-primary);
}
.auth-btn-secondary:focus-visible {
    outline: 3px solid var(--auth-focus-ring);
    outline-offset: 2px;
}

.auth-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: authSpin 0.65s linear infinite;
}
.auth-btn-primary.is-loading .auth-spinner { display: inline-block; }
.auth-btn-primary.is-loading .auth-btn-icon { display: none; }

@keyframes authSpin { to { transform: rotate(360deg); } }

/* ── Footer & Preview Bar ──────────────────────────────────────────────── */
.auth-card-footer {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--auth-border);
    text-align: center;
    font-size: 0.88rem;
    color: var(--auth-ink-muted);
}
.auth-card-footer p { margin: 0 0 6px; }
.auth-card-footer p:last-child { margin-bottom: 0; }

.auth-meta-footer {
    max-width: 480px;
    margin: 18px auto 0;
    text-align: center;
    font-size: 0.78rem;
    color: var(--auth-ink-muted);
    line-height: 1.6;
}
.auth-meta-footer .auth-slogan {
    color: var(--auth-primary);
    font-weight: 600;
}

.auth-preview-bar {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
}
.auth-preview-bar button {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-family: var(--auth-font);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.auth-preview-apply { background: var(--auth-primary); color: #ffffff; }
.auth-preview-discard { background: rgba(255, 255, 255, 0.14); color: #f8fafc; }

/* ── Responsive Breakpoints ────────────────────────────────────────────── */
@media (max-width: 959.98px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand-panel { display: none; }
    .auth-mobile-brand { display: inline-flex; }
}

@media (max-width: 575.98px) {
    .auth-row-2 { grid-template-columns: 1fr; gap: 0; }
    .pw-rules { grid-template-columns: 1fr; }
    .auth-card { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .auth-slide, .auth-btn-primary, .auth-back-link, .auth-spinner {
        transition: none !important;
        animation: none !important;
    }
}
