/* ============================================================
   Auth Layout — Split-screen widescreen design
   Adapted from Dolos AI (forensicintelligence_chat)
   Theme: html.dark class (Tailwind convention)
   ============================================================ */

.auth-page {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(24px, 4vw, 48px);
    padding-top: clamp(32px, 5vh, 80px);
    overflow: hidden;
}

.auth-background {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.auth-glow {
    position: absolute;
    width: 420px;
    height: 420px;
    filter: blur(90px);
    opacity: 0.75;
    animation: pulse 18s infinite ease-in-out;
}

.auth-glow--left {
    background: radial-gradient(circle, rgba(129, 140, 248, 0.35), transparent 65%);
    top: -80px;
    left: -120px;
}

.auth-glow--right {
    background: radial-gradient(circle, rgba(56, 189, 248, 0.3), transparent 60%);
    bottom: -100px;
    right: -120px;
    animation-delay: 6s;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(0.8);
        opacity: 0.65;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

@keyframes authBrandShimmer {
    0% {
        opacity: 0;
        transform: translate3d(-165%, 0, 0) rotate(18deg);
    }
    12% {
        opacity: 0.18;
    }
    42% {
        opacity: 0.68;
    }
    100% {
        opacity: 0;
        transform: translate3d(165%, 0, 0) rotate(18deg);
    }
}

/* ── Card (mobile: flex column) ── */

.auth-card {
    position: relative;
    width: min(460px, 92vw);
    padding: clamp(32px, 4vw, 48px);
    border-radius: 28px;
    display: flex;
    flex-direction: column;
    gap: clamp(22px, 3vw, 30px);
    z-index: 2;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.18), transparent 45%, rgba(56, 189, 248, 0.15));
    border-radius: inherit;
    opacity: 0.8;
    pointer-events: none;
}

.auth-card > * {
    position: relative;
    z-index: 2;
}

/* ── Header ── */

.auth-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-mark {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.75);
}

.auth-mark-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    filter: invert(1) drop-shadow(0 8px 20px rgba(56, 189, 248, 0.3));
}

.auth-mark-text {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
}

.auth-title {
    font-size: clamp(1.65rem, 1.8vw + 1rem, 2.1rem);
    font-weight: 600;
    margin: 0;
}

.auth-subtitle {
    margin: 0;
    font-size: 0.95rem;
}

/* ── Brand Panel (mobile: order 2, below form) ── */

.auth-brand-panel {
    order: 2;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-brand-stage {
    position: relative;
    overflow: hidden;
    display: none;
}

.auth-brand-logo {
    display: block;
    object-fit: contain;
}

.auth-brand-copy {
    display: none;
}

.auth-side-meta {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px;
    border-radius: 20px;
    background: linear-gradient(155deg, rgba(15, 23, 42, 0.62), rgba(30, 41, 59, 0.52));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 16px 34px rgba(5, 10, 24, 0.2);
}

/* ── Column Divider (hidden on mobile) ── */

.auth-column-divider {
    display: none;
}

/* ── Main Column (mobile: order 1, above brand) ── */

.auth-main-column {
    order: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: clamp(18px, 2vw, 24px);
}

/* ── Form ── */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ── Toggle (login ↔ register link) ── */

.auth-toggle {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.7);
}

.auth-toggle-link {
    background: transparent;
    border: none;
    color: rgba(129, 140, 248, 0.9);
    font-weight: 600;
    cursor: pointer;
    position: relative;
    text-decoration: none;
}

.auth-toggle-link::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 1px;
    background: linear-gradient(90deg, rgba(129, 140, 248, 0.6), transparent);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.auth-toggle-link:hover::after {
    opacity: 1;
}

/* ── Legal note ── */

.auth-legal-note {
    margin: 0;
    text-align: center;
    font-size: 0.78rem;
    color: rgba(148, 163, 184, 0.85);
    line-height: 1.5;
}

.auth-legal-note a {
    color: rgba(129, 140, 248, 0.9);
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s ease;
}

.auth-legal-note a:hover {
    color: rgba(129, 140, 248, 1);
}

/* ── Support link (forgot password) ── */

.auth-support {
    display: flex;
    justify-content: flex-end;
    margin-top: -6px;
}

.auth-support-link {
    font-size: 0.85rem;
    color: rgba(129, 140, 248, 0.9);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.auth-support-link:hover {
    color: rgba(129, 140, 248, 1);
}

/* ============================================================
   Desktop: 3-column grid (980px+)
   ============================================================ */

@media (min-width: 980px) {
    .auth-page {
        padding: clamp(18px, 2.4vw, 36px);
        padding-top: clamp(24px, 4vh, 60px);
        align-items: flex-start;
    }

    .auth-card {
        width: min(1060px, calc(100vw - 48px));
        max-width: none;
        min-height: min(720px, calc(100vh - 96px));
        padding: clamp(32px, 3vw, 44px);
        display: grid;
        grid-template-columns: minmax(220px, clamp(220px, 21vw, 258px)) 1px minmax(0, 540px);
        column-gap: clamp(18px, 2vw, 24px);
        row-gap: 0;
        align-items: center;
        justify-content: center;
    }

    .auth-column-divider {
        display: block;
        grid-column: 2;
        align-self: stretch;
        justify-self: center;
        width: 1px;
        border-radius: 999px;
        background: linear-gradient(
            180deg,
            rgba(255, 255, 255, 0),
            rgba(255, 255, 255, 0.14) 12%,
            rgba(129, 140, 248, 0.42) 50%,
            rgba(255, 255, 255, 0.14) 88%,
            rgba(255, 255, 255, 0)
        );
        pointer-events: none;
    }

    .auth-brand-panel {
        grid-column: 1;
        position: relative;
        order: initial;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        width: 100%;
        max-width: 258px;
        margin-top: 0;
        padding: 18px;
        border-top: none;
        border-radius: 22px;
        background:
            radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 44%),
            linear-gradient(160deg, rgba(15, 23, 42, 0.82), rgba(30, 41, 59, 0.74));
        border: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 26px 62px rgba(5, 10, 24, 0.34);
        overflow: hidden;
        isolation: isolate;
    }

    .auth-brand-panel::before {
        content: "";
        position: absolute;
        inset: auto auto -14% -14%;
        width: 220px;
        height: 220px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(129, 140, 248, 0.24), transparent 70%);
        z-index: -1;
        pointer-events: none;
    }

    .auth-brand-stage {
        display: flex;
        width: clamp(88px, 7vw, 112px);
        aspect-ratio: 1;
        align-items: center;
        justify-content: center;
        align-self: center;
        border-radius: 20px;
        background:
            radial-gradient(circle at 50% 38%, rgba(56, 189, 248, 0.18), transparent 38%),
            linear-gradient(145deg, rgba(15, 23, 42, 0.72), rgba(30, 41, 59, 0.52));
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    }

    .auth-brand-stage::before {
        content: "";
        position: absolute;
        width: clamp(96px, 8vw, 132px);
        aspect-ratio: 1;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(129, 140, 248, 0.34), rgba(129, 140, 248, 0) 68%);
        filter: blur(10px);
        opacity: 0.8;
    }

    .auth-brand-stage::after {
        content: "";
        position: absolute;
        inset: -24%;
        background: linear-gradient(
            105deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.08) 34%,
            rgba(255, 255, 255, 0.82) 50%,
            rgba(255, 255, 255, 0.1) 64%,
            rgba(255, 255, 255, 0) 100%
        );
        opacity: 0;
        transform: translate3d(-165%, 0, 0) rotate(18deg);
        will-change: transform, opacity;
        pointer-events: none;
        animation: authBrandShimmer 2.8s cubic-bezier(0.22, 1, 0.36, 1) 0.45s 1 both;
    }

    .auth-brand-logo {
        position: relative;
        width: clamp(68px, 5vw, 92px);
        filter: invert(1) drop-shadow(0 18px 38px rgba(56, 189, 248, 0.32));
    }

    .auth-brand-copy {
        display: flex;
        flex-direction: column;
        gap: 4px;
        align-items: center;
        text-align: center;
    }

    .auth-brand-kicker {
        font-size: 0.64rem;
        letter-spacing: 0.18em;
        text-transform: uppercase;
        color: rgba(148, 163, 184, 0.84);
    }

    .auth-brand-name {
        font-size: clamp(1.7rem, 1vw + 1rem, 2.15rem);
        font-weight: 650;
        line-height: 1;
        color: #e2e8f0;
    }

    .auth-main-column {
        grid-column: 3;
        order: initial;
        width: 100%;
        max-width: 540px;
        gap: 18px;
    }

    .auth-header {
        gap: 10px;
        padding-top: 0;
    }

    .auth-title {
        font-size: clamp(1.8rem, 0.9vw + 1.2rem, 2.35rem);
    }

    .auth-subtitle {
        max-width: 34ch;
    }

    .auth-side-meta {
        padding: 14px 16px;
        border-radius: 18px;
        background: linear-gradient(155deg, rgba(15, 23, 42, 0.76), rgba(30, 41, 59, 0.68));
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 20px 42px rgba(5, 10, 24, 0.24);
    }

    .auth-toggle {
        justify-content: center;
        flex-wrap: wrap;
    }

    .auth-side-meta .auth-legal-note {
        text-align: center;
    }

    /* ── 2-column form grid on desktop ── */

    .auth-form-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px 18px;
        align-items: start;
    }

    .auth-form-grid .auth-form-full {
        grid-column: 1 / -1;
    }

    .auth-form-grid .forensic-input {
        min-width: 0;
    }
}

/* ── Small mobile ── */

@media (max-width: 640px) {
    .auth-card {
        border-radius: 22px;
        padding: clamp(24px, 6vw, 32px);
        gap: 22px;
    }

    .auth-mark {
        font-size: 0.75rem;
    }

    .auth-title {
        font-size: clamp(1.45rem, 4vw, 1.85rem);
    }
}

/* ============================================================
   Light mode overrides (html without .dark class)
   ============================================================ */

html:not(.dark) .auth-card::before {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), transparent 45%, rgba(14, 165, 233, 0.08));
}

html:not(.dark) .auth-glow {
    opacity: 0.35;
}

html:not(.dark) .auth-brand-panel {
    border-top-color: rgba(15, 23, 42, 0.08);
}

html:not(.dark) .auth-mark {
    color: rgba(15, 23, 42, 0.7);
}

html:not(.dark) .auth-mark-logo {
    filter: drop-shadow(0 8px 20px rgba(56, 189, 248, 0.3));
}

html:not(.dark) .auth-toggle {
    color: rgba(51, 65, 85, 0.8);
}

html:not(.dark) .auth-toggle-link {
    color: rgba(79, 70, 229, 0.85);
}

html:not(.dark) .auth-toggle-link:hover {
    color: rgba(79, 70, 229, 1);
}

html:not(.dark) .auth-legal-note {
    color: rgba(71, 85, 105, 0.9);
}

html:not(.dark) .auth-legal-note a {
    color: rgba(79, 70, 229, 0.85);
}

html:not(.dark) .auth-support-link {
    color: rgba(79, 70, 229, 0.85);
}

html:not(.dark) .auth-support-link:hover {
    color: rgba(79, 70, 229, 1);
}

html:not(.dark) .auth-side-meta {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.94), rgba(241, 245, 249, 0.88));
    border-color: rgba(15, 23, 42, 0.08);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
}

html:not(.dark) .auth-brand-name {
    color: #1e293b;
}

html:not(.dark) .auth-brand-kicker {
    color: rgba(71, 85, 105, 0.82);
}

html:not(.dark) .auth-column-divider {
    background: linear-gradient(
        180deg,
        rgba(15, 23, 42, 0),
        rgba(148, 163, 184, 0.32) 12%,
        rgba(59, 130, 246, 0.36) 50%,
        rgba(148, 163, 184, 0.32) 88%,
        rgba(15, 23, 42, 0)
    );
}

@media (min-width: 980px) {
    html:not(.dark) .auth-brand-panel {
        background:
            radial-gradient(circle at top right, rgba(14, 165, 233, 0.15), transparent 44%),
            linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(226, 232, 240, 0.9));
        border-color: rgba(15, 23, 42, 0.08);
        box-shadow: 0 26px 54px rgba(15, 23, 42, 0.1);
    }

    html:not(.dark) .auth-brand-stage {
        background:
            radial-gradient(circle at 50% 38%, rgba(59, 130, 246, 0.15), transparent 38%),
            linear-gradient(145deg, rgba(248, 250, 252, 0.95), rgba(226, 232, 240, 0.84));
        border-color: rgba(15, 23, 42, 0.08);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
    }

    html:not(.dark) .auth-brand-stage::after {
        background: linear-gradient(
            105deg,
            rgba(255, 255, 255, 0) 0%,
            rgba(255, 255, 255, 0.06) 34%,
            rgba(255, 255, 255, 0.72) 50%,
            rgba(191, 219, 254, 0.22) 62%,
            rgba(255, 255, 255, 0) 100%
        );
    }

    html:not(.dark) .auth-brand-logo {
        filter: drop-shadow(0 18px 34px rgba(56, 189, 248, 0.22));
    }

    html:not(.dark) .auth-side-meta {
        padding: 14px 16px;
        border-radius: 18px;
        background: linear-gradient(155deg, rgba(255, 255, 255, 0.94), rgba(241, 245, 249, 0.88));
        border-color: rgba(15, 23, 42, 0.08);
        box-shadow: 0 18px 36px rgba(15, 23, 42, 0.08);
    }
}

/* ============================================================
   Accessibility & touch
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .auth-glow,
    .auth-brand-stage::after {
        animation: none !important;
    }

    .auth-brand-stage::after {
        opacity: 0 !important;
        transform: none !important;
    }
}

@media (hover: none) and (pointer: coarse) {
    .auth-toggle-link:hover::after {
        opacity: 0;
    }
}
