/* ===== AUTH NAV BUTTONS — hidden until session check finishes ===== */
/* Prevents the "Войти/Регистрация" flash before /api/me responds. */
.auth-login-btn,
.auth-register-btn {
    opacity: 0;
    pointer-events: none;
}

body.auth-ready .auth-login-btn,
body.auth-ready .auth-register-btn {
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

/* ===== AUTH MODAL ===== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 2, 8, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.auth-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.auth-modal {
    background: linear-gradient(145deg, rgba(18, 8, 42, 0.98), rgba(10, 4, 20, 0.99));
    border: 1px solid rgba(124, 58, 237, 0.15);
    border-radius: var(--radius-lg);
    width: 440px;
    max-width: 94vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 0 120px rgba(124, 58, 237, 0.15);
}

.auth-overlay.open .auth-modal {
    transform: translateY(0) scale(1);
}

.auth-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--gray-400);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    z-index: 10;
}

.auth-modal-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.auth-modal-header {
    padding: 32px 32px 0;
    text-align: center;
}

.auth-modal-header .logo-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
}

.auth-modal-header .logo-icon svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.3));
}

.auth-modal-header h2 {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

.auth-modal-header p {
    font-size: 14px;
    color: var(--gray-500);
}

.auth-modal-body {
    padding: 24px 32px 32px;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.02);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    background: none;
    border: none;
    color: var(--gray-500);
    border-radius: 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.auth-tab.active {
    background: var(--gradient-main);
    color: white;
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.3);
}

.auth-tab:not(.active):hover {
    color: var(--gray-300);
}

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

.auth-form.hidden {
    display: none;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-400);
}

.auth-field input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(124, 58, 237, 0.1);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 15px;
    font-family: var(--font);
    transition: all var(--transition);
    outline: none;
}

.auth-field input::placeholder {
    color: var(--gray-600);
}

.auth-field input:focus {
    border-color: var(--purple-light);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}

.auth-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: #f87171;
    display: none;
}

.auth-error.show {
    display: block;
    animation: authShake 0.3s ease;
}

@keyframes authShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.auth-success {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: #4ade80;
    display: none;
}

.auth-success.show {
    display: block;
}

.auth-submit {
    width: 100%;
    padding: 14px;
    background: var(--gradient-main);
    color: white;
    font-size: 16px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.auth-submit:hover {
    box-shadow: 0 4px 30px rgba(124, 58, 237, 0.4);
    transform: translateY(-1px);
}

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

.auth-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.auth-submit .spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spinAuth 0.6s linear infinite;
    margin: 0 auto;
}

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

.auth-submit.loading .btn-text {
    display: none;
}

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

.auth-resend {
    background: none;
    border: none;
    color: var(--purple-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 4px;
    padding: 4px;
    align-self: center;
    transition: color var(--transition);
}

.auth-resend:hover {
    color: var(--purple-lighter);
    text-decoration: underline;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255,255,255,0.04);
}

.auth-divider span {
    font-size: 12px;
    color: var(--gray-600);
    white-space: nowrap;
}

.auth-demo-note {
    text-align: center;
    font-size: 12px;
    color: var(--gray-600);
    padding-top: 8px;
}

.auth-demo-note a {
    color: var(--purple-light);
    text-decoration: none;
}

.auth-demo-note a:hover {
    text-decoration: underline;
}

/* Nav auth buttons */
.nav-link-register {
    background: transparent;
    color: var(--purple-light);
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 100px;
    border: 1px solid rgba(168, 85, 247, 0.3);
}

.nav-link-register:hover {
    background: rgba(168, 85, 247, 0.1);
    border-color: var(--purple-light);
}

.auth-login-btn {
    background: var(--gradient-main);
    color: white;
    box-shadow: var(--shadow-btn);
}

.auth-login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 40px rgba(124, 58, 237, 0.5);
}

/* Logged in state */
.nav-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--gradient-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: white;
    border: 2px solid rgba(168, 85, 247, 0.3);
}

.nav-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-300);
}

.nav-logout-btn {
    font-size: 12px;
    color: var(--gray-500);
    background: none;
    border: 1px solid rgba(255,255,255,0.06);
    padding: 4px 12px;
    border-radius: 100px;
    cursor: pointer;
    transition: all var(--transition);
}

.nav-logout-btn:hover {
    color: #ef4444;
    border-color: rgba(239,68,68,0.2);
}

@media (max-width: 768px) {
    .auth-modal-body {
        padding: 20px 20px 28px;
    }
    .auth-modal-header {
        padding: 24px 20px 0;
    }
    .nav-link-register {
        display: none;
    }
    .nav-user-info {
        display: flex;
    }
}
