/* ─── Design Tokens ──────────────────────────────────────────── */
:root {
    --auth-bg: #0a0b0f;
    --auth-surface: rgba(18, 20, 28, 0.85);
    --auth-surface-raised: rgba(26, 29, 40, 0.9);
    --auth-border: rgba(255, 255, 255, 0.06);
    --auth-border-focus: rgba(99, 102, 241, 0.5);
    --auth-text: #e4e4e7;
    --auth-text-muted: #71717a;
    --auth-text-dim: #52525b;
    --auth-accent: #6366f1;
    --auth-accent-hover: #818cf8;
    --auth-accent-glow: rgba(99, 102, 241, 0.15);
    --auth-success: #22c55e;
    --auth-error: #ef4444;
    --auth-error-bg: rgba(239, 68, 68, 0.08);
    --auth-error-border: rgba(239, 68, 68, 0.2);
    --auth-success-bg: rgba(34, 197, 94, 0.08);
    --auth-success-border: rgba(34, 197, 94, 0.2);
    --auth-radius: 14px;
    --auth-radius-sm: 10px;
    --auth-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 1px rgba(255, 255, 255, 0.05);
    --auth-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --auth-mono: 'JetBrains Mono', monospace;
    --auth-fast: 150ms;
    --auth-base: 250ms;
    --auth-slow: 400ms;
    --auth-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

body {
    font-family: var(--auth-font);
    background-color: var(--auth-bg);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--auth-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 0;
}

/* ─── Preloader ─────────────────────────────────────────────── */
.preloader {
    position: fixed;
    inset: 0;
    background: var(--auth-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--auth-slow) var(--auth-ease);
}
.preloader.done { opacity: 0; pointer-events: none; }
.preloader-spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--auth-border);
    border-top-color: var(--auth-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Auth Wrapper (full-screen centering) ──────────────────── */
.auth-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}
.auth-wrapper.hidden { display: none; }

/* ─── Auth Card ─────────────────────────────────────────────── */
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--auth-surface);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow);
    overflow: hidden;
    animation: cardIn var(--auth-slow) var(--auth-ease);
}
@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ─── Header ────────────────────────────────────────────────── */
.auth-header {
    position: relative;
    text-align: center;
    padding: 32px 28px 0;
}

.back-btn {
    position: absolute;
    top: 16px; left: 16px;
    background: none;
    border: 1px solid var(--auth-border);
    color: var(--auth-text-muted);
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: all var(--auth-fast) var(--auth-ease);
}
.back-btn:hover {
    color: var(--auth-text);
    border-color: var(--auth-text-dim);
    background: rgba(255, 255, 255, 0.04);
}

.auth-logo {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid var(--auth-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}
.auth-logo.small { width: 48px; height: 48px; border-radius: 12px; }
.auth-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--auth-text);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: var(--auth-text-muted);
    line-height: 1.4;
    margin-bottom: 0;
}

/* ─── Body ──────────────────────────────────────────────────── */
.auth-body {
    padding: 24px 28px 28px;
}

/* ─── Alerts ────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--auth-radius-sm);
    font-size: 0.82rem;
    line-height: 1.4;
    margin-bottom: 16px;
    animation: alertIn var(--auth-base) var(--auth-ease);
}
@keyframes alertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert i { margin-top: 1px; flex-shrink: 0; font-size: 0.9rem; }
.alert-error {
    background: var(--auth-error-bg);
    border: 1px solid var(--auth-error-border);
    color: var(--auth-error);
}
.alert-success {
    background: var(--auth-success-bg);
    border: 1px solid var(--auth-success-border);
    color: var(--auth-success);
}

/* ─── Google Button ─────────────────────────────────────────── */
.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    color: var(--auth-text);
    font-family: var(--auth-font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--auth-fast) var(--auth-ease);
}
.btn-google:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--auth-text-dim);
}
.btn-google:active { transform: scale(0.985); }

/* ─── Divider ───────────────────────────────────────────────── */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 20px 0;
    color: var(--auth-text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.auth-divider::before, .auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--auth-border);
}

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

.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--auth-text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    transition: all var(--auth-fast) var(--auth-ease);
}
.input-wrap:focus-within {
    border-color: var(--auth-border-focus);
    box-shadow: 0 0 0 3px var(--auth-accent-glow);
}
.input-wrap > i {
    position: absolute;
    left: 14px;
    color: var(--auth-text-dim);
    font-size: 0.85rem;
    pointer-events: none;
    transition: color var(--auth-fast);
}
.input-wrap:focus-within > i { color: var(--auth-accent); }

.input-wrap input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--auth-text);
    font-family: var(--auth-font);
    font-size: 0.9rem;
    padding: 12px 14px 12px 40px;
    min-width: 0;
}
.input-wrap input::placeholder { color: var(--auth-text-dim); }

.toggle-pw {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--auth-text-dim);
    cursor: pointer;
    padding: 6px 8px;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: color var(--auth-fast);
}
.toggle-pw:hover { color: var(--auth-text-muted); }

/* ─── Checkbox ──────────────────────────────────────────────── */
.field-row { display: flex; align-items: center; justify-content: space-between; }

.checkbox-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--auth-text-muted);
    user-select: none;
}
.checkbox-wrap input { display: none; }
.checkmark {
    width: 18px; height: 18px;
    border: 1.5px solid var(--auth-text-dim);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--auth-fast);
    flex-shrink: 0;
}
.checkmark::after {
    content: "\f00c";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.6rem;
    color: white;
    opacity: 0;
    transform: scale(0);
    transition: all var(--auth-fast);
}
.checkbox-wrap input:checked + .checkmark {
    background: var(--auth-accent);
    border-color: var(--auth-accent);
}
.checkbox-wrap input:checked + .checkmark::after {
    opacity: 1;
    transform: scale(1);
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: var(--auth-accent);
    border: none;
    border-radius: var(--auth-radius-sm);
    color: white;
    font-family: var(--auth-font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--auth-fast) var(--auth-ease);
    position: relative;
    overflow: hidden;
}
.btn-primary:hover { background: var(--auth-accent-hover); }
.btn-primary:active { transform: scale(0.985); }
.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.btn-primary .btn-loading { display: none; }
.btn-primary.loading .btn-text { display: none; }
.btn-primary.loading .btn-loading { display: flex; align-items: center; gap: 8px; }

.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn-outline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    color: var(--auth-text-muted);
    font-family: var(--auth-font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--auth-fast) var(--auth-ease);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--auth-text-dim);
    color: var(--auth-text);
}

/* ─── Links ─────────────────────────────────────────────────── */
.auth-links {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}
.auth-links.center { justify-content: center; }

.link-btn {
    background: none;
    border: none;
    color: var(--auth-text-dim);
    font-family: var(--auth-font);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all var(--auth-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}
.link-btn:hover { color: var(--auth-text-muted); background: rgba(255, 255, 255, 0.04); }
.link-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.auth-footer-links {
    text-align: center;
    margin-top: 16px;
}
.auth-footer-links a {
    color: var(--auth-text-dim);
    font-size: 0.8rem;
    text-decoration: none;
    transition: color var(--auth-fast);
}
.auth-footer-links a:hover { color: var(--auth-text-muted); }

/* ─── OTP Grid ──────────────────────────────────────────────── */
.otp-grid {
    display: flex;
    gap: 8px;
    justify-content: center;
}
.otp-digit {
    width: 48px; height: 52px;
    text-align: center;
    font-family: var(--auth-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--auth-text);
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    outline: none;
    transition: all var(--auth-fast) var(--auth-ease);
    caret-color: var(--auth-accent);
}
.otp-digit:focus {
    border-color: var(--auth-accent);
    box-shadow: 0 0 0 3px var(--auth-accent-glow);
}

.otp-hint {
    text-align: center;
    font-size: 0.82rem;
    color: var(--auth-text-muted);
    margin-bottom: 16px;
}
.otp-hint strong { color: var(--auth-text); font-weight: 600; }

/* ─── Success State ─────────────────────────────────────────── */
.success-state {
    text-align: center;
    padding: 12px 0;
}
.success-icon {
    font-size: 3rem;
    color: var(--auth-success);
    margin-bottom: 16px;
    animation: successPop var(--auth-slow) var(--auth-ease);
}
@keyframes successPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}
.success-state h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--auth-text);
    margin-bottom: 8px;
}
.success-state p {
    font-size: 0.85rem;
    color: var(--auth-text-muted);
    margin-bottom: 24px;
}

/* ─── Footer ────────────────────────────────────────────────── */
.auth-footer {
    text-align: center;
    padding: 16px 28px;
    border-top: 1px solid var(--auth-border);
    font-size: 0.72rem;
    color: var(--auth-text-dim);
}

/* ─── Reduced Motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 480px) {
    .auth-wrapper { padding: 16px 12px; }
    .auth-card { border-radius: 12px; }
    .auth-header { padding: 24px 20px 0; }
    .auth-body { padding: 20px 20px 24px; }
    .auth-title { font-size: 1.3rem; }
    .otp-digit { width: 42px; height: 46px; font-size: 1.1rem; }
    .auth-links { flex-direction: column; align-items: stretch; }
    .link-btn { justify-content: center; }
}
