/* ========== БАЗОВЫЙ СБРОС ВНУТРИ МОДАЛЬНОГО ОКНА ========== */
#konfect-auth-container,
#konfect-auth-container * {
    box-sizing: border-box;
}

#konfect-auth-container button {
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

#konfect-auth-container input {
    background: transparent;
    border: none;
    margin: 0;
    font: inherit;
    color: inherit;
}

#konfect-auth-container a {
    text-decoration: none;
    color: inherit;
}

/* ========== ОСНОВНОЙ ОВЕРЛЕЙ ========== */
#auth-main-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Затемнённый фон (клик по нему закрывает окно) */
#auth-main-overlay .auth-main-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: -1;
}

/* ========== ОСНОВНОЙ КОНТЕЙНЕР (FLEX-СТРУКТУРА) ========== */
#konfect-auth-container {
    position: relative;
    z-index: 1;
    width: 90%;
    max-width: 400px;
    background-color: #1a1d26;
    border-radius: 0.75rem;
    border: 1px solid rgba(55, 65, 81, 0.5);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);

    display: flex;
    flex-direction: column;

    /* Фиксированная высота: минимум 500px, предпочтительно 90dvh, но никогда не выше 600px */
    height: clamp(500px, 90dvh, 600px);
    overflow: hidden;
}


/* Кнопка закрытия (крестик) */
#auth-main-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: #6b7280;
    z-index: 2;
    transition: color 0.2s;
}

#auth-main-close:hover {
    color: #fff;
}

/* ========== ЗАГОЛОВОК (ФИКСИРОВАННАЯ ВЫСОТА) ========== */
#konfect-auth-container .auth-heading {
    padding: clamp(0.8rem, 2vh, 1.5rem) clamp(0.8rem, 2vw, 1.5rem) clamp(0.3rem, 0.5vh, 0.5rem);
    text-align: center;
    flex-shrink: 0;
    min-height: clamp(3.5rem, 10vh, 5.5rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

#konfect-auth-container .auth-title {
    font-family: 'Neucha', sans-serif;
    font-weight: 500;
    font-size: clamp(1.25rem, 4vw, 1.875rem);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fff;
    margin: 0;
}

/* ========== ПРОКРУЧИВАЕМАЯ ОБЛАСТЬ С СЕКЦИЯМИ ========== */
#konfect-auth-container .auth-sections-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2px clamp(0.8rem, 2vw, 1.5rem) clamp(0.5rem, 1vh, 1rem);
}

/* ========== СЕКЦИИ ========== */
#konfect-auth-container .auth-section {
    width: 100%;
    padding: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 100%;
}

#konfect-auth-container .auth-actions {
    margin-top: auto;
    width: 100%;
}

#konfect-auth-container .hidden-step {
    display: none !important;
}

/* ========== КНОПКА «НАЗАД» ВНУТРИ СЕКЦИИ ВОССТАНОВЛЕНИЯ ========== */
/* Прижимаем к низу и делаем такой же, как auth‑btn‑back */
#auth-reset-back {
    margin-top: auto;
    /* улетает вниз */
    width: 100%;
    height: 60px;
    border-radius: 0.75rem;
    font-weight: 700;
    font-size: 1.125rem;
    background-color: transparent;
    border: 1px solid rgba(55, 65, 81, 0.5);
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    /* убираем подчёркивание */
    transition: all 0.2s ease-in-out;
}

#auth-reset-back:hover {
    color: #fff;
    border-color: #6b7280;
}

#auth-reset-back:active {
    transform: scale(0.98);
}

/* ========== ФУТЕР (ПРИБИТ К НИЗУ) ========== */
#konfect-auth-container .auth-footer {
    padding: 0 clamp(0.8rem, 2vw, 1.5rem) clamp(0.5rem, 1vh, 1rem);
    flex-shrink: 0;
}

/* ========== ТИПОГРАФИКА ========== */
#konfect-auth-container .auth-recipe-text {
    font-family: 'Elina', cursive;
    font-size: clamp(1rem, 3.5vw, 1.875rem);
    color: #d1d5db;
    text-align: center;
    margin-bottom: clamp(0.8rem, 2vh, 1.5rem);
    line-height: 1.25;
}

#konfect-auth-container .auth-info-text {
    color: #d1d5db;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    text-align: center;
    line-height: 1.25;
    margin-bottom: 1rem;
}

#konfect-auth-container .auth-email-highlight {
    color: #fb923c;
    font-weight: 500;
    word-break: break-all;
}

#konfect-auth-container .auth-description {
    color: #9ca3af;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* ========== ПОЛЯ ВВОДА ========== */
#konfect-auth-container .auth-input {
    width: 100%;
    height: 60px;
    background-color: #252936;
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 0.75rem;
    padding: 0 1.5rem;
    color: #fff;
    margin-bottom: 0.75rem;
    transition: border-color 0.2s ease-in-out;
}

#konfect-auth-container .auth-input,
#konfect-auth-container .auth-btn {
    height: clamp(44px, 7vh, 60px);
    /* от 44 до 60 пикселей */
    font-size: clamp(0.9rem, 2.5vw, 1.125rem);
    margin-bottom: clamp(0.4rem, 1vh, 0.75rem);
}

#konfect-auth-container .auth-input:focus {
    outline: none;
    border-color: #6b7280;
}

#konfect-auth-container .auth-input::placeholder {
    color: #4b5563;
}

/* Индикатор совпадения паролей */
.password-match {
    border-color: #2ecc71 !important;
    box-shadow: 0 0 0 1px #2ecc71;
}

.password-mismatch {
    border-color: #e74c3c !important;
    box-shadow: 0 0 0 1px #e74c3c;
}

/* Фокус на кнопке показа пароля */
#konfect-auth-container .password-toggle:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(242, 143, 14, 0.5);
}

/* Для старых браузеров */
#konfect-auth-container .password-toggle:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

@supports selector(:focus-visible) {
    #konfect-auth-container .password-toggle:focus {
        outline: none;
    }
}

/* чтобы иконка глаза не съезжала из-за margin-bottom у поля */
#konfect-auth-container .password-toggle-wrap {
    margin-bottom: 0.75rem;
}

#konfect-auth-container .password-toggle-wrap .auth-input {
    margin-bottom: 0;
}

/* Кнопка просмотра пароля */
.password-toggle-wrap {
    position: relative;
    display: block;
}

.password-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 18px;
    user-select: none;
    z-index: 2;
    line-height: 1;
}

/* Иконка глаза (SVG) */
.password-toggle svg {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    pointer-events: none;
    /* чтобы клик проходил на родительский span */
}

.password-toggle .eye-open {
    display: inline;
}

.password-toggle .eye-closed {
    display: none;
}

.password-toggle.eye-closed .eye-open {
    display: none;
}

.password-toggle.eye-closed .eye-closed {
    display: inline;
}

/* Индикатор сложности */
.password-strength-meter {
    height: 4px;
    background: #ddd;
    margin-top: 5px;
    border-radius: 2px;
    overflow: hidden;
}

.password-strength-bar {
    width: 0%;
    height: 100%;
    transition: width 0.3s, background-color 0.3s;
}

.password-strength-text {
    display: block;
    text-align: center;
    margin-top: 4px;
    font-size: 12px;
    color: #666;
}

/* Конфект-метр */
.konfect-meter {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 6px;
    font-family: monospace;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 0.75rem;
}

.konfect-char {
    color: #e74c3c;
}

/* ========== КНОПКИ ========== */
#konfect-auth-container .auth-btn {
    width: 100%;
    height: 60px;
    border-radius: 0.75rem;
    font-weight: 700;
    transition: all 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

#konfect-auth-container .auth-btn:active {
    transform: scale(0.98);
}

#konfect-auth-container .auth-btn-primary {
    background-color: #f28f0e;
    color: #fff;
}

#konfect-auth-container .auth-btn-primary:hover {
    background-color: #d9800d;
}

#konfect-auth-container .auth-btn-secondary {
    background-color: transparent;
    border: 1px solid rgba(55, 65, 81, 0.5);
    color: #9ca3af;
}

#konfect-auth-container .auth-btn-secondary:hover {
    color: #fff;
    border-color: #6b7280;
}

/* Кнопка "Назад" в футере */
#konfect-auth-container .auth-btn-back {
    background-color: transparent;
    border: 1px solid rgba(55, 65, 81, 0.5);
    color: #9ca3af;
    margin-top: 0.5rem;
}

#konfect-auth-container .auth-btn-back:hover {
    color: #fff;
    border-color: #6b7280;
}

/* ========== ИНДИКАТОР ЗАГРУЗКИ НА КНОПКЕ ========== */
#konfect-auth-container .auth-btn-loading {
    position: relative;
    color: transparent !important;
    /* скрываем текст */
    pointer-events: none;
    /* исключаем двойные клики */
}

#konfect-auth-container .auth-btn-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: auth-spin 0.6s linear infinite;
}

@keyframes auth-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== ОШИБКИ И УСПЕХ ========== */
#konfect-auth-container .auth-error {
    color: #ef4444;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    text-align: center;
    margin-bottom: 0.75rem;
    min-height: 2rem;
    line-height: 2rem;
    display: block;
}

#konfect-auth-container .auth-success {
    color: #10b981;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    text-align: center;
    margin-bottom: 0.75rem;
}

/* ========== ССЫЛКИ-КНОПКИ ========== */
#konfect-auth-container .auth-links {
    text-align: center;
    margin-top: 0.75rem;
}

#konfect-auth-container .auth-link {
    background: transparent;
    border: none;
    padding: 0;
    color: #9ca3af;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s;
    cursor: pointer;
    font: inherit;
    /* наследование шрифта */
}

#konfect-auth-container .auth-link:hover {
    color: #fff;
}

/* ========== РАЗДЕЛИТЕЛЬ "ИЛИ" ========== */
#konfect-auth-container .auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #6b7280;
    margin: 1.5rem 0;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
}

#konfect-auth-container .auth-divider::before,
#konfect-auth-container .auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
}

#konfect-auth-container .auth-divider::before {
    margin-right: 1rem;
}

#konfect-auth-container .auth-divider::after {
    margin-left: 1rem;
}

/* ========== ЧЕКБОКС "ЗАПОМНИТЬ МЕНЯ" ========== */
#konfect-auth-container .auth-remember {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: clamp(0.5rem, 1.5vh, 1rem);
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    color: #9ca3af;
}

#konfect-auth-container .auth-checkbox-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    color: #9ca3af;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    position: relative;
    padding-left: 28px;
    /* место под квадратик */
    user-select: none;
}

#konfect-auth-container .auth-checkbox-label:focus-within {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(242, 143, 14, 0.5);
    border-radius: 2px;
}

/* Прячем нативный input, но оставляем доступным для скринридеров */
#konfect-auth-container .auth-checkbox-label input[type="checkbox"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Квадратик */
#konfect-auth-container .auth-nice-checkbox {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border-radius: 3px;
    background-color: #252936;
    /* фон как у полей */
    border: 1px solid rgba(55, 65, 81, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

/* Галочка (появляется при checked) */
#konfect-auth-container .auth-nice-checkbox::before {
    content: "✓";
    color: #000;
    font-size: 14px;
    font-weight: bold;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

/* Состояние checked */
#konfect-auth-container .auth-checkbox-label input[type="checkbox"]:checked+.auth-nice-checkbox {
    background-color: #f28f0e;
    /* оранжевый как у кнопок */
    border-color: #f28f0e;
}

#konfect-auth-container .auth-checkbox-label input[type="checkbox"]:checked+.auth-nice-checkbox::before {
    opacity: 1;
    transform: scale(1);
}

/* Чекбокс "Запомнить меня" – фокус на label при фокусе на скрытом input */
#konfect-auth-container .auth-checkbox-label input[type="checkbox"]:focus-visible+.auth-nice-checkbox {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ========== ТАЙМЕР ========== */
#konfect-auth-container .auth-timer-text {
    color: #6b7280;
    font-size: clamp(0.75rem, 2vw, 0.875rem);
    text-align: center;
}

#konfect-auth-container .auth-timer-value {
    color: #f97316;
    font-family: monospace;
    font-weight: 700;
}

/* ========== OTP-ПОЛЯ ========== */
#konfect-auth-container .otp-fields {
    display: flex;
    justify-content: center;
    gap: 0.375rem;
    margin: 1rem 0;
}

#konfect-auth-container .auth-otp-input {
    width: 42px;
    height: 54px;
    background-color: #252936;
    border: 1px solid rgba(55, 65, 81, 0.5);
    border-radius: 0.75rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    padding: 0;
    line-height: 54px;
    transition: border-color 0.3s ease;
}

#konfect-auth-container .auth-otp-input:focus {
    outline: none;
    border-color: #f28f0e;
    box-shadow: 0 0 0 1px rgba(242, 143, 14, 0.3);
}

#konfect-auth-container .otp-filled {
    border-color: #10b981 !important;
}

#konfect-auth-container .otp-error {
    border-color: #ef4444 !important;
}

/* ========== УСПЕХ ========== */
#konfect-auth-container .auth-success-icon {
    width: 4rem;
    height: 4rem;
    background-color: rgba(16, 185, 129, 0.1);
    border: 2px solid #10b981;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

#konfect-auth-container .auth-success-text {
    color: #9ca3af;
    text-align: center;
}

#konfect-auth-container #auth-otp-step-success {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* ========== ЮРИДИЧЕСКИЙ ТЕКСТ (ФУТЕР OTP) ========== */
#konfect-auth-container .auth-legal-text {
    font-size: clamp(8px, 1.5vw, 10px);
    color: #6b7280;
    margin-top: clamp(0.3rem, 1vh, 1rem);
    line-height: 1.5;
    text-align: center;
}

#konfect-auth-container .auth-consent-link {
    color: #9ca3af;
    text-decoration: underline;
    text-decoration-color: #4b5563;
    text-underline-offset: 2px;
}

#konfect-auth-container .auth-consent-link:hover {
    color: #fff;
}

/* ========== ПОПАП СОГЛАСИЙ ========== */
.consent-page-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    /* управляется JS, но для вёрстки flex */
    align-items: center;
    justify-content: center;
}

.consent-page-popup {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    background: #1e1e1e;
    color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    position: relative;
    /* для позиционирования крестика */
}

.consent-page-popup .auth-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #6b7280;
    transition: color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
}

.consent-page-popup .auth-close-btn:hover {
    color: #fff;
}

.consent-loading-text {
    text-align: center;
    color: #aaa;
}

.consent-title {
    margin-top: 0;
    color: #fff;
}

.consent-error-text {
    color: #e74c3c;
    text-align: center;
}

/* ========== ЧЁТКИЙ ФОКУС ДЛЯ ДОСТУПНОСТИ ========== */
#konfect-auth-container button:focus-visible,
#konfect-auth-container input:focus-visible,
#konfect-auth-container a:focus-visible,
#konfect-auth-container .auth-consent-link:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(242, 143, 14, 0.5);
    /* лёгкое оранжевое свечение */
}

/* Для старых браузеров, где :focus-visible не поддерживается, даём обычный outline */
#konfect-auth-container button:focus,
#konfect-auth-container input:focus,
#konfect-auth-container a:focus,
#konfect-auth-container .auth-consent-link:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Убираем дублирование, если браузер поддерживает :focus-visible, то скрываем :focus */
@supports selector(:focus-visible) {

    #konfect-auth-container button:focus,
    #konfect-auth-container input:focus,
    #konfect-auth-container a:focus,
    #konfect-auth-container .auth-consent-link:focus {
        outline: none;
    }
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 480px) {
    #konfect-auth-container {
        max-width: 90vw;
        width: 92vw;
        height: clamp(380px, 80dvh, 500px);
    }

    /* остальные мобильные стили (заголовок, wrapper, footer) остаются без изменений */
    #konfect-auth-container .auth-heading {
        min-height: 3.5rem;
        padding: 1rem 1rem 0.3rem;
    }

    #konfect-auth-container .auth-sections-wrapper {
        padding: 0 1rem 0.5rem;
    }

    #konfect-auth-container .auth-footer {
        padding: 0 1rem 0.5rem;
    }

    #konfect-auth-container .auth-title,
    #konfect-auth-container .auth-recipe-text {
        font-size: 1.5rem;
    }

    #konfect-auth-container .auth-input,
    #konfect-auth-container .auth-btn {
        height: 46px;
    }

    #konfect-auth-container .auth-otp-input {
        width: 36px;
        height: 44px;
        font-size: 1rem;
        line-height: 44px;
    }
}

@media (min-width: 1400px) {
    #konfect-auth-container {
        max-width: 440px;
    }
}

/* ========== БОЛЬШИЕ ЭКРАНЫ (Full HD и 4K) ========== */
@media (min-height: 1200px) {
    #konfect-auth-container {
        height: clamp(600px, 80dvh, 720px);
        /* высота по содержимому */
        min-height: 600px;
        /* не меньше дефолтной */
        max-height: 80vh;
        /* не более 80% экрана */
    }

    #konfect-auth-container .auth-sections-wrapper {
        overflow-y: visible;
        /* убираем принудительный скролл */
    }

    /* Чуть увеличим ширину, чтобы форма выглядела пропорциональнее */
    #konfect-auth-container {
        max-width: 440px;
    }
}