/* ═══════════════════════════════════════════════════
   SSO Auth Pages — Modern Metro
   Customizable via CSS custom properties (tenant branding)
   ═══════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────── */
:root {
    --sso-primary: #4f46e5;
    --sso-bg: #eceef2;
    --sso-card-bg: #ffffff;
    --sso-text: #111;
    --sso-text-secondary: #5f6368;
    --sso-border: #dadce0;
    --sso-input-bg: #f8f9fa;
    --sso-radius: 4px;
    --sso-font: 'Outfit', system-ui, -apple-system, sans-serif;
}

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

.auth-body {
    font-family: var(--sso-font);
    color: var(--sso-text);
    background: var(--sso-bg);
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── Wrapper ──────────────────────────────────────── */
.auth-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

/* ── Card ─────────────────────────────────────────── */
.auth-card {
    width: 100%;
    background: var(--sso-card-bg);
    border-radius: var(--sso-radius);
    border: none;
    box-shadow:
        0 0 0 1px rgb(0 0 0 / .08),
        0 2px 4px rgb(0 0 0 / .06),
        0 8px 24px rgb(0 0 0 / .1),
        0 24px 48px rgb(0 0 0 / .06);
    overflow: hidden;
    animation: fadeIn .2s ease both;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Brand Bar (colored header) ───────────────────── */
.auth-brand-bar {
    background:
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 8px,
            rgb(255 255 255 / .05) 8px,
            rgb(255 255 255 / .05) 16px
        ),
        linear-gradient(180deg,
            color-mix(in srgb, var(--sso-primary) 92%, #fff) 0%,
            var(--sso-primary) 100%
        );
    padding: 1.125rem 1.75rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgb(0 0 0 / .15);
    position: relative;
}

/* Subtle bottom highlight */
.auth-brand-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgb(255 255 255 / .1);
}

.auth-brand-bar .auth-logo {
    height: 26px;
    width: auto;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.auth-brand-name {
    color: #fff;
    font-size: .9375rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* ── Card Body ────────────────────────────────────── */
.auth-card-body {
    padding: 2rem 1.75rem 1.75rem;
}

/* ── Heading ──────────────────────────────────────── */
.auth-heading {
    margin-bottom: 1.75rem;
}

.auth-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--sso-text);
    margin: 0;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.auth-subtitle {
    font-size: .875rem;
    color: var(--sso-text-secondary);
    margin: .5rem 0 0;
    line-height: 1.5;
    font-weight: 400;
}

/* ── Form ─────────────────────────────────────────── */
.auth-form .mb-3 {
    margin-bottom: 1.125rem !important;
}

.auth-form .form-label {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--sso-text);
    margin-bottom: .375rem;
    display: block;
    letter-spacing: .01em;
}

.auth-form .form-control {
    height: 44px;
    border-radius: var(--sso-radius);
    border: 1px solid var(--sso-border);
    padding: 0 .875rem;
    font-size: .9375rem;
    font-family: var(--sso-font);
    color: var(--sso-text);
    background: var(--sso-input-bg);
    transition: border-color .15s, background .15s, box-shadow .15s;
    width: 100%;
}

.auth-form .form-control:hover {
    border-color: #bfc3c9;
}

.auth-form .form-control:focus {
    background: #fff;
    border-color: var(--sso-primary);
    box-shadow: inset 0 -2px 0 var(--sso-primary);
    outline: none;
}

.auth-form .form-control::placeholder {
    color: var(--sso-text-secondary);
    opacity: .55;
}

/* Code inputs (MFA / recovery) */
.auth-form .form-control.code-input {
    text-align: center;
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: .3em;
    padding: .75rem;
    height: auto;
}

/* ── Primary Button ───────────────────────────────── */
.btn-sso-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    height: 44px;
    padding: 0 1.25rem;
    border: none;
    border-radius: var(--sso-radius);
    background: var(--sso-primary);
    color: #fff;
    font-size: .9375rem;
    font-weight: 600;
    font-family: var(--sso-font);
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    text-decoration: none;
    line-height: 1.5;
    letter-spacing: .01em;
}

.btn-sso-primary:hover {
    background: color-mix(in srgb, var(--sso-primary) 85%, #000);
    box-shadow: 0 2px 12px color-mix(in srgb, var(--sso-primary) 25%, transparent);
    color: #fff;
}

.btn-sso-primary:active {
    background: color-mix(in srgb, var(--sso-primary) 78%, #000);
    box-shadow: none;
}

/* ── Outline / Provider Button ────────────────────── */
.btn-sso-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    width: 100%;
    height: 42px;
    padding: 0 1rem;
    border: 1px solid var(--sso-border);
    border-radius: var(--sso-radius);
    background: var(--sso-card-bg);
    color: var(--sso-text);
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--sso-font);
    cursor: pointer;
    transition: border-color .15s, background .15s;
    text-decoration: none;
}

.btn-sso-outline:hover {
    border-color: var(--sso-primary);
    background: color-mix(in srgb, var(--sso-primary) 4%, #fff);
    color: var(--sso-primary);
}

/* ── Divider ──────────────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: .875rem;
    margin: 1.5rem 0;
    color: var(--sso-text-secondary);
    font-size: .8125rem;
    font-weight: 500;
    white-space: nowrap;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--sso-border);
}

/* ── Providers ────────────────────────────────────── */
.auth-providers {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

/* ── Provider Buttons (new) ──────────────────────── */
.auth-providers-grid {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-bottom: .75rem;
}

.auth-providers-grid form {
    display: contents;
}

.auth-provider-group-label {
    font-size: .6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--sso-text-secondary);
    margin: .75rem 0 .375rem;
}

.auth-provider-group-label:first-child {
    margin-top: 0;
}

.btn-provider {
    --provider-color: var(--sso-text);
    display: inline-flex;
    align-items: center;
    gap: .625rem;
    width: 100%;
    height: 44px;
    padding: 0 1rem;
    border: 1px solid var(--sso-border);
    border-radius: var(--sso-radius);
    background: var(--sso-card-bg);
    color: var(--sso-text);
    font-size: .875rem;
    font-weight: 500;
    font-family: var(--sso-font);
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
    text-decoration: none;
    text-align: left;
}

.btn-provider:hover {
    border-color: var(--provider-color, var(--sso-primary));
    background: color-mix(in srgb, var(--provider-color, var(--sso-primary)) 4%, #fff);
}

.btn-provider:active {
    background: color-mix(in srgb, var(--provider-color, var(--sso-primary)) 8%, #fff);
}

.provider-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.provider-icon svg {
    width: 20px;
    height: 20px;
}

/* ── Preferred provider ──────────────────────────── */
.auth-preferred-provider {
    margin-bottom: .5rem;
}

.btn-provider-preferred {
    height: 48px;
    font-weight: 600;
    border-color: var(--provider-color, var(--sso-primary));
    background: color-mix(in srgb, var(--provider-color, var(--sso-primary)) 4%, #fff);
    position: relative;
}

.btn-provider-preferred:hover {
    background: color-mix(in srgb, var(--provider-color, var(--sso-primary)) 10%, #fff);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--provider-color, var(--sso-primary)) 15%, transparent);
}

.provider-badge {
    margin-left: auto;
    font-size: .625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .125rem .375rem;
    border-radius: 2px;
    background: color-mix(in srgb, var(--provider-color, var(--sso-primary)) 12%, transparent);
    color: var(--provider-color, var(--sso-primary));
}

/* ── Provider-specific brand colors ──────────────── */
.btn-provider-google  { --provider-color: #4285F4; }
.btn-provider-microsoft { --provider-color: #00A4EF; }
.btn-provider-github  { --provider-color: #24292e; }
.btn-provider-apple   { --provider-color: #000000; }
.btn-provider-okta    { --provider-color: #007dc1; }
.btn-provider-saml    { --provider-color: #e34f26; }

/* ── Links ────────────────────────────────────────── */
.auth-links {
    text-align: center;
    margin-top: 1.5rem;
    font-size: .875rem;
    color: var(--sso-text-secondary);
}

.auth-links a {
    color: var(--sso-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-links a:hover {
    text-decoration: underline;
}

.auth-forgot-link {
    font-size: .8125rem;
    color: var(--sso-primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-forgot-link:hover {
    text-decoration: underline;
}

/* ── Alerts ───────────────────────────────────────── */
.auth-alert {
    background: #fef2f2;
    color: #991b1b;
    border: none;
    border-left: 3px solid #dc2626;
    border-radius: 0;
    padding: .75rem 1rem;
    font-size: .8125rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.auth-alert:empty { display: none; }

.auth-alert-success {
    background: #f0fdf4;
    color: #166534;
    border-left-color: #16a34a;
}

.auth-alert-info {
    background: color-mix(in srgb, var(--sso-primary) 5%, #fff);
    color: var(--sso-text);
    border-left-color: var(--sso-primary);
}

/* ── Info Pages (Confirmation, Success, Error) ────── */
.auth-info {
    text-align: center;
    padding: .5rem 0;
}

.auth-info-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--sso-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.375rem;
    margin-bottom: 1rem;
}

.auth-info-icon.success {
    background: #ecfdf5;
    color: #059669;
}

.auth-info-icon.error {
    background: #fef2f2;
    color: #dc2626;
}

.auth-info-icon.info {
    background: color-mix(in srgb, var(--sso-primary) 8%, #fff);
    color: var(--sso-primary);
}

.auth-info-icon.warning {
    background: #fffbeb;
    color: #d97706;
}

.auth-info p {
    color: var(--sso-text-secondary);
    font-size: .9375rem;
    line-height: 1.6;
    margin: 0 0 1.5rem;
}

.auth-info .btn-sso-primary {
    width: auto;
    min-width: 140px;
    display: inline-flex;
}

/* ── Key / Code Display ───────────────────────────── */
.auth-code-box {
    background: var(--sso-input-bg);
    border: 1px solid var(--sso-border);
    border-radius: var(--sso-radius);
    padding: .75rem 1rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: .8125rem;
    word-break: break-all;
    margin-bottom: 1rem;
}

.auth-code-box strong {
    font-weight: 600;
    color: var(--sso-text);
}

/* ── QR Code ──────────────────────────────────────── */
.auth-qr {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.auth-qr img,
.auth-qr canvas {
    border-radius: var(--sso-radius);
}

/* ── Validation ───────────────────────────────────── */
.field-validation-error,
.auth-form .text-danger {
    font-size: .75rem;
    color: #dc2626;
    margin-top: .25rem;
    display: block;
}

/* ── Footer ───────────────────────────────────────── */
.auth-footer {
    font-size: .6875rem;
    color: var(--sso-text-secondary);
    opacity: .4;
    letter-spacing: .01em;
}

.auth-footer strong {
    font-weight: 600;
}

/* ── Wider variant (sessions, tables) ─────────────── */
.auth-wrapper-wide {
    max-width: 540px;
}

/* ── Profile Navigation ──────────────────────────── */
.auth-profile-nav {
    display: flex;
    gap: .25rem;
    margin-bottom: 1.5rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--sso-border);
    flex-wrap: wrap;
}

.auth-profile-nav a {
    font-size: .8125rem;
    font-weight: 500;
    color: var(--sso-text-secondary);
    text-decoration: none;
    padding: .375rem .625rem;
    border-radius: var(--sso-radius);
    transition: background .15s, color .15s;
}

.auth-profile-nav a:hover {
    background: color-mix(in srgb, var(--sso-primary) 8%, transparent);
    color: var(--sso-primary);
}

.auth-profile-nav a.active {
    background: color-mix(in srgb, var(--sso-primary) 10%, transparent);
    color: var(--sso-primary);
    font-weight: 600;
}

/* ── Session Item ─────────────────────────────────── */
.auth-session {
    border: 1px solid var(--sso-border);
    border-radius: var(--sso-radius);
    padding: .75rem 1rem;
    margin-bottom: .5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    transition: border-color .15s;
}

.auth-session:hover {
    border-color: var(--sso-primary);
}

.auth-session.revoked {
    opacity: .5;
}

.auth-session-meta {
    font-size: .8125rem;
    color: var(--sso-text-secondary);
    line-height: 1.6;
}

.auth-session-meta strong {
    color: var(--sso-text);
    font-weight: 600;
}

/* ── Recovery Codes Grid ──────────────────────────── */
.auth-recovery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .375rem;
    margin-bottom: 1.25rem;
}

.auth-recovery-grid code {
    display: block;
    background: var(--sso-input-bg);
    border: 1px solid var(--sso-border);
    border-radius: var(--sso-radius);
    padding: .5rem .75rem;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: .8125rem;
    text-align: center;
    color: var(--sso-text);
}

/* ── Consent Scope List ───────────────────────────── */
.auth-scope-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem;
}

.auth-scope-list li {
    display: flex;
    align-items: center;
    gap: .625rem;
    padding: .5rem .75rem;
    border: 1px solid var(--sso-border);
    border-radius: var(--sso-radius);
    margin-bottom: .375rem;
    font-size: .875rem;
    color: var(--sso-text);
}

.auth-scope-list li i {
    color: var(--sso-primary);
    font-size: .875rem;
}

/* ── Button Danger ────────────────────────────────── */
.btn-sso-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .5rem 1rem;
    border: 1px solid #fecaca;
    border-radius: var(--sso-radius);
    background: #fef2f2;
    color: #dc2626;
    font-size: .8125rem;
    font-weight: 500;
    font-family: var(--sso-font);
    cursor: pointer;
    transition: background .15s, border-color .15s;
    text-decoration: none;
}

.btn-sso-danger:hover {
    background: #fee2e2;
    border-color: #f87171;
    color: #dc2626;
}

.btn-sso-danger-sm {
    padding: .3125rem .625rem;
    font-size: .75rem;
}

/* ── Divider (thin) ───────────────────────────────── */
.auth-divider-thin {
    height: 1px;
    background: var(--sso-border);
    margin: 1.25rem 0;
}

/* ── Badge ────────────────────────────────────────── */
.auth-badge {
    font-size: .6875rem;
    font-weight: 600;
    padding: .125rem .4rem;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.auth-badge-muted {
    background: #f3f4f6;
    color: var(--sso-text-secondary);
}

.auth-badge-success {
    background: #ecfdf5;
    color: #059669;
}

/* ── Action group ─────────────────────────────────── */
.auth-actions {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: 1.25rem;
}

/* ── Backward compat: old layout classes ──────────── */
.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-logo-placeholder {
    display: none;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 480px) {
    .auth-wrapper,
    .auth-wrapper-wide {
        padding: 1rem .75rem;
    }

    .auth-card-body {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .auth-recovery-grid {
        grid-template-columns: 1fr;
    }
}
