/* BI Vis — login screen and post-login transition */

:root {
    --auth-bg: #060a14;
    --auth-panel: rgba(16, 26, 46, 0.86);
    --auth-panel-strong: rgba(10, 18, 34, 0.94);
    --auth-border: rgba(126, 178, 255, 0.16);
    --auth-text: #e8f0ff;
    --auth-muted: #8fa3c4;
    --auth-accent: #38bdf8;
    --auth-accent-2: #2dd4bf;
    --auth-danger: #fb7185;
    --auth-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

html {
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

body.auth-page {
    margin: 0;
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
    background: var(--auth-bg);
    color: var(--auth-text);
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}


/* ---------- Theme toggle ---------- */

.auth-theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 50;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--auth-border);
    border-radius: 50%;
    background: rgba(16, 26, 46, 0.72);
    color: var(--auth-muted);
    font-size: 1rem;
    cursor: pointer;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.auth-theme-toggle:hover {
    color: var(--auth-text);
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.14);
}

.auth-theme-toggle:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.22);
}

/* ---------- Background ---------- */

.auth-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.auth-orb {
    position: absolute;
    width: 42rem;
    height: 42rem;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.55;
    animation: authOrbFloat 18s ease-in-out infinite;
}

.auth-orb--one {
    top: -18rem;
    left: -12rem;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.55), transparent 65%);
}

.auth-orb--two {
    right: -16rem;
    bottom: -20rem;
    background: radial-gradient(circle, rgba(45, 212, 191, 0.42), transparent 65%);
    animation-delay: -6s;
}

.auth-orb--three {
    top: 30%;
    left: 55%;
    width: 28rem;
    height: 28rem;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.35), transparent 68%);
    animation-delay: -11s;
}

.auth-grid {
    position: absolute;
    inset: -20%;
    background-image:
        linear-gradient(rgba(126, 178, 255, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(126, 178, 255, 0.055) 1px, transparent 1px);
    background-size: 56px 56px;
    transform: perspective(700px) rotateX(58deg) translateY(18%);
    mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 72%);
    -webkit-mask-image: radial-gradient(circle at 50% 40%, #000 20%, transparent 72%);
}

/* ---------- Card ---------- */

.auth-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 430px;
}

.auth-card {
    position: relative;
    overflow: hidden;
    padding: 2.4rem 2.2rem 1.9rem;
    border: 1px solid var(--auth-border);
    border-radius: 28px;
    background:
        linear-gradient(155deg, rgba(30, 48, 82, 0.72), transparent 42%),
        linear-gradient(180deg, var(--auth-panel), var(--auth-panel-strong));
    box-shadow: var(--auth-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
    animation: authCardIn 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.auth-card::before {
    content: "";
    position: absolute;
    top: -60%;
    right: -35%;
    width: 22rem;
    height: 22rem;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.18), transparent 65%);
    pointer-events: none;
}

.auth-card.is-busy {
    cursor: progress;
}

.auth-card.is-shaking {
    animation: authShake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.auth-card.is-leaving {
    transform: scale(0.96) translateY(-10px);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.28s ease;
}

/* ---------- Brand ---------- */

.auth-brand {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-bottom: 1.8rem;
}

.auth-logo {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    color: #04121c;
    background: linear-gradient(135deg, var(--auth-accent), var(--auth-accent-2));
    box-shadow: 0 12px 28px rgba(45, 212, 191, 0.28);
}

.auth-logo i {
    font-size: 1.55rem;
}

.auth-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.auth-brand-tag {
    font-size: 0.76rem;
    color: var(--auth-muted);
}

.auth-title {
    margin: 0 0 0.4rem;
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    margin: 0 0 1.4rem;
    color: var(--auth-muted);
    font-size: 0.92rem;
}

/* ---------- Error ---------- */

.auth-error {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    max-height: 0;
    margin: 0;
    padding: 0 0.9rem;
    overflow: hidden;
    color: #ffd9df;
    font-size: 0.86rem;
    background: rgba(251, 113, 133, 0.12);
    border: 1px solid rgba(251, 113, 133, 0.32);
    border-radius: 12px;
    opacity: 0;
    transition: max-height 0.25s ease, margin 0.25s ease, padding 0.25s ease, opacity 0.25s ease;
}

.auth-error.is-visible {
    max-height: 5rem;
    margin-bottom: 1rem;
    padding: 0.7rem 0.9rem;
    opacity: 1;
}

.auth-error i {
    margin-top: 0.1rem;
    color: var(--auth-danger);
}

/* ---------- Form ---------- */

.auth-field {
    margin-bottom: 1.05rem;
}

.auth-label {
    display: block;
    margin-bottom: 0.45rem;
    color: #b9c9e4;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.auth-input {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid rgba(126, 178, 255, 0.18);
    border-radius: 14px;
    background: rgba(6, 12, 24, 0.55);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.auth-input:focus-within {
    border-color: rgba(56, 189, 248, 0.7);
    background: rgba(9, 18, 34, 0.75);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
}

.auth-input > i {
    flex: 0 0 auto;
    width: 2.9rem;
    color: #6f86a8;
    font-size: 1rem;
    text-align: center;
}

.auth-input input {
    width: 100%;
    min-width: 0;
    padding: 0.88rem 0.9rem 0.88rem 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--auth-text);
    font-size: 0.95rem;
}

.auth-input input::placeholder {
    color: #5d718f;
}

.auth-input input:-webkit-autofill,
.auth-input input:-webkit-autofill:hover,
.auth-input input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-text);
    -webkit-box-shadow: 0 0 0 1000px #0a1222 inset;
    transition: background-color 5000s ease-in-out 0s;
}

.auth-reveal {
    flex: 0 0 auto;
    width: 2.8rem;
    height: 2.8rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #7890b2;
    cursor: pointer;
    transition: color 0.2s ease, background 0.2s ease;
}

.auth-reveal:hover {
    color: var(--auth-text);
    background: rgba(126, 178, 255, 0.08);
}

/* ---------- Submit ---------- */

.auth-submit {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    height: 52px;
    margin-top: 1.35rem;
    border: 0;
    border-radius: 14px;
    color: #031019;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: linear-gradient(120deg, var(--auth-accent), var(--auth-accent-2));
    box-shadow: 0 14px 32px rgba(45, 212, 191, 0.22);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.auth-submit:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px rgba(45, 212, 191, 0.3);
    filter: brightness(1.04);
}

.auth-submit:active:not(:disabled) {
    transform: translateY(0);
}

.auth-submit:disabled {
    cursor: progress;
    filter: saturate(0.7);
}

.auth-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(3, 16, 25, 0.25);
    border-top-color: #031019;
    border-radius: 50%;
    animation: authSpin 0.7s linear infinite;
}

.auth-submit.is-loading .auth-submit-label {
    opacity: 0.6;
}

.auth-submit.is-loading .auth-spinner {
    display: block;
}

.auth-footnote {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1.45rem;
    color: #6c809f;
    font-size: 0.76rem;
}

/* ---------- Success transition ---------- */

.auth-transition {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 42%, rgba(20, 56, 94, 0.96), rgba(4, 8, 16, 0.99) 62%),
        var(--auth-bg);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.auth-transition.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.auth-transition__glow {
    position: absolute;
    width: 46rem;
    height: 46rem;
    border-radius: 50%;
    background: conic-gradient(from 120deg, rgba(56, 189, 248, 0.3), rgba(45, 212, 191, 0.24), rgba(99, 102, 241, 0.3), rgba(56, 189, 248, 0.3));
    filter: blur(80px);
    opacity: 0;
}

.auth-transition.is-active .auth-transition__glow {
    animation: authGlowPulse 1.6s ease-out both;
}

.auth-transition__content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
}

.auth-transition__mark {
    position: relative;
    display: grid;
    place-items: center;
    width: 104px;
    height: 104px;
    margin-bottom: 1.6rem;
    border-radius: 30px;
    color: #04121c;
    background: linear-gradient(135deg, var(--auth-accent), var(--auth-accent-2));
    box-shadow: 0 24px 70px rgba(45, 212, 191, 0.35);
    opacity: 0;
}

.auth-transition__mark > i {
    font-size: 2.9rem;
}

.auth-transition.is-active .auth-transition__mark {
    animation: authMarkPop 0.75s cubic-bezier(0.2, 0.9, 0.2, 1.15) 0.08s both;
}

.auth-transition__ring {
    position: absolute;
    inset: -14px;
    border: 1px solid rgba(56, 189, 248, 0.5);
    border-radius: 40px;
    opacity: 0;
}

.auth-transition.is-active .auth-transition__ring {
    animation: authRingPulse 1.2s ease-out 0.3s both;
}

.auth-transition.is-active .auth-transition__ring--late {
    animation-delay: 0.55s;
}

.auth-transition__title {
    margin-bottom: 0.4rem;
    font-size: 2.35rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    opacity: 0;
}

.auth-transition.is-active .auth-transition__title {
    animation: authRise 0.55s ease-out 0.38s both;
}

.auth-transition__text {
    color: #a9c0df;
    font-size: 0.98rem;
    opacity: 0;
}

.auth-transition.is-active .auth-transition__text {
    animation: authRise 0.55s ease-out 0.5s both;
}

.auth-transition__bar {
    width: 190px;
    height: 3px;
    margin-top: 1.7rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(126, 178, 255, 0.14);
}

.auth-transition__bar span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--auth-accent), var(--auth-accent-2));
    transform: scaleX(0);
    transform-origin: left;
}

.auth-transition.is-active .auth-transition__bar span {
    animation: authBarFill 1.15s cubic-bezier(0.65, 0, 0.35, 1) 0.25s both;
}

.auth-particles {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: grid;
    place-items: center;
}

.auth-particles span {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--auth-accent), var(--auth-accent-2));
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.75);
    opacity: 0;
}

.auth-transition.is-active .auth-particles span {
    animation: authParticleFly 1.35s cubic-bezier(0.2, 0.7, 0.3, 1) var(--d) both;
}

/* ---------- Motion ---------- */

@keyframes authOrbFloat {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(2rem, -1.5rem, 0) scale(1.06); }
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(22px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes authShake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

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

@keyframes authMarkPop {
    0% { opacity: 0; transform: scale(0.5) rotate(-8deg); }
    60% { opacity: 1; transform: scale(1.06) rotate(2deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
}

@keyframes authRingPulse {
    0% { opacity: 0.75; transform: scale(0.75); }
    100% { opacity: 0; transform: scale(1.55); }
}

@keyframes authRise {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes authBarFill {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes authGlowPulse {
    0% { opacity: 0; transform: scale(0.8); }
    45% { opacity: 0.9; }
    100% { opacity: 0.35; transform: scale(1.08); }
}

@keyframes authParticleFly {
    0% { opacity: 0; transform: translate(0, 0) scale(0.4); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--x), var(--y)) scale(0.8); }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 2rem 1.4rem 1.6rem;
        border-radius: 22px;
    }

    .auth-title {
        font-size: 1.6rem;
    }

    .auth-transition__mark {
        width: 86px;
        height: 86px;
        border-radius: 24px;
    }

    .auth-transition__title {
        font-size: 2rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-orb,
    .auth-card,
    .auth-transition,
    .auth-transition__glow,
    .auth-transition__mark,
    .auth-transition__ring,
    .auth-transition__title,
    .auth-transition__text,
    .auth-transition__bar span,
    .auth-particles span,
    .auth-card.is-shaking {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }

    .auth-transition__mark,
    .auth-transition__title,
    .auth-transition__text {
        opacity: 1;
    }

    .auth-transition__bar span {
        transform: scaleX(1);
    }
}

/* --------------------------------------------------------------------------
   Light theme
   -------------------------------------------------------------------------- */

html[data-theme="light"] {
    color-scheme: light;

    --auth-bg: #eef4fd;
    --auth-panel: rgba(255, 255, 255, 0.88);
    --auth-panel-strong: rgba(247, 250, 255, 0.96);
    --auth-border: rgba(37, 99, 235, 0.18);
    --auth-text: #0f213d;
    --auth-muted: #55688a;
    --auth-accent: #0ea5e9;
    --auth-accent-2: #14b8a6;
    --auth-danger: #e11d48;
    --auth-shadow: 0 30px 80px rgba(31, 64, 120, 0.2);
}

html[data-theme="light"] body.auth-page {
    background:
        radial-gradient(circle at 15% 0%, rgba(14, 165, 233, 0.16), transparent 40%),
        radial-gradient(circle at 90% 100%, rgba(20, 184, 166, 0.14), transparent 42%),
        linear-gradient(180deg, #f9fbff 0%, #eef4fd 52%, #e6eefb 100%);
}

html[data-theme="light"] .auth-orb {
    opacity: 0.4;
}

html[data-theme="light"] .auth-orb--one {
    background: radial-gradient(circle, rgba(56, 189, 248, 0.38), transparent 65%);
}

html[data-theme="light"] .auth-orb--two {
    background: radial-gradient(circle, rgba(45, 212, 191, 0.3), transparent 65%);
}

html[data-theme="light"] .auth-orb--three {
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2), transparent 68%);
}

html[data-theme="light"] .auth-grid {
    background-image:
        linear-gradient(rgba(37, 99, 235, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, 0.07) 1px, transparent 1px);
}

html[data-theme="light"] .auth-card {
    background:
        linear-gradient(155deg, rgba(255, 255, 255, 0.96), transparent 42%),
        linear-gradient(180deg, var(--auth-panel), var(--auth-panel-strong));
    box-shadow: var(--auth-shadow), inset 0 1px 0 #ffffff;
}

html[data-theme="light"] .auth-card::before {
    background: radial-gradient(circle, rgba(14, 165, 233, 0.14), transparent 65%);
}

html[data-theme="light"] .auth-label {
    color: #334966;
}

html[data-theme="light"] .auth-input {
    border-color: rgba(37, 99, 235, 0.18);
    background: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .auth-input:focus-within {
    border-color: rgba(14, 165, 233, 0.65);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.13);
}

html[data-theme="light"] .auth-input > i {
    color: #7b8caa;
}

html[data-theme="light"] .auth-input input {
    color: var(--auth-text);
}

html[data-theme="light"] .auth-input input::placeholder {
    color: #8a99b1;
}

html[data-theme="light"] .auth-input input:-webkit-autofill,
html[data-theme="light"] .auth-input input:-webkit-autofill:hover,
html[data-theme="light"] .auth-input input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--auth-text);
    -webkit-box-shadow: 0 0 0 1000px #ffffff inset;
}

html[data-theme="light"] .auth-reveal {
    color: #7b8caa;
}

html[data-theme="light"] .auth-reveal:hover {
    color: var(--auth-text);
    background: rgba(14, 165, 233, 0.08);
}

html[data-theme="light"] .auth-error {
    color: #9f1239;
    background: rgba(225, 29, 72, 0.08);
    border-color: rgba(225, 29, 72, 0.28);
}

html[data-theme="light"] .auth-error i {
    color: var(--auth-danger);
}

html[data-theme="light"] .auth-submit {
    box-shadow: 0 14px 32px rgba(20, 184, 166, 0.22);
}

html[data-theme="light"] .auth-submit:hover:not(:disabled) {
    box-shadow: 0 18px 40px rgba(20, 184, 166, 0.3);
}

html[data-theme="light"] .auth-footnote {
    color: #6a7d9b;
}

html[data-theme="light"] .auth-theme-toggle {
    background: rgba(255, 255, 255, 0.72);
    color: var(--auth-muted);
}

html[data-theme="light"] .auth-theme-toggle:hover {
    color: #075985;
    border-color: rgba(14, 165, 233, 0.45);
    background: #ffffff;
}

html[data-theme="light"] .auth-theme-toggle:focus-visible {
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}

html[data-theme="light"] .auth-transition {
    background:
        radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.98), rgba(231, 240, 252, 0.99) 62%),
        var(--auth-bg);
}

html[data-theme="light"] .auth-transition__glow {
    background: conic-gradient(from 120deg, rgba(14, 165, 233, 0.22), rgba(20, 184, 166, 0.18), rgba(99, 102, 241, 0.2), rgba(14, 165, 233, 0.22));
}

html[data-theme="light"] .auth-transition__text {
    color: #55688a;
}

html[data-theme="light"] .auth-transition__bar {
    background: rgba(37, 99, 235, 0.14);
}

html[data-theme="light"] .auth-particles span {
    box-shadow: 0 0 14px rgba(14, 165, 233, 0.6);
}
