/* ============================================================
   SWAPSPACE — СТИЛИ АВТОРИЗАЦИИ (v2, фирменная тема 2026-10-25)
   Месторасположение: swapzone_website/static/css/auth.css

   Гамма портала: графит (#212529 / #2b3035) + amber (#ffc107 / #f59e0b),
   белые карточки, мягкие тени, крупные радиусы — как лендинг и navbar.

   Покрывает: SMS-режим (телефон → код), классический вход, регистрацию.
   ============================================================ */

/* ============================================================
   0. ПЕРЕМЕННЫЕ
   ============================================================ */
:root {
    --auth-primary: #f59e0b;
    --auth-primary-dark: #b45309;
    --auth-accent: #ffc107;
    --auth-accent-hover: #e0a800;
    --auth-dark: #212529;
    --auth-dark-2: #2b3035;
    --auth-dark-3: #16181b;
    --auth-text: #212529;
    --auth-muted: #6b7280;
    --auth-border: #e5e7eb;
    --auth-border-strong: #d1d5db;
    --auth-bg: #f4f4f5;
    --auth-white: #ffffff;
    --auth-danger: #dc2626;
    --auth-success: #16a34a;
    --auth-info: #2563eb;
    --auth-shadow-sm: 0 2px 8px rgba(33, 37, 41, 0.06);
    --auth-shadow-md: 0 18px 50px rgba(33, 37, 41, 0.12);
    --auth-shadow-lg: 0 28px 80px rgba(33, 37, 41, 0.20);
    --auth-radius: 22px;
    --auth-radius-sm: 12px;
}

/* ============================================================
   1. СТРАНИЦА
   ============================================================ */
.auth-page {
    position: relative;
    min-height: calc(100vh - 140px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    background:
        radial-gradient(900px 500px at 15% 0%, rgba(33, 37, 41, 0.10), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(33, 37, 41, 0.08), transparent 55%),
        var(--auth-bg);
    overflow: hidden;
}

/* Декоративный фон */
.auth-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.auth-bg-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: 0.35;
    animation: authBlobFloat 20s ease-in-out infinite;
}

.auth-bg-blob--1 {
    width: 520px;
    height: 520px;
    background: #2b3035;
    top: -220px;
    left: -160px;
}

.auth-bg-blob--2 {
    width: 460px;
    height: 460px;
    background: #2b3035;
    bottom: -220px;
    right: -140px;
    animation-delay: -10s;
}

.auth-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(33, 37, 41, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(33, 37, 41, 0.045) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at center, #000 25%, transparent 72%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 25%, transparent 72%);
}

@keyframes authBlobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33%      { transform: translate(28px, -36px) scale(1.06); }
    66%      { transform: translate(-22px, 24px) scale(0.96); }
}

/* ============================================================
   2. КОНТЕЙНЕР: бренд-панель + карточка
   ============================================================ */
.auth-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1040px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
    background: var(--auth-white);
    border: 1px solid var(--auth-border);
    border-radius: var(--auth-radius);
    box-shadow: var(--auth-shadow-md);
    overflow: hidden;
}

/* ============================================================
   3. БРЕНД-ПАНЕЛЬ (слева)
   ============================================================ */
.auth-brand {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 14px;
    padding: 56px 48px;
    background:
        radial-gradient(600px 340px at 0% 0%, rgba(148, 163, 184, 0.18), transparent 62%),
        linear-gradient(160deg, var(--auth-dark) 0%, var(--auth-dark-2) 60%, var(--auth-dark-3) 100%);
    color: #f9fafb;
    overflow: hidden;
}

/* тонкая «гаражная» сетка на панели */
.auth-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: linear-gradient(180deg, #000 30%, transparent 100%);
    -webkit-mask-image: linear-gradient(180deg, #000 30%, transparent 100%);
    pointer-events: none;
}

.auth-brand > * {
    position: relative;
    z-index: 1;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--auth-accent);
}

.auth-logo:hover,
.auth-logo:focus,
.auth-logo:active {
    color: #ffffff;
    text-decoration: none;
}

.auth-logo:hover .auth-logo__text {
    color: #ffffff;
}

.auth-logo__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(180deg, var(--auth-accent) 0%, var(--auth-primary) 100%);
    color: var(--auth-dark);
    font-size: 26px;
    box-shadow: 0 10px 24px rgba(245, 158, 11, 0.35);
}

.auth-logo__text {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--auth-accent);
    transition: color 0.15s ease;
}

.auth-logo:hover .auth-logo__text {
    color: #ffffff;
}

.auth-tagline {
    margin: 4px 0 0;
    color: rgba(249, 250, 251, 0.72);
    font-size: 15px;
    line-height: 1.55;
    max-width: 340px;
}

.auth-features {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-features li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: rgba(249, 250, 251, 0.88);
    font-size: 14.5px;
    line-height: 1.45;
}

.auth-features i {
    color: var(--auth-accent);
    font-size: 17px;
    margin-top: 1px;
}


/* ============================================================
   4. КАРТОЧКА ФОРМЫ (справа)
   ============================================================ */
.auth-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 52px 48px;
    background: var(--auth-white);
}

.auth-step {
    width: 100%;
}

.auth-step.is-hidden {
    display: none !important;
}

.auth-step[hidden] {
    display: none !important;
}

.auth-title {
    margin: 0 0 8px;
    font-size: 30px;
    line-height: 1.2;
    font-weight: 800;
    color: var(--auth-text);
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin: 0 0 26px;
    color: var(--auth-muted);
    font-size: 15px;
    line-height: 1.55;
}

/* ============================================================
   5. ПОЛЯ
   ============================================================ */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.auth-label {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #374151;
}

.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="tel"],
.auth-form input[type="email"],
.auth-form select,
.auth-form textarea,
.auth-input {
    width: 100%;
    min-height: 50px;
    padding: 12px 15px;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: #f9fafb;
    color: var(--auth-text);
    font-size: 15.5px;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    outline: none;
}

.auth-form input::placeholder,
.auth-input::placeholder {
    color: #9ca3af;
}

.auth-form input:focus,
.auth-form select:focus,
.auth-form textarea:focus,
.auth-input:focus {
    border-color: var(--auth-primary);
    background: var(--auth-white);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.auth-form input[type="text"]:disabled,
.auth-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

/* help_text и звёздочка обязательных полей */
.auth-help {
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--auth-muted);
}

.auth-help ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.auth-required {
    color: var(--auth-danger);
    font-weight: 700;
}

/* Телефон: префикс + поле */
.auth-phone-wrap {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: #f9fafb;
    overflow: hidden;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-phone-wrap:focus-within {
    border-color: var(--auth-primary);
    background: var(--auth-white);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.auth-phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 14px;
    background: #eef0f3;
    border-right: 1.5px solid var(--auth-border);
    color: #374151;
    font-weight: 700;
    font-size: 15px;
}

.auth-phone-wrap .auth-input,
.auth-phone-wrap .auth-input--phone {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    min-height: 48px;
}

.auth-phone-wrap .auth-input:focus {
    box-shadow: none;
    background: transparent;
}

/* ============================================================
   6. КНОПКИ
   ============================================================ */
.auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    min-height: 50px;
    padding: 13px 18px;
    border-radius: var(--auth-radius-sm);
    border: 1.5px solid transparent;
    font-size: 15.5px;
    font-weight: 700;
    font-family: inherit;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease, background 0.15s ease,
                border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.auth-btn:active {
    transform: translateY(1px);
}

.auth-btn--primary {
    background: linear-gradient(180deg, var(--auth-accent) 0%, var(--auth-primary) 100%);
    color: var(--auth-dark);
    box-shadow: 0 10px 24px rgba(245, 158, 11, 0.28);
}

.auth-btn--primary:hover {
    background: linear-gradient(180deg, #ffd54f 0%, var(--auth-accent-hover) 100%);
    color: var(--auth-dark);
    box-shadow: 0 12px 28px rgba(245, 158, 11, 0.36);
}

.auth-btn--primary:focus-visible {
    outline: 3px solid rgba(245, 158, 11, 0.45);
    outline-offset: 2px;
}

.auth-btn--secondary {
    background: var(--auth-white);
    color: var(--auth-text);
    border-color: var(--auth-border-strong);
}

.auth-btn--secondary i,
.auth-btn--secondary .bi {
    color: var(--auth-primary-dark);
    font-size: 17px;
}

.auth-btn--secondary:hover {
    background: #f9fafb;
    border-color: var(--auth-primary);
    color: var(--auth-text);
}

.auth-btn[disabled],
.auth-btn.is-loading {
    cursor: wait;
    opacity: 0.75;
    box-shadow: none;
}

/* Спиннер внутри кнопки */
.auth-btn__spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(33, 37, 41, 0.25);
    border-top-color: var(--auth-dark);
    border-radius: 50%;
    animation: authSpin 0.7s linear infinite;
}

.auth-btn--secondary .auth-btn__spinner {
    border-color: rgba(33, 37, 41, 0.15);
    border-top-color: var(--auth-dark);
}

.auth-btn.is-loading .auth-btn__spinner {
    display: inline-block;
}

.auth-btn.is-loading .auth-btn__text {
    opacity: 0.75;
}

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

/* ============================================================
   7. РАЗДЕЛИТЕЛЬ, ССЫЛКИ, УВЕДОМЛЕНИЯ
   ============================================================ */
.auth-divider {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
    color: #9ca3af;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.auth-footer-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

.auth-container > .auth-footer-links {
    grid-column: 1 / -1;
    margin: 0;
    padding: 14px 20px;
    border-top: 1px solid var(--auth-border);
    background: #fbfbfc;
}

.auth-footer-links a {
    color: var(--auth-primary-dark);
    font-weight: 700;
    text-decoration: none;
}

.auth-footer-links a:hover {
    color: var(--auth-dark);
    text-decoration: underline;
}

.auth-link-btn {
    padding: 0;
    border: 0;
    background: none;
    color: var(--auth-primary-dark);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.auth-link-btn:hover {
    color: var(--auth-dark);
    text-decoration: underline;
}

/* Сообщения */
.auth-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.auth-message {
    padding: 12px 14px;
    border-radius: var(--auth-radius-sm);
    border: 1px solid var(--auth-border);
    background: #f9fafb;
    color: #374151;
    font-size: 14px;
    line-height: 1.45;
}

.auth-message--error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.auth-message--success {
    background: #f0fdf4;
    border-color: #bbf7d0;
    color: #166534;
}

.auth-message--warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.auth-message--info,
.auth-message--debug {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

.auth-notice {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: var(--auth-radius-sm);
    border: 1px solid var(--auth-border);
    background: #f9fafb;
    color: #4b5563;
    font-size: 13.5px;
    line-height: 1.5;
}

.auth-notice--warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

/* ============================================================
   8. ВКЛАДКИ ВХОД / РЕГИСТРАЦИЯ
   ============================================================ */
.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 24px;
    border-radius: 14px;
    background: #f3f4f6;
    border: 1px solid var(--auth-border);
}

.auth-tab {
    padding: 11px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #4b5563;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.auth-tab:hover:not(:disabled) {
    color: var(--auth-dark);
    background: rgba(255, 255, 255, 0.7);
}

.auth-tab.is-active {
    background: var(--auth-dark);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(33, 37, 41, 0.22);
}

.auth-tab:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ============================================================
   9. ШАГ 2: КОД ИЗ SMS
   ============================================================ */
.auth-code-header {
    margin-bottom: 22px;
}

.auth-code-header .auth-subtitle {
    margin-bottom: 0;
}

.auth-code-phone {
    display: inline-block;
    margin-left: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: var(--auth-primary-dark);
    font-weight: 700;
    white-space: nowrap;
}

.auth-code-cells {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}

.auth-code-cell {
    width: 100%;
    height: 58px;
    padding: 0;
    border: 1.5px solid var(--auth-border);
    border-radius: var(--auth-radius-sm);
    background: #f9fafb;
    color: var(--auth-text);
    font-size: 24px;
    font-weight: 800;
    font-family: inherit;
    text-align: center;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-code-cell:focus {
    border-color: var(--auth-primary);
    background: var(--auth-white);
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.auth-code-cell.is-filled {
    border-color: var(--auth-primary);
    background: #fffbeb;
    color: var(--auth-dark);
}

/* Таймер и повторная отправка */
.auth-timer {
    margin-top: 18px;
    text-align: center;
    color: var(--auth-muted);
    font-size: 14px;
    line-height: 1.5;
}

.auth-timer-count {
    font-weight: 800;
    color: var(--auth-text);
    font-variant-numeric: tabular-nums;
}

.auth-resend-btn {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 12px 16px;
    border: 1.5px solid var(--auth-border-strong);
    border-radius: var(--auth-radius-sm);
    background: var(--auth-white);
    color: var(--auth-text);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.auth-resend-btn:hover:not(:disabled) {
    background: #f9fafb;
    border-color: var(--auth-primary);
}

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

/* ============================================================
   10. РЕГИСТРАЦИЯ ЗАКРЫТА / СЛУЖЕБНЫЕ БЛОКИ
   ============================================================ */
.auth-closed {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 12px 0 4px;
    text-align: center;
}

.auth-closed__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 999px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: var(--auth-primary-dark);
    font-size: 34px;
}

.auth-closed__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
}

/* Оверлей загрузки (legacy) */
.auth-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(2px);
    border-radius: var(--auth-radius);
    z-index: 5;
}

.auth-overlay.is-visible {
    display: flex;
}

.auth-overlay-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(33, 37, 41, 0.15);
    border-top-color: var(--auth-primary);
    border-radius: 50%;
    animation: authSpin 0.8s linear infinite;
}

/* ============================================================
   11. АДАПТИВНОСТЬ
   ============================================================ */
@media (max-width: 980px) {
    .auth-container {
        grid-template-columns: 1fr;
        max-width: 520px;
    }

    .auth-brand {
        align-items: center;
        text-align: center;
        padding: 34px 28px;
        gap: 12px;
    }

    .auth-brand::before {
        mask-image: linear-gradient(180deg, #000 20%, transparent 100%);
    }

    .auth-tagline {
        max-width: 100%;
    }

    .auth-features {
        display: none;
    }

    .auth-card {
        padding: 34px 26px;
    }

    .auth-title {
        font-size: 26px;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding: 24px 12px;
    }

    .auth-container {
        border-radius: 18px;
    }

    .auth-card {
        padding: 26px 18px;
    }

    .auth-code-cells {
        gap: 6px;
    }

    .auth-code-cell {
        height: 50px;
        font-size: 20px;
        border-radius: 10px;
    }

    .auth-brand {
        padding: 26px 20px;
    }

    .auth-logo__icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .auth-logo__text {
        font-size: 22px;
    }
}

/* Уважение к настройкам пользователя */
@media (prefers-reduced-motion: reduce) {
    .auth-bg-blob,
    .auth-btn__spinner,
    .auth-overlay-spinner {
        animation: none !important;
    }
}

/* Логотип в авторизации: не подчёркивать ни в одном состоянии (как в хедере) */
.auth-logo,
.auth-logo:hover,
.auth-logo:focus,
.auth-logo:active,
.auth-logo:visited,
.auth-logo .auth-logo__text,
.auth-logo:hover .auth-logo__text {
    text-decoration: none !important;
}

/* Согласия при регистрации */
.auth-consent {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin: .85rem 0 .25rem;
}

.auth-check {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin: 0;
    font-size: .82rem;
    line-height: 1.45;
    color: #495057;
    cursor: pointer;
}

.auth-check input[type="checkbox"] {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    margin-top: .15rem;
    accent-color: #ffc107;
    cursor: pointer;
}

.auth-check a {
    color: #b8860b;
    text-decoration: underline;
}

.auth-check a:hover {
    color: #ffc107;
}

.auth-check--muted {
    color: #6c757d;
    font-size: .78rem;
}
