/* =========================================================================
   Файл: /_assets/_css/auth.css
   Описание: Стили экранов авторизации, регистрации, восстановления, модалок и тостов
   ========================================================================= */

.auth-wrap {
    max-width: 440px;
    margin: 12px auto 32px;
}

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

.auth-title {
    font-size: 22px;
    font-weight: 800;
    text-align: center;
}

.auth-sub {
    font-size: 13px;
    color: var(--text-secondary);
    text-align: center;
    margin: 6px 0 22px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.auth-form[hidden],
.rem-step[hidden] {
    display: none !important;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.link-accent {
    color: var(--accent);
    font-weight: 600;
    font-size: 13px;
}

.btn-block { width: 100%; }

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1.6fr;
    gap: 10px;
}

/* Поле пароля с глазом */
.pass-field { position: relative; }
.pass-field .input { padding-right: 44px; }
.pass-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.pass-toggle .ico-hide { display: none; }
.pass-toggle.is-visible .ico-show { display: none; }
.pass-toggle.is-visible .ico-hide { display: inline-block; }

.check-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}
/* Индикатор шагов и плитки выбора */
.step-dots { display: flex; gap: 8px; margin-bottom: 18px; }
.step-dot { flex: 1; height: 4px; border-radius: 99px; background: var(--bg-elevated); transition: 0.25s; }
.step-dot.is-active { background: var(--accent-grad); }

.choice-grid { display: grid; gap: 10px; }
.choice-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.choice-grid.cols-1 { grid-template-columns: 1fr; }

.choice-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 46px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}
.choice-tile input { display: none; }
.choice-tile:has(input:checked) {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--text-primary);
}

.bday-grid { display: grid; grid-template-columns: 0.8fr 1.2fr 1fr; gap: 8px; }

/* ФИАС-поиск городов */
.geo-wrap { position: relative; }
.geo-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--card-shadow);
    z-index: 90;
}
.geo-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
    font-size: 13px;
    cursor: pointer;
}
.geo-item:last-child { border-bottom: none; }
.geo-item:hover { background: var(--bg-hover); }
.geo-item.is-empty { color: var(--text-muted); cursor: default; }

.auth-legal { font-size: 11px; color: var(--text-muted); text-align: center; margin-top: 16px; }
.auth-footer { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-color); text-align: center; font-size: 13px; color: var(--text-secondary); }

/* Модальное окно авторизации */
.auth-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.auth-modal[hidden] { display: none; }

.auth-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 10, 18, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: modalFadeIn 0.2s ease forwards;
}

.auth-modal-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 410px;
    padding: 28px 24px 24px;
    border-radius: 22px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    animation: modalPopIn 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.auth-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes modalPopIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Анимация и таймлайн тостов */
.toast {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    cursor: pointer;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast.is-warning { border-left-color: var(--warning); }
.toast-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 100%;
    background: var(--accent);
    transform-origin: left;
    animation: toastTimer var(--toast-duration, 3800ms) linear forwards;
}
.toast.is-success .toast-bar { background: var(--success); }
.toast.is-error .toast-bar   { background: var(--danger); }
.toast.is-warning .toast-bar { background: var(--warning); }

@keyframes toastTimer {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Поверх всех модальных окон */
.toast-stack {
    z-index: 2000 !important;
}

/* =========================================================================
   Дополнение: 3-шаговая модальная регистрация и настройка @login
   ========================================================================= */

.label-err {
    color: var(--danger);
    font-weight: 600;
    margin-left: 4px;
}

.reg-modal-card {
    max-width: 440px;
    max-height: 92dvh;
    overflow-y: auto;
}

.choice-tile-col {
    flex-direction: column;
    text-align: center;
    padding: 14px 10px;
    min-height: 78px;
    font-size: 13px;
    line-height: 1.3;
}

/* Обязательное окно настройки адреса страницы (@login) */
.login-setup-card {
    max-width: 470px;
    max-height: 92dvh;
    overflow-y: auto;
}

.setup-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 auto 10px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
}
.login-setup-card {
    display: flex;
    flex-direction: column;
}

.login-prefix-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.login-prefix-wrap:focus-within {
    border-color: var(--accent);
}
.login-prefix {
    padding: 0 10px 0 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    user-select: none;
}
.login-prefix-wrap .input {
    border: none;
    border-radius: 0;
    padding-left: 2px;
    background: transparent;
}

.login-status-msg {
    font-size: 13px;
    font-weight: 600;
    min-height: 18px;
}
.login-status-msg.is-ok { color: var(--success); }
.login-status-msg.is-err { color: var(--danger); }

.login-rules-box {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 12px 14px;
}
.login-rules-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.login-rules-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.login-rules-list li {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    line-height: 1.35;
}
.login-rules-list li::before {
    content: '•';
    font-weight: 800;
    color: var(--text-muted);
    flex-shrink: 0;
}
.login-rules-list li.is-pass {
    color: var(--success);
}
.login-rules-list li.is-pass::before {
    content: '✓';
    color: var(--success);
}
.login-rules-list li.is-fail {
    color: var(--danger);
}
.login-rules-list li.is-fail::before {
    content: '✕';
    color: var(--danger);
}

.toast-stack {
    z-index: 2000 !important;
}

/* Отступы между полями и кнопками внутри шагов регистрации */
.reg-step.is-active {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.reg-step .btn-block,
.reg-step .btn-row {
    margin-top: 6px;
}

/* Тактильные плитки выбора пола с индикатором-галочкой */
.choice-grid.cols-2:has(input[name="gender"]) .choice-tile::before {
    content: '';
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    transition: background 0.2s, box-shadow 0.2s;
}

/* Мужской пол (value="1") — голубой акцент */
.choice-grid.cols-2:has(input[name="gender"]) .choice-tile:has(input[value="1"]:checked) {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.14);
}
.choice-grid.cols-2:has(input[name="gender"]) .choice-tile:has(input[value="1"]:checked)::before {
    content: '✓';
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    color: #ffffff;
    background: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.65);
}

/* Женский пол (value="2") — розово-коралловый акцент */
.choice-grid.cols-2:has(input[name="gender"]) .choice-tile:has(input[value="2"]:checked) {
    border-color: #fb3b64;
    background: rgba(251, 59, 100, 0.14);
}
.choice-grid.cols-2:has(input[name="gender"]) .choice-tile:has(input[value="2"]:checked)::before {
    content: '✓';
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
    color: #ffffff;
    background: #fb3b64;
    box-shadow: 0 0 12px rgba(251, 59, 100, 0.65);
}

/* Единый стиль кнопки закрытия модальных окон и отступ полоски шагов */
.reg-modal-card .step-dots {
    margin-right: 44px;
}

.auth-modal-close {
    background: rgba(220, 38, 38, 0.22) !important;
    border: 1px solid rgba(239, 68, 68, 0.48) !important;
    color: #fca5a5 !important;
    transition: background 0.2s, color 0.2s, transform 0.15s;
}
.auth-modal-close:hover {
    background: #dc2626 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    transform: scale(1.05);
}

/* =========================================================================
   Мобильная адаптация модальных окон под клавиатуру и позиционирование Cookie
   ========================================================================= */

/* Плашка Cookie на мобильных: вплотную к низу для гостей и над таббаром для авторизованных */
@media (max-width: 959px) {
    body[data-auth="0"] .cookie-banner {
        bottom: calc(10px + env(safe-area-inset-bottom)) !important;
    }
    body[data-auth="1"] .cookie-banner {
        bottom: calc(68px + env(safe-area-inset-bottom)) !important;
    }
}

@media (max-width: 640px) {
    .cookie-banner {
        left: 10px !important;
        right: 10px !important;
        padding: 10px 12px !important;
        border-radius: 14px !important;
        gap: 10px !important;
    }
    .cookie-banner-text {
        font-size: 12px !important;
        line-height: 1.35 !important;
    }

    /* Модалка под реальную высоту видимого окна (с учётом клавиатуры) */
    .auth-modal {
        height: 100dvh;
        padding: 8px;
        align-items: center;
    }

    .auth-modal-card,
    .reg-modal-card,
    .login-setup-card {
        max-height: calc(100dvh - 16px);
        padding: 16px 14px 14px;
        border-radius: 18px;
    }

    .auth-modal-close {
        top: 10px;
        right: 10px;
        width: 30px;
        height: 30px;
    }

    .reg-modal-card .step-dots {
        margin-bottom: 10px;
        margin-right: 38px;
    }

    .auth-modal-card .auth-title {
        font-size: 19px;
    }

    .auth-modal-card .auth-sub {
        font-size: 12px;
        margin: 3px 0 12px;
    }

    .auth-modal-card .auth-form,
    .auth-modal-card .reg-step.is-active {
        gap: 10px;
    }

    .auth-modal-card .form-group {
        gap: 5px;
    }

    .auth-modal-card .form-label {
        font-size: 12px;
    }

    .auth-modal-card .input,
    .auth-modal-card .choice-tile {
        min-height: 40px;
        height: 40px;
        font-size: 14px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .auth-modal-card .choice-tile-col {
        height: auto;
        min-height: 66px;
        padding: 10px 8px;
    }

    .auth-modal-card .btn {
        min-height: 42px;
        height: 42px;
    }

    .auth-modal-card .reg-step .btn-block,
    .auth-modal-card .reg-step .btn-row {
        margin-top: 2px;
    }

    .auth-modal-card .auth-legal {
        margin-top: 10px;
        font-size: 10.5px;
        line-height: 1.3;
    }

    .auth-modal-card .auth-footer {
        margin-top: 10px;
        padding-top: 10px;
        font-size: 12px;
    }

    .geo-dropdown {
        max-height: 150px;
    }
}

/* Плотный ввод сразу после @ без пробела и без мерцания при клике */
.auth-modal-card {
    background: var(--bg-surface);
    transform: translateZ(0);
}

.login-prefix {
    padding: 0 0 0 14px !important;
}

.login-prefix-wrap .input {
    padding-left: 1px !important;
}

/* =========================================================================
   Блок быстрой авторизации через соцсети (VK, OK, Mail.ru, Яндекс)
   ========================================================================= */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.oauth-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.oauth-grid .oauth-pill {
    width: 100%;
    height: 42px;
    border-radius: 12px;
}

@media (max-width: 640px) {
    .auth-modal-card .auth-divider {
        margin: 12px 0 8px;
    }
    .auth-modal-card .oauth-grid .oauth-pill {
        height: 38px;
    }
}
