/* ── Custom Properties ─────────────────────────────── */
:root {
    --crystal-bg-deep: #050b14;
    --crystal-bg-mid: #0a1628;
    --crystal-glass-bg: rgba(10, 22, 40, 0.55);
    --crystal-glass-border: rgba(99, 179, 237, 0.15);
    --crystal-glass-blur: 24px;

    --crystal-accent-blue: #4fa3e8;
    --crystal-accent-violet: #8b5cf6;
    --crystal-accent-cyan: #22d3ee;
    --crystal-gradient: linear-gradient(
        135deg,
        var(--crystal-accent-blue),
        var(--crystal-accent-violet)
    );

    --crystal-bull: #22c55e;
    --crystal-bear: #ef4444;

    --crystal-text-primary: #e8f0fe;
    --crystal-text-muted: #6b7fa3;
    --crystal-text-label: #94a3b8;

    --crystal-input-bg: rgba(255, 255, 255, 0.04);
    --crystal-input-border: rgba(99, 179, 237, 0.2);
    --crystal-input-focus: rgba(79, 163, 232, 0.5);

    --crystal-radius-card: 20px;
    --crystal-radius-input: 10px;
    --crystal-radius-btn: 10px;

    --crystal-shadow-card:
        0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 179, 237, 0.08);
    --crystal-shadow-glow: 0 0 40px rgba(79, 163, 232, 0.12);
}

/* ── Base ──────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Instrument Sans", ui-sans-serif, system-ui, sans-serif;
    background-color: var(--crystal-bg-deep);
    color: var(--crystal-text-primary);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-direction: column;
    top: 0px !important;
}

.auth-footer {
    bottom: 30px;
    position: absolute;
    color: var(--crystal-text-muted);
}

.auth-header {
    top: 30px;
    position: absolute;
}

/* ── Animated Background ───────────────────────────── */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.18;
    animation: drift 12s ease-in-out infinite alternate;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: var(--crystal-accent-blue);
    top: -120px;
    left: -100px;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: var(--crystal-accent-violet);
    bottom: -80px;
    right: -80px;
    animation-delay: -4s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--crystal-accent-cyan);
    top: 50%;
    left: 55%;
    animation-delay: -8s;
    opacity: 0.1;
}

@keyframes drift {
    from {
        transform: translate(0, 0) scale(1);
    }
    to {
        transform: translate(30px, 20px) scale(1.06);
    }
}

/* ── Grid lines overlay ────────────────────────────── */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(79, 163, 232, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(79, 163, 232, 0.03) 1px, transparent 1px);
    background-size: 48px 48px;
    pointer-events: none;
    z-index: 0;
}

/* ── Card ──────────────────────────────────────────── */
.login-card {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 14px 10px;
    animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-top {
    display: flex;
    justify-content: space-around;
    width: 100%;
    position: fixed;
    top: 42px;
}

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

/* ── Logo ──────────────────────────────────────────── */
.logo-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}

.logo-mark {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.logo-wordmark {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: var(--crystal-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Headings ──────────────────────────────────────── */
.login-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--crystal-text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--crystal-text-muted);
    margin-bottom: 32px;
}

/* ── Form fields ───────────────────────────────────── */
.field {
    margin-bottom: 18px;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--crystal-text-label);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.input-wrap {
    position: relative;
}

.input-wrap input {
    width: 100%;
    padding: 13px 16px;
    background: var(--crystal-input-bg);
    border: 1px solid var(--crystal-input-border);
    border-radius: var(--crystal-radius-input);
    color: var(--crystal-text-primary);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition:
        border-color 0.2s,
        box-shadow 0.2s,
        background 0.2s;
}

.input-wrap input::placeholder {
    color: var(--crystal-text-muted);
    opacity: 0.6;
}

.input-wrap input:focus {
    border-color: var(--crystal-accent-blue);
    box-shadow: 0 0 0 3px var(--crystal-input-focus);
    background: rgba(255, 255, 255, 0.06);
}

.input-wrap input.has-toggle {
    padding-right: 48px;
}

.eye-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--crystal-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s;
}

.eye-btn:hover {
    color: var(--crystal-accent-blue);
}

/* ── Forgot link ───────────────────────────────────── */
.forgot-link {
    display: block;
    text-align: right;
    font-size: 12px;
    color: var(--crystal-text-muted);
    text-decoration: none;
    margin-top: 6px;
    transition: color 0.2s;
}

.forgot-link:hover {
    color: var(--crystal-accent-blue);
}

/* ── Submit button ─────────────────────────────────── */
.btn-login {
    width: 100%;
    margin-top: 26px;
    padding: 14px;
    border: none;
    border-radius: var(--crystal-radius-btn);
    background: var(--crystal-gradient);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition:
        opacity 0.2s,
        transform 0.15s,
        box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(79, 163, 232, 0.3);
}

.btn-login:hover:not(:disabled) {
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 8px 30px rgba(79, 163, 232, 0.4);
}

.btn-login:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-login .btn-text {
    transition: opacity 0.2s;
}
.btn-login.loading .btn-text {
    opacity: 0;
}

.btn-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-login.loading .btn-spinner {
    opacity: 1;
}

.btn-spinner svg {
    animation: spin 0.8s linear infinite;
}

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

/* ── Divider ───────────────────────────────────────── */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 0;
    font-size: 12px;
    color: var(--crystal-text-muted);
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--crystal-glass-border);
}

/* ── Register link ─────────────────────────────────── */
.register-hint {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: var(--crystal-text-muted);
}

.register-hint a {
    color: var(--crystal-accent-blue);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.register-hint a:hover {
    opacity: 0.8;
}

/* ── Toast notifications ───────────────────────────── */
.toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid transparent;
    min-width: 300px;
    max-width: 380px;
    pointer-events: all;
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.toast.removing {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 100px;
        margin-bottom: 0;
    }
    to {
        opacity: 0;
        transform: translateX(20px) scale(0.95);
        max-height: 0;
        margin-bottom: -10px;
    }
}

.toast.success {
    background: rgba(16, 40, 24, 0.85);
    border-color: rgba(34, 197, 94, 0.3);
}

.toast.error {
    background: rgba(40, 12, 12, 0.85);
    border-color: rgba(239, 68, 68, 0.3);
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.toast.success .toast-icon {
    color: var(--crystal-bull);
}
.toast.error .toast-icon {
    color: var(--crystal-bear);
}

.toast-body {
}

.toast-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.toast.success .toast-title {
    color: #4ade80;
}
.toast.error .toast-title {
    color: #f87171;
}

.toast-msg {
    font-size: 12px;
    color: var(--crystal-text-muted);
    line-height: 1.4;
}

/* ── Fullscreen Loader ─────────────────────────────── */
.loader-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(5, 11, 20, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.loader-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.loader-chart {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 60px;
}

.candle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.candle-wick {
    width: 2px;
    border-radius: 2px;
    background: currentColor;
    opacity: 0.5;
}

.candle-body {
    width: 14px;
    border-radius: 3px;
}

.candle.bull {
    color: var(--crystal-bull);
}
.candle.bull .candle-body {
    background: var(--crystal-bull);
}
.candle.bear {
    color: var(--crystal-bear);
}
.candle.bear .candle-body {
    background: var(--crystal-bear);
}

/* Each candle animates up then down in staggered sequence */
.candle {
    animation: candlePulse 1.4s ease-in-out infinite;
}
.candle:nth-child(1) {
    animation-delay: 0s;
}
.candle:nth-child(2) {
    animation-delay: 0.1s;
}
.candle:nth-child(3) {
    animation-delay: 0.2s;
}
.candle:nth-child(4) {
    animation-delay: 0.3s;
}
.candle:nth-child(5) {
    animation-delay: 0.4s;
}
.candle:nth-child(6) {
    animation-delay: 0.5s;
}
.candle:nth-child(7) {
    animation-delay: 0.6s;
}

@keyframes candlePulse {
    0%,
    100% {
        opacity: 0.35;
        transform: scaleY(0.7);
    }
    50% {
        opacity: 1;
        transform: scaleY(1);
    }
}

.loader-text {
    font-size: 14px;
    color: var(--crystal-text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    animation: textPulse 1.4s ease-in-out infinite;
}

@keyframes textPulse {
    0%,
    100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* ── Input error state ─────────────────────────────── */
.input-wrap input.field-error {
    border-color: rgba(239, 68, 68, 0.5);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.field-error-msg {
    font-size: 11px;
    color: #f87171;
    margin-top: 5px;
    display: none;
}

.field-error-msg.visible {
    display: block;
}
