/* ==========================================================================
   SPM AUTH MASTER CSS 
   Окончательная версия: адаптивность, UI/UX, состояния BXmaker, SmartCaptcha
   ========================================================================== */

:root {
    --spm-auth-red: #f73342;
    --spm-auth-red-hover: #e72635;
    --spm-auth-soft: #f6f6f7;
    --spm-auth-border: #dedede;
    --spm-auth-text: #222;
    --spm-auth-muted: #8b8b8b;
}

/* === 1. ГЛОБАЛЬНЫЙ КАРКАС (Для отдельной страницы /auth/) === */
html:has(.spm-auth-main-page), 
body:has(.spm-auth-main-page) {
    background: var(--spm-auth-soft) !important;
    margin: 0;
    padding: 0;
    min-height: 100%;
}

.spm-auth-main-page {
    min-height: 100svh;
    padding: 40px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Golos Text", Arial, "Helvetica Neue", Helvetica, sans-serif;
}

.spm-auth-main-card {
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}

.spm-auth-main-back {
    display: block;
    width: fit-content;
    margin: 20px auto 0;
    color: #777;
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s ease;
}

.spm-auth-main-back:hover {
    color: var(--spm-auth-red);
}

/* === 2. КОНТЕЙНЕР ФОРМЫ (Для страницы и Popup) === */
.spm-auth-custom {
    width: 100%;
    margin: 0 auto;
    color: var(--spm-auth-text);
    border-radius: 12px;
    background: #fff;
    box-sizing: border-box;
    font-family: inherit;
}

.spm-auth-custom *,
.spm-auth-custom *:before,
.spm-auth-custom *:after {
    box-sizing: border-box;
}

/* Тени и отступы только для отдельной страницы, попап оформляет Аспро */
body:not(.order_page) .spm-auth-main-card .spm-auth-custom {
    box-shadow: 0 10px 32px rgba(0,0,0,.08);
    padding: 32px 30px 28px;
}

.auth_frame.popup .spm-auth-custom {
    padding: 0 4px 4px !important;
    box-shadow: none !important;
}

.spm-auth-custom__title {
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--spm-auth-text);
    margin: 0 0 20px;
}

/* === 3. ВКЛАДКИ (Вход по ID / Код) === */
.spm-auth-custom__radio {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

.spm-auth-custom__tabs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    margin: 0 0 24px;
}

.spm-auth-custom__tab {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--spm-auth-soft);
    color: #444;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    user-select: none;
    transition: all .2s ease;
}

.spm-auth-custom__tab:hover {
    color: var(--spm-auth-text);
    background: #ebebeb;
}

.spm-auth-custom__radio[id*="tab-id"]:checked ~ .spm-auth-custom__tabs .spm-auth-custom__tab--id,
.spm-auth-custom__radio[id*="tab-phone"]:checked ~ .spm-auth-custom__tabs .spm-auth-custom__tab--phone {
    background: #fff;
    color: var(--spm-auth-text);
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
}

.spm-auth-custom__panel {
    display: none;
    width: 100%;
    min-width: 0;
}

.spm-auth-custom__radio[id*="tab-id"]:checked ~ .spm-auth-custom__panels .spm-auth-custom__panel--id,
.spm-auth-custom__radio[id*="tab-phone"]:checked ~ .spm-auth-custom__panels .spm-auth-custom__panel--phone {
    display: block;
    animation: spmFadeIn 0.3s ease;
}

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

/* === 4. СОЦИАЛЬНАЯ АВТОРИЗАЦИЯ (VK / Yandex) === */
.spm-auth-custom__social {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 46px;
    margin: 0 0 12px;
    border-radius: 8px;
    border: 1px solid var(--spm-auth-border);
    background: #fff;
    color: var(--spm-auth-text) !important;
    text-decoration: none !important;
    font-size: 15px;
    font-weight: 500;
    transition: all .2s ease;
}

.spm-auth-custom__social:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,.08);
    border-color: #cfcfcf !important;
}

.spm-auth-custom__social--vk:hover {
    border-color: #0877f2 !important;
    box-shadow: 0 6px 16px rgba(8,119,242,.18);
}

.spm-auth-custom__social--yandex:hover {
    border-color: #fc3f1d !important;
    box-shadow: 0 6px 16px rgba(252,63,29,.15);
}

.spm-auth-custom__social-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex: 0 0 24px;
}

.spm-auth-custom__social--vk .spm-auth-custom__social-icon { background: #0877f2; }
.spm-auth-custom__social--yandex .spm-auth-custom__social-icon { background: #fc3f1d; }

.spm-auth-custom__policy {
    margin-top: 18px;
    color: var(--spm-auth-muted);
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

.spm-auth-custom__policy a {
    color: #1677ff !important;
    text-decoration: none;
    transition: color 0.2s;
}

.spm-auth-custom__policy a:hover { color: #0050b3 !important; }

.spm-auth-custom.spm-confirm-active .spm-auth-custom__policy--phone {
    display: none !important;
}

/* === 5. ОЧИСТКА ВНУТРЕННОСТЕЙ BXMAKER === */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-form,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget-form,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-smscode,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-botcall {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

.spm-auth-custom__phone-root {
    position: relative;
    z-index: 2;
    margin-bottom: 14px;
}

/* Скрываем мусор (Лоадеры, внутренние заголовки, регистрацию) */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-loader,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth__title,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth__toregistration {
    display: none !important;
}

/* Служебные заголовки (Ввод кода) */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-header {
    display: block !important;
    margin: 0 0 16px !important;
    color: var(--spm-auth-text) !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    text-align: left !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-enter-auth__title {
    display: none !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-header {
    margin-bottom: 12px !important;
    font-size: 19px !important;
    line-height: 1.25 !important;
}

/* Текстовки таймеров и подсказок */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-smscode__notice,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-usercall__notice,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-botcall__notice {
    margin: 0 0 16px !important;
    color: #555 !important;
    font-size: 13px !important;
    line-height: 1.45 !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-message {
    margin: 0 0 18px !important;
    font-size: 13px !important;
    line-height: 1.35 !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-enter-smscode__notice,
.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-enter-usercall__notice,
.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-enter-botcall__notice {
    margin-bottom: 18px !important;
}

/* === 6. ПОЛЯ ВВОДА (Телефон, Код, Пароль) === */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-phone,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-code {
    width: 100% !important;
    margin: 0 0 16px !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-input-code {
    margin: 2px 0 14px !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-phone__field,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input__field,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password__field,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-code__field {
    width: 100% !important;
    height: 52px !important;
    border-radius: 8px !important;
    border: 1px solid var(--spm-auth-border) !important;
    background: #fff !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.2s ease !important;
    position: relative !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-input-code__field {
    height: 56px !important;
    border-radius: 9px !important;
}

/* ПРЕМИАЛЬНЫЙ ФОКУС */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-phone__field:focus-within,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input__field:focus-within,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password__field:focus-within,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-code__field:focus-within {
    border-color: var(--spm-auth-red) !important;
    box-shadow: 0 0 0 3px rgba(247,51,66,.12) !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-phone__flag {
    width: 44px !important;
    min-width: 44px !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-phone__input,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input__input,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password__input,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-code__input {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.spm-auth-custom__panel--phone input {
    width: 100% !important;
    height: 50px !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 16px !important;
    color: var(--spm-auth-text) !important;
    padding: 0 14px !important;
    outline: none !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-input-code input {
    padding: 0 16px !important;
    text-align: center !important;
    font-weight: 700 !important;
    letter-spacing: 1px !important;
}

/* === 7. ГЛАВНАЯ КНОПКА === */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-button {
    width: 100% !important;
    height: 52px !important;
    border-radius: 8px !important;
    background: var(--spm-auth-red) !important;
    border: none !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(247,51,66,.2) !important;
    margin: 8px 0 0 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-button:hover:not(:disabled) {
    background: var(--spm-auth-red-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 16px rgba(247,51,66,.3) !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-button__title {
    color: #fff !important;
    font-weight: 700 !important;
    font-size: 16px !important;
}

/* Замена "Далее" на "Получить код" */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-form .bxmaker-authuserphone-button__title {
    font-size: 0 !important;
}
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-form .bxmaker-authuserphone-button__title:after {
    content: "Получить код";
    font-size: 16px;
}

/* Замена "Далее" в форме восстановления */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget-form .bxmaker-authuserphone-button__title {
    font-size: 0 !important;
}
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget-form .bxmaker-authuserphone-button__title:after {
    content: "Продолжить";
    font-size: 16px;
}

.spm-smart-captcha {
    display: block;
    clear: both;
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 302px;
    min-height: 112px;
    margin: 16px auto 18px;
    overflow: visible;
}

.spm-smart-captcha[data-visible="N"] {
    display: none !important;
}

.spm-smart-captcha iframe {
    display: block !important;
    max-width: 100% !important;
}

.spm-smart-captcha[data-status="required"]:before,
.spm-smart-captcha[data-status="missing-sitekey"]:before,
.spm-smart-captcha[data-status="script-error"]:before {
    display: block;
    padding: 12px 14px;
    border: 1px solid #f2c1c1;
    border-radius: 8px;
    background: #fff5f5;
    color: #9b1c1c;
    font-size: 13px;
    line-height: 1.4;
}

.spm-smart-captcha[data-status="required"]:before {
    content: "Подтвердите, что вы не робот";
}

.spm-smart-captcha[data-status="missing-sitekey"]:before {
    content: "Yandex SmartCaptcha: не задан публичный ключ";
}

.spm-smart-captcha[data-status="script-error"]:before {
    content: "Yandex SmartCaptcha временно недоступна";
}

/* === 9. СОСТОЯНИЯ ПАРОЛЯ И ВОССТАНОВЛЕНИЯ (Идеальная геометрия) === */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password {
    margin-bottom: 12px !important;
}

/* Иконка глаза */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password__visible {
    position: absolute !important;
    right: 14px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    margin: 0 !important;
    cursor: pointer !important;
    opacity: 0.5;
    transition: opacity 0.2s;
}
.spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password__visible:hover {
    opacity: 1;
}

/* "Не помню пароль" */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__forget {
    display: block !important;
    width: 100% !important;
    clear: both !important;
    position: relative !important;
    top: auto !important;
    z-index: 2 !important;
    text-align: right !important;
    margin: -8px 0 20px !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    color: #777 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    cursor: pointer !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__forget a,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__forget .bxmaker-authuserphone-link {
    display: inline-flex !important;
    min-height: 20px !important;
    align-items: center !important;
    justify-content: flex-end !important;
    color: inherit !important;
    font-size: inherit !important;
    line-height: 20px !important;
    text-decoration: none !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__forget:hover {
    color: var(--spm-auth-red) !important;
}

/* Разделитель "- или -" при восстановлении */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget-form__or {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    width: 100% !important;
    min-height: 22px !important;
    clear: both !important;
    margin: 18px 0 !important;
    top: auto !important;
    height: auto !important;
    color: #aaa !important;
    font-size: 13px !important;
    line-height: 22px !important;
    white-space: nowrap !important;
    position: relative !important;
    z-index: 2 !important;
}
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget-form__or:before,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget-form__or:after {
    content: "" !important;
    height: 1px !important;
    flex: 1 !important;
    background: #eaeaea !important;
}

/* Кнопки "Назад" */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__back,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget .bxmaker-authuserphone-enter-auth__toregistration {
    display: block !important;
    width: 100% !important;
    margin: 14px 0 0 !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__back a,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget .bxmaker-authuserphone-enter-auth__toregistration a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 46px !important;
    border-radius: 8px !important;
    background: var(--spm-auth-soft) !important;
    color: var(--spm-auth-text) !important;
    text-decoration: none !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth-by-password-form__back a:hover,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget .bxmaker-authuserphone-enter-auth__toregistration a:hover {
    background: #ebebeb !important;
}

/* Текст "Назад" в восстановлении */
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget .bxmaker-authuserphone-enter-auth__toregistration a { font-size: 0 !important; }
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-forget .bxmaker-authuserphone-enter-auth__toregistration a:after {
    content: "Вернуться назад";
    font-size: 14px !important;
}

/* === 10. МАГИЯ ТАЙМЕРА И КНОПКА "ДРУГОЙ СПОСОБ" === */

/* Базовый стиль альтернативной кнопки (любой метод подтверждения) */
.spm-auth-custom__panel--phone [class*="__bypass"] a {
    display: flex !important;
    width: 100% !important;
    height: 46px !important;
    border-radius: 8px !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin-top: 16px !important;
    
    /* Состояние: Таймер истек (Активная аккуратная кнопка) */
    background: #fff !important;
    color: var(--spm-auth-text) !important;
    border: 1px solid #d9d9d9 !important;
    cursor: pointer !important;
}

.spm-auth-custom__panel--phone [class*="__bypass"] a:hover {
    border-color: var(--spm-auth-red) !important;
    color: var(--spm-auth-red) !important;
    background: #fffafa !important;
}

/* Состояние: Таймер РАБОТАЕТ (ЖЕСТКАЯ БЛОКИРОВКА) */
/* Класс .spm-timer-active вешается скриптом из bxmaker_template.php */
.spm-timer-active [class*="__bypass"],
.spm-timer-active .bxmaker-authuserphone-enter-auth__change-confirm,
.spm-timer-active .bxmaker-authuserphone-enter-reg__change-confirm {
    pointer-events: none !important;
}

.spm-timer-active [class*="__bypass"] a,
.spm-timer-active .bxmaker-authuserphone-enter-auth__change-confirm a,
.spm-timer-active .bxmaker-authuserphone-enter-reg__change-confirm a {
    background: transparent !important;
    border-color: transparent !important;
    color: #999 !important;
    opacity: 0.7 !important;
    cursor: default !important;
}

.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-auth__change-confirm,
.spm-auth-custom__panel--phone .bxmaker-authuserphone-enter-reg__change-confirm {
    margin-top: 16px !important;
    text-align: center !important;
}

.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-enter-auth__change-confirm,
.spm-auth-custom.spm-confirm-active .bxmaker-authuserphone-enter-reg__change-confirm {
    margin-top: 12px !important;
}

/* === 11. МОБИЛЬНАЯ АДАПТИВНОСТЬ === */
@media (max-width: 480px) {
    .spm-auth-main-page {
        padding: 24px 14px;
        align-items: flex-start;
    }

    body:not(.order_page) .spm-auth-main-card .spm-auth-custom {
        padding: 28px 24px 24px;
        border-radius: 12px;
    }

    .auth_frame.popup {
        width: calc(100vw - 24px) !important;
        max-width: calc(100vw - 24px) !important;
        border-radius: 12px !important;
        padding: 24px 14px 16px !important;
    }

    .auth_frame.popup .spm-auth-custom {
        padding: 0 !important;
    }

    .spm-auth-custom__title {
        font-size: 20px;
        margin-bottom: 18px;
    }

    .spm-auth-custom__tab {
        min-height: 38px;
        font-size: 13px;
    }

    .spm-auth-custom__panel--phone .bxmaker-authuserphone-input-phone__field,
    .spm-auth-custom__panel--phone .bxmaker-authuserphone-input__field,
    .spm-auth-custom__panel--phone .bxmaker-authuserphone-input-password__field,
    .spm-auth-custom__panel--phone .bxmaker-authuserphone-input-code__field {
        height: 48px !important;
    }
    
    .spm-auth-custom__panel--phone input {
        height: 46px !important;
    }

    .spm-auth-custom__panel--phone .bxmaker-authuserphone-button {
        height: 48px !important;
    }
}

@media (max-width: 370px) {
    .spm-auth-main-card .spm-auth-custom,
    .auth_frame.popup .spm-auth-custom {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    .spm-auth-custom__tabs { gap: 6px; }
    .spm-auth-custom__tab { font-size: 12px; padding: 0 4px; }
}
