/* ============================================================
   AUTH SCREEN — email-first, Telegram как вторичный вход.
   Использует CSS-переменные из app.css (темы space/aurora/crimson).
   Ничего не переопределяется через !important — чистый слой.
   ============================================================ */

.screen-auth {
    position: fixed;
    inset: 0;
    background: var(--bg, #0a0a0f);
    background-image:
        radial-gradient(ellipse 70% 50% at 50% -10%, var(--accent-glow, rgba(108,92,231,.25)) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 50% 110%, rgba(79,142,247,.04) 0%, transparent 55%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    margin: auto;
    text-align: center;
    animation: authFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* ---- Лого + заголовок ---- */
.auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent, #6c5ce7), var(--accent-light, #a29bfe));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    overflow: hidden;
    box-shadow: 0 8px 28px var(--accent-glow, rgba(108,92,231,.35));
}

.auth-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text, #fff);
    margin: 0 0 6px;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    color: var(--text-secondary, #8b8b9e);
    font-size: 14px;
    margin: 0 0 22px;
}

/* ---- Табы переключения Вход / Регистрация ---- */
.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin: 0 0 18px;
    background: var(--bg-card, #141422);
    border-radius: 12px;
    border: 1px solid var(--border, #222);
}

.auth-tab {
    flex: 1;
    padding: 9px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #8b8b9e);
    font: 600 13px/1 inherit;
    border-radius: 9px;
    cursor: pointer;
    transition: background .2s, color .2s;
}

.auth-tab:hover {
    color: var(--text, #fff);
}

.auth-tab.active {
    background: var(--accent, #6c5ce7);
    color: #fff;
    box-shadow: 0 2px 10px var(--accent-glow, rgba(108,92,231,.35));
}

/* ---- Поля ---- */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-input {
    width: 100%;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1px solid var(--border, #333);
    background: var(--bg-card, #141422);
    color: var(--text, #fff);
    font: 400 15px/1.2 inherit;
    outline: none;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.auth-input::placeholder {
    color: var(--text-secondary, #8b8b9e);
    opacity: .7;
}

.auth-input:focus {
    border-color: var(--accent, #6c5ce7);
    box-shadow: 0 0 0 3px var(--accent-glow, rgba(108,92,231,.2));
}

.auth-input:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Код подтверждения — крупно, центрировано */
.auth-input-code {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 8px;
    font-feature-settings: "tnum" 1;
}

/* ---- Кнопки ---- */
.auth-btn {
    width: 100%;
    padding: 13px 16px;
    border-radius: 12px;
    border: none;
    font: 600 15px/1 inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform .15s, background .2s, box-shadow .2s, opacity .2s;
    box-sizing: border-box;
}

.auth-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.auth-btn-primary {
    background: var(--accent, #6c5ce7);
    color: #fff;
    box-shadow: 0 4px 16px var(--accent-glow, rgba(108,92,231,.35));
}

.auth-btn-primary:not(:disabled):active {
    transform: scale(.98);
    box-shadow: 0 2px 8px var(--accent-glow, rgba(108,92,231,.25));
}

.auth-btn-ghost {
    background: transparent;
    color: var(--text, #fff);
    border: 1px solid var(--border, #333);
}

.auth-btn-ghost:not(:disabled):hover {
    background: var(--bg-card, #141422);
    border-color: var(--text-secondary, #8b8b9e);
}

.auth-btn-ghost:not(:disabled):active {
    transform: scale(.98);
}

.auth-btn-tg {
    color: #54a9eb;
    border-color: rgba(84, 169, 235, .35);
}

.auth-btn-tg:not(:disabled):hover {
    background: rgba(84, 169, 235, .08);
    border-color: rgba(84, 169, 235, .6);
}

.auth-btn-tg svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ---- Ссылки / вспомогательные элементы ---- */
.auth-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2px;
    gap: 8px;
}

.auth-link {
    color: var(--accent-light, #a29bfe);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 6px 4px;
    transition: color .2s;
}

.auth-link:hover {
    color: var(--accent, #6c5ce7);
}

.auth-link-muted {
    color: var(--text-secondary, #8b8b9e);
}

.auth-link-muted:hover {
    color: var(--text, #fff);
}

/* ---- Разделитель "или" ---- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 12px;
    color: var(--text-secondary, #8b8b9e);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border, #222);
}

/* ---- Telegram widget контейнер ---- */
.auth-tg-widget {
    display: flex;
    justify-content: center;
    min-height: 42px;
    margin-top: 10px;
}

.auth-tg-widget:empty {
    display: none;
}

/* ---- Статусные сообщения ---- */
.auth-message {
    font-size: 13px;
    line-height: 1.4;
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 10px;
    text-align: left;
    display: none;
}

.auth-message.auth-error {
    color: #ff6b6b;
    background: rgba(255, 107, 107, .08);
    border: 1px solid rgba(255, 107, 107, .22);
}

.auth-message.auth-success {
    color: #51cf66;
    background: rgba(81, 207, 102, .08);
    border: 1px solid rgba(81, 207, 102, .22);
}

/* ---- Нижняя ссылка "На главную" ---- */
.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 22px;
    color: var(--text-secondary, #8b8b9e);
    font-size: 13px;
    text-decoration: none;
    transition: color .2s;
}

.auth-back:hover {
    color: var(--text, #fff);
}

/* ---- View переключение (login / register / code) ---- */
.auth-view {
    display: none;
}

.auth-view.active {
    display: block;
    animation: authFadeIn .25s ease-out;
}

/* ---- Адаптив ---- */
@media (max-width: 380px) {
    .auth-card { max-width: 100%; }
    .auth-logo { width: 64px; height: 64px; font-size: 28px; border-radius: 18px; }
    .auth-title { font-size: 20px; }
    .auth-input, .auth-btn { padding: 12px 14px; font-size: 14px; }
}

/* ---- Respect reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .auth-card, .auth-view.active { animation: none; }
    .auth-btn { transition: none; }
}
