/* ============================================================
   auth.css — Sprafo dual-panel animated auth design
   Scope: .sap-body (set on <body> by auth_head.php)
   Panel layout:
     - LOGIN panel:    LEFT half  (default visible)
     - REGISTER panel: LEFT half  (hidden behind login; slides RIGHT when active)
     - OVERLAY:        RIGHT half (slides LEFT when active)
   Follows: prefers-reduced-motion, RTL (.sap-rtl), responsive
   ============================================================ */

/* ── Auth body / page reset ──────────────────────────────── */
.sap-body {
    margin: 0;
    padding: 0;
}

/* ── Auth-shell top bar ──────────────────────────────────── */
.ash-topbar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--dl-surface, #fff);
    border-bottom: 1px solid var(--dl-border, #e5e7eb);
    height: 52px;
}

[data-bs-theme="dark"] .ash-topbar,
[data-theme="dark"]    .ash-topbar {
    background: #0f172a;
    border-bottom-color: #1e293b;
}

.ash-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1.25rem;
}

.ash-brand {
    display: flex;
    align-items: center;
    gap: .45rem;
    text-decoration: none;
    color: var(--dl-primary, #0056b3);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.01em;
}

.ash-brand:hover { opacity: .85; }

.ash-brand-icon { font-size: 1.2rem; }

.ash-brand-name {
    color: #1a202c;
}

[data-bs-theme="dark"] .ash-brand-name,
[data-theme="dark"]    .ash-brand-name {
    color: #f1f5f9;
}

.ash-brand-logo {
    height: 28px;
    width: auto;
}

.ash-controls {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.ash-ctrl-btn {
    color: #374151;
    border-color: #d1d5db;
    background: transparent;
    font-size: .8rem;
    padding: .3rem .6rem;
}

.ash-ctrl-btn:hover,
.ash-ctrl-btn:focus-visible {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
}

[data-bs-theme="dark"] .ash-ctrl-btn,
[data-theme="dark"]    .ash-ctrl-btn {
    color: #94a3b8;
    border-color: #334155;
}

[data-bs-theme="dark"] .ash-ctrl-btn:hover,
[data-theme="dark"]    .ash-ctrl-btn:hover {
    background: #1e293b;
    border-color: #475569;
    color: #f1f5f9;
}

/* ── Page background wrapper ──────────────────────────────── */
.sap-page {
    min-height: calc(100vh - 52px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--dl-primary, #0056b3) 8%, #f0f4ff) 0%,
        #f8faff 50%,
        color-mix(in srgb, var(--dl-primary, #0056b3) 5%, #eef2fb) 100%
    );
}

/* ── Main dual-panel container ────────────────────────────── */
.sap-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 860px;
    min-height: 540px;   /* login-only height */
    background: #fff;
    border-radius: 30px;
    box-shadow:
        0 24px 64px rgba(0, 0, 0, .15),
        0 4px 20px rgba(0, 0, 0, .07);
}

/* Taller container when register panel is active (fits all register fields + padding) */
.sap-container.sap-active {
    min-height: 920px;
}

/* ── Form panels — shared ─────────────────────────────────── */
.sap-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2.5rem 2.5rem 2rem;
    transition: opacity 0.6s ease-in-out, transform 0.6s ease-in-out;
}

/* ── LOGIN panel: LEFT side, always (default visible) ─────── */
.sap-panel--login {
    left: 0;
    z-index: 2;
    opacity: 1;
    transform: translateX(0);
}

/* ── REGISTER panel: LEFT side (hidden behind login) ─────── */
/* Slides to RIGHT half when active via transform: translateX(100%) */
.sap-panel--register {
    left: 0;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transform: translateX(0);
}

/* ── ACTIVE state: register panel shown ──────────────────── */
.sap-container.sap-active .sap-panel--login {
    opacity: 0;
    pointer-events: none;
    transform: translateX(0); /* stays on left, just fades */
}

.sap-container.sap-active .sap-panel--register {
    transform: translateX(100%);  /* moves to right half */
    opacity: 1;
    z-index: 5;
    pointer-events: auto;
}

/* ── Overlay container ────────────────────────────────────── */
/* Sits on the RIGHT half of the card, z-index 100 */
/* On .sap-active it slides to cover the LEFT half */
.sap-overlay-wrap {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    overflow: hidden;
    z-index: 100;
    border-radius: 150px 0 0 100px;
    transition: transform 0.6s ease-in-out, border-radius 0.6s ease-in-out;
}

.sap-container.sap-active .sap-overlay-wrap {
    transform: translateX(-100%);
    border-radius: 0 150px 100px 0;
}

/* ── Overlay colour layer ─────────────────────────────────── */
/* width: 200% so the background spans the full card width.
   left: -100% (relative to wrap) places the left edge at card x=0.
   When translateX(50%) the right panel content centres over the right half. */
.sap-overlay {
    position: relative;
    display: flex;
    align-items: stretch;
    height: 100%;
    width: 200%;
    left: -100%;
    background: linear-gradient(
        135deg,
        var(--dl-primary, #0056b3) 0%,
        var(--dl-primary-dk, #003d8a) 100%
    );
    transition: transform 0.6s ease-in-out;
}

.sap-container.sap-active .sap-overlay {
    transform: translateX(50%);
}

/* ── Overlay panels (coloured invitation panels) ────────── */
.sap-overlay-panel {
    position: absolute;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
    text-align: center;
    padding: 3rem 2.25rem;
    height: 100%;
    width: 50%;
    color: #fff;
    transition: transform 0.6s ease-in-out;
}

/* Left overlay panel — visible when .sap-active (shows "Welcome Back") */
.sap-overlay-panel--left {
    left: 0;
    transform: translateX(-200%);
}

/* Right overlay panel — visible by default (shows "Hello, Friend!") */
.sap-overlay-panel--right {
    right: 0;
    transform: translateX(0);
}

.sap-container.sap-active .sap-overlay-panel--left {
    transform: translateX(0);
}

.sap-container.sap-active .sap-overlay-panel--right {
    transform: translateX(200%);
}

/* ── Overlay typography ───────────────────────────────────── */
.sap-overlay-panel h2 {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
    line-height: 1.2;
}

.sap-overlay-panel p {
    font-size: .92rem;
    opacity: .9;
    margin: 0;
    line-height: 1.6;
    max-width: 230px;
}

/* ── Ghost button (overlay CTA) ───────────────────────────── */
.sap-ghost-btn {
    display: inline-block;
    padding: .6rem 2rem;
    border: 2px solid #fff;
    border-radius: 24px;
    background: transparent;
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
    letter-spacing: .04em;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.sap-ghost-btn:hover,
.sap-ghost-btn:focus-visible {
    background: rgba(255,255,255,.2);
    color: #fff;
    outline: 2px solid rgba(255,255,255,.6);
    outline-offset: 2px;
}

/* ── Panel inner content ──────────────────────────────────── */
.sap-panel-inner {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ── Panel header (icon + title + subtitle) ───────────────── */
.sap-panel-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.sap-icon-ring {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(
        135deg,
        color-mix(in srgb, var(--dl-primary, #0056b3) 15%, #fff) 0%,
        color-mix(in srgb, var(--dl-primary, #0056b3) 8%, #fff) 100%
    );
    border: 2px solid color-mix(in srgb, var(--dl-primary, #0056b3) 20%, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--dl-primary, #0056b3);
    margin: 0 auto 0.8rem;
}

.sap-panel-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0 0 .3rem;
    line-height: 1.2;
}

.sap-panel-subtitle {
    font-size: .84rem;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* ── Alerts inside panels ─────────────────────────────────── */
.sap-alert {
    width: 100%;
    max-width: 340px;
    margin: 0 auto 1rem;
    border-radius: .5rem;
    font-size: .875rem;
}

/* ── Form elements ────────────────────────────────────────── */
.sap-form {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
}

.sap-form .auth-label {
    font-size: .8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .3rem;
    display: block;
}

.sap-form .auth-input {
    height: 2.75rem;
    font-size: .9rem;
    border-radius: .45rem !important;
    padding-left: .85rem;
    border-color: #d1d5db;
    background: #fff;
    color: #111827;
    transition: border-color .15s, box-shadow .15s;
}

.sap-form .auth-input:focus {
    border-color: var(--dl-primary, #0056b3);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dl-primary, #0056b3) 15%, transparent);
    background: #fff;
}

.sap-form .auth-input::placeholder {
    color: #b0b8c4;
    opacity: 1;
}

.sap-form .auth-input-group {
    position: relative;
}

.sap-form .auth-input-group .auth-input {
    padding-right: 2.85rem;
}

.sap-form .auth-pw-toggle {
    position: absolute;
    top: 50%;
    right: .55rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: .2rem .3rem;
    color: #9ca3af;
    cursor: pointer;
    line-height: 1;
    transition: color .15s;
}

.sap-form .auth-pw-toggle:hover { color: var(--dl-primary, #0056b3); }
.sap-form .auth-pw-toggle:focus-visible {
    outline: 2px solid var(--dl-primary, #0056b3);
    outline-offset: 2px;
    border-radius: .25rem;
}

.sap-form .auth-hint {
    font-size: .74rem;
    color: #9ca3af;
    margin-top: .25rem;
    line-height: 1.4;
}

.sap-submit-btn {
    height: 2.85rem;
    font-size: .95rem;
    border-radius: .5rem;
    letter-spacing: .01em;
    box-shadow: 0 2px 12px color-mix(in srgb, var(--dl-primary, #0056b3) 28%, transparent);
    transition: box-shadow .18s, transform .1s;
    width: 100%;
    font-weight: 600;
}

.sap-submit-btn:hover {
    box-shadow: 0 5px 22px color-mix(in srgb, var(--dl-primary, #0056b3) 38%, transparent);
    transform: translateY(-1px);
}

.sap-submit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--dl-primary, #0056b3) 20%, transparent);
}

/* ── Forgot password / footer link ───────────────────────── */
.sap-forgot-link {
    font-size: .79rem;
    color: #6b7280;
    text-decoration: none;
}

.sap-forgot-link:hover {
    color: var(--dl-primary, #0056b3);
    text-decoration: underline;
}

/* ── OR divider ───────────────────────────────────────────── */
.sap-divider {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin: .8rem 0;
}

.sap-divider hr {
    flex: 1;
    border-color: #e5e7eb;
    margin: 0;
}

.sap-divider small {
    font-size: .74rem;
    color: #9ca3af;
    white-space: nowrap;
}

/* ── Social login buttons ─────────────────────────────────── */
.sap-social-btn {
    height: 2.65rem;
    font-size: .85rem;
    border-radius: .45rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    font-weight: 500;
    transition: background .15s, box-shadow .15s;
}

.sap-social-btn:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
}

/* ── Trust badges ─────────────────────────────────────────── */
.sap-trust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: .8rem;
    border-top: 1px solid #f0f0f0;
    margin-top: .8rem;
}

.sap-trust-item {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .72rem;
    color: #9ca3af;
}

.sap-trust-item i {
    color: var(--dl-primary, #0056b3);
    font-size: .82rem;
}

/* ── Terms checkbox wrapper ───────────────────────────────── */
.sap-terms-wrap {
    font-size: .8rem;
}

.sap-terms-wrap .form-check-label {
    font-size: .8rem;
    color: #374151;
    line-height: 1.55;
}

.sap-terms-wrap a {
    color: var(--dl-primary, #0056b3);
}

.sap-terms-wrap .sf-terms-error-msg {
    font-size: .78rem;
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: .3rem;
    margin-top: .25rem;
}

/* ── Mobile switch link (desktop: hidden) ─────────────────── */
.sap-mobile-switch {
    display: none;
}

/* ── No-transition helper (suppress flash on initial load) ── */
.sap-no-transition,
.sap-no-transition * {
    transition: none !important;
    animation: none !important;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .sap-panel,
    .sap-overlay-wrap,
    .sap-overlay,
    .sap-overlay-panel,
    .sap-ghost-btn,
    .sap-submit-btn {
        transition: none !important;
        animation: none !important;
    }
}

/* ══════════════════════════════════════════════════════════
   TABLET 640–959 px
   ══════════════════════════════════════════════════════════ */
@media (min-width: 640px) and (max-width: 959px) {
    .sap-container {
        max-width: 640px;
        min-height: 520px;
        border-radius: 24px;
    }

    .sap-container.sap-active {
        min-height: 860px;
    }

    .sap-panel {
        padding: 2rem 1.75rem;
    }

    .sap-panel-inner,
    .sap-form,
    .sap-alert {
        max-width: 290px;
    }

    .sap-overlay-panel h2 { font-size: 1.35rem; }
    .sap-overlay-panel p  { font-size: .83rem; max-width: 190px; }
}

/* ══════════════════════════════════════════════════════════
   MOBILE ≤ 639 px — stacked layout, single panel at a time
   ══════════════════════════════════════════════════════════ */
@media (max-width: 639px) {
    .sap-page {
        padding: 1rem .75rem;
        align-items: flex-start;
        min-height: calc(100vh - 52px);
    }

    .sap-container {
        min-height: unset;
        border-radius: 20px;
        box-shadow: 0 8px 32px rgba(0,0,0,.12);
    }

    .sap-container.sap-active {
        min-height: unset;
    }

    /* Stack panels: release absolute positioning */
    .sap-panel {
        position: static;
        width: 100%;
        min-height: unset;
        padding: 1.75rem 1.5rem 1.5rem;
        opacity: 1;
        transform: none !important;
        pointer-events: auto;
        transition: none;
    }

    /* Show only the active panel */
    .sap-panel--login    { display: flex; }
    .sap-panel--register { display: none; }

    .sap-container.sap-active .sap-panel--login    { display: none; }
    .sap-container.sap-active .sap-panel--register {
        display: flex;
        opacity: 1;
        transform: none !important;
        pointer-events: auto;
    }

    /* Hide overlay on mobile */
    .sap-overlay-wrap { display: none; }

    /* Mobile switch link */
    .sap-mobile-switch {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: .35rem;
        margin-top: 1rem;
        font-size: .84rem;
        color: #6b7280;
    }

    .sap-mobile-switch a {
        color: var(--dl-primary, #0056b3);
        font-weight: 600;
        text-decoration: underline;
    }

    .sap-mobile-switch a:hover { text-decoration: none; }

    .sap-panel-inner,
    .sap-form,
    .sap-alert {
        max-width: 100%;
    }
}

/* ══════════════════════════════════════════════════════════
   RTL — mirror ALL slide directions
   ══════════════════════════════════════════════════════════ */

/* RTL default: login on RIGHT, register behind it on RIGHT */
.sap-container.sap-rtl .sap-panel--login {
    left: auto;
    right: 0;
}

.sap-container.sap-rtl .sap-panel--register {
    left: auto;
    right: 0;
}

/* Overlay on LEFT half in RTL */
.sap-container.sap-rtl .sap-overlay-wrap {
    left: auto;
    right: 50%;
    border-radius: 0 150px 100px 0;
}

/* RTL active: register slides to LEFT (translateX(-100%)), overlay slides RIGHT */
.sap-container.sap-rtl.sap-active .sap-overlay-wrap {
    transform: translateX(100%);
    border-radius: 150px 0 0 100px;
}

.sap-container.sap-rtl.sap-active .sap-panel--login {
    opacity: 0;
    pointer-events: none;
    transform: translateX(0);
}

.sap-container.sap-rtl.sap-active .sap-panel--register {
    transform: translateX(-100%);
    opacity: 1;
    z-index: 5;
    pointer-events: auto;
}

/* RTL overlay colour layer */
.sap-container.sap-rtl .sap-overlay {
    left: 0;
    right: -100%;
    direction: rtl;
}

.sap-container.sap-rtl.sap-active .sap-overlay {
    transform: translateX(-50%);
}

/* RTL overlay panels */
.sap-container.sap-rtl .sap-overlay-panel--left {
    left: auto;
    right: 0;
    transform: translateX(200%);
}

.sap-container.sap-rtl .sap-overlay-panel--right {
    right: auto;
    left: 0;
    transform: translateX(0);
}

.sap-container.sap-rtl.sap-active .sap-overlay-panel--left {
    transform: translateX(0);
}

.sap-container.sap-rtl.sap-active .sap-overlay-panel--right {
    transform: translateX(-200%);
}

/* ══════════════════════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════════════════════ */
[data-bs-theme="dark"] .sap-page,
[data-theme="dark"]    .sap-page {
    background: linear-gradient(135deg, #0d1117 0%, #161b27 50%, #0f1822 100%);
}

[data-bs-theme="dark"] .sap-container,
[data-theme="dark"]    .sap-container {
    background: #1a1f2e;
    box-shadow: 0 24px 64px rgba(0,0,0,.4), 0 4px 20px rgba(0,0,0,.2);
}

[data-bs-theme="dark"] .sap-panel-title,
[data-theme="dark"]    .sap-panel-title { color: #f1f5f9; }

[data-bs-theme="dark"] .sap-panel-subtitle,
[data-theme="dark"]    .sap-panel-subtitle { color: #94a3b8; }

[data-bs-theme="dark"] .sap-form .auth-label,
[data-theme="dark"]    .sap-form .auth-label { color: #cbd5e1; }

[data-bs-theme="dark"] .sap-form .auth-input,
[data-theme="dark"]    .sap-form .auth-input {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .sap-form .auth-input:focus,
[data-theme="dark"]    .sap-form .auth-input:focus {
    background: #0f172a;
}

[data-bs-theme="dark"] .sap-form .auth-input::placeholder,
[data-theme="dark"]    .sap-form .auth-input::placeholder { color: #475569; }

[data-bs-theme="dark"] .sap-trust,
[data-theme="dark"]    .sap-trust { border-top-color: #1e293b; }

[data-bs-theme="dark"] .sap-trust-item,
[data-theme="dark"]    .sap-trust-item { color: #64748b; }

[data-bs-theme="dark"] .sap-forgot-link,
[data-theme="dark"]    .sap-forgot-link { color: #64748b; }

[data-bs-theme="dark"] .sap-divider hr,
[data-theme="dark"]    .sap-divider hr { border-color: #1e293b; }

[data-bs-theme="dark"] .sap-divider small,
[data-theme="dark"]    .sap-divider small { color: #475569; }

[data-bs-theme="dark"] .sap-terms-wrap .form-check-label,
[data-theme="dark"]    .sap-terms-wrap .form-check-label { color: #cbd5e1; }

[data-bs-theme="dark"] .sap-mobile-switch,
[data-theme="dark"]    .sap-mobile-switch { color: #64748b; }

[data-bs-theme="dark"] .sap-form .auth-hint,
[data-theme="dark"]    .sap-form .auth-hint { color: #64748b; }

[data-bs-theme="dark"] .sap-panel-subtitle,
[data-theme="dark"]    .sap-panel-subtitle { color: #94a3b8; }
