/* =========================================================
   SSO Login — Serene Split (2026-04-15)
   Page-scoped. Loads AFTER portal-theme-20250808.css.
   ========================================================= */

/* ── Kill the animated body background inherited from portal-theme ── */
body.login-page::before,
body.login-page::after { content: none !important; display: none !important; }

body.login-page {
    animation: none !important;
    background: var(--bg-1);
    min-height: 100vh;
    overflow: hidden;   /* login fits in one viewport; prevent bounce */
}

/* ── Layout shell ── */
.login-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;   /* 50/50 desktop */
    min-height: 100vh;
    width: 100%;
}
/* RTL: first grid column is visually RIGHT.
   Markup order: brand-panel first → shows on the right. */

.brand-panel {
    background: linear-gradient(135deg, var(--bg-2), var(--brand-2));
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
html[data-theme="dark"] .brand-panel {
    background: linear-gradient(135deg, var(--bg-1), var(--bg-3));
}

.brand-inner {
    width: 100%;
    text-align: center;
}

.form-panel {
    --surface-form: #f7f2ea;
    background: var(--surface-form);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}
html[data-theme="dark"] .form-panel {
    --surface-form: #26221f;
}

.form-inner {
    --card-surface: #ffffff;
    --card-border: rgba(138, 115, 79, 0.18);   /* brand-tinted hairline */
    --card-accent: linear-gradient(90deg, var(--brand), var(--brand-2));

    width: 100%;
    max-width: 440px;
    padding: 44px 36px;
    background: var(--card-surface);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 12px 32px rgba(60, 45, 25, 0.10);
    position: relative;
    overflow: hidden;
}
/* Subtle bronze accent bar at the card's top edge */
.form-inner::before {
    content: "";
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    height: 3px;
    background: var(--card-accent);
    opacity: .85;
}

html[data-theme="dark"] .form-inner {
    --card-surface: #2e2925;
    --card-border: rgba(209, 197, 163, 0.14);
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.3),
        0 16px 40px rgba(0, 0, 0, 0.35);
}

/* Ultra-wide: cap the form card's visual reach on very wide monitors */
@media (min-width: 1600px) {
    .form-inner { max-width: 520px; }
}

/* Tablet: 40% brand / 60% form */
@media (max-width: 991.98px) {
    .login-shell { grid-template-columns: 40% 60%; }
    .brand-panel, .form-panel { padding: 36px; }
}

/* Mobile: single column, brand becomes a header strip */
@media (max-width: 767.98px) {
    body.login-page { overflow: auto; }
    .login-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        min-height: 100vh;
    }
    /* Reserve top space on mobile so the fixed theme toggle doesn't sit
       on top of the logo when the safe-area is zero. */
    .brand-panel { padding: 56px 20px 28px; }
    .form-panel  { padding: 8px 16px 32px; }
    .form-inner  { padding: 32px 22px; border-radius: 16px; }
}

/* ── Brand panel content ── */
.brand-logo {
    max-height: 140px;
    width: auto;
    margin: 0 auto 32px;
    display: block;
}

.brand-ayah {
    display: block;
    width: 100%;
    max-width: 560px;
    height: auto;
    margin: 0 auto;
    color: var(--muted);   /* flows into the SVG text via fill="currentColor" */
}

/* Light-mode brand panel text sits on a sand gradient; keep legible */
html[data-theme="light"] .brand-ayah { color: #5e5a55; }

@media (max-width: 991.98px) {
    .brand-logo { max-height: 110px; margin-bottom: 24px; }
    .brand-ayah { max-width: 420px; }
}

/* Mobile header strip: compact logo + ayah stacked */
@media (max-width: 767.98px) {
    .brand-logo { max-height: 64px; margin: 0 auto 14px; }
    .brand-ayah { max-width: 100%; }
}

/* ── Theme toggle ──
   Fixed to the viewport so placement is consistent across breakpoints and
   it never competes with the form card. Sits in the top visual-LEFT corner
   (RTL: inset-inline-end). Respects safe-area insets on notch devices.
   44×44 touch target per Apple HIG / Material Design. */
.theme-toggle {
    position: fixed;
    inset-block-start: calc(16px + env(safe-area-inset-top, 0px));
    inset-inline-end:  calc(16px + env(safe-area-inset-right, 0px));
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--card-brd);
    background: rgba(255, 255, 255, 0.08);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    z-index: 10;
    transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
html[data-theme="light"] .theme-toggle {
    background: rgba(255, 255, 255, 0.55);
    border-color: rgba(0, 0, 0, 0.08);
}
.theme-toggle:hover {
    background: var(--card-bg);
    transform: translateY(-1px);
    border-color: var(--brand);
}
.theme-toggle:focus-visible {
    outline: none;
    box-shadow: var(--ring);
}

/* ── Error banner (flash) ── */
.login-error {
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 107, 107, 0.10);
    border: 1px solid rgba(255, 107, 107, 0.28);
    color: #c04040;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
html[data-theme="dark"] .login-error {
    color: #ff9a9a;
    background: rgba(255, 107, 107, 0.14);
    border-color: rgba(255, 107, 107, 0.32);
}

/* ── Form ── */
.login-form { display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 8px; }

.field-label {
    font-size: 16px;
    font-weight: 500;
    color: var(--text);
    margin: 0;
}

.field-input {
    height: 52px;
    padding: 0 16px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--card-brd);
    border-radius: 12px;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.field-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--ring);
}

.btn-primary {
    margin-top: 8px;               /* 20 gap + 8 = 28 from last field */
    height: 52px;
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    cursor: pointer;
    transition: transform .18s ease, filter .18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-primary:hover   { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary[disabled] { opacity: .75; cursor: progress; transform: none; }

.btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.btn-primary.is-loading .btn-spinner { display: inline-block; }

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

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .btn-primary, .btn-primary:hover,
    .theme-toggle, .theme-toggle:hover {
        transition: none;
        transform: none;
    }
    .btn-spinner { animation: none; }
}
