/* Модалка входа и регистрации. Макет: docs/auth-redesign-spec.md
   Все правила начинаются с .auth-dialog, чтобы не задеть main.css и bootstrap. */

/* ---------- Каркас ---------- */
.auth-dialog {
    width: 100%;
    max-width: 466px;
    margin: 1.75rem auto;
}
.auth-dialog .modal-content {
    position: relative;
    padding: 32px 40px;
    background: #FFFFFF;
    border: 1px solid #EAEAEA;
    border-radius: 28px;
    font-family: Inter, sans-serif;
    color: #0B090A;
}
.auth-dialog .modal-body {
    display: flex;
    flex-direction: column;
    gap: 41px;
    padding: 0;
}
.auth-dialog .modal-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 16px;
    margin: 0;
    padding: 0;
    border: 0;
}
.auth-dialog .auth-dialog__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    line-height: 0;
    cursor: pointer;
}
.auth-dialog .auth-dialog__close img {
    display: block;
    width: 24px;
    height: 24px;
}
.auth-dialog .auth-dialog__title {
    margin: 0;
    font: 600 28px/1.2 Inter, sans-serif;
    color: #0B090A;
}
.auth-dialog .auth-dialog__back {
    display: inline-flex;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    line-height: 0;
}
.auth-dialog .auth-dialog__back img {
    display: block;
    width: 24px;
    height: 24px;
}

/* Форма регистрации: шапка -> тело 24px (первый шаг и пароль — 41px по умолчанию) */
.auth-dialog.auth-dialog--form .modal-body {
    gap: 24px;
}

/* ---------- Вертикальные стеки ---------- */
.auth-dialog .auth-stack,
.auth-dialog .auth-stack--wide {
    display: flex;
    flex-direction: column;
}
.auth-dialog .auth-stack {
    gap: 24px;
}
.auth-dialog .auth-stack--wide {
    gap: 41px;
}
.auth-dialog .auth-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---------- Поле ввода ---------- */
.auth-dialog .auth-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    width: 100%;
    height: 42px;
    padding: 0 16px;
    background: #FFFFFF;
    border: 1px solid #E0E0E0;
    border-radius: 8px;
    font: 400 16px/1 Inter, sans-serif;
    color: #343434;
}
.auth-dialog .auth-field input {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    background: transparent;
    box-shadow: none;
    font: inherit;
    color: inherit;
}
.auth-dialog .auth-field input::placeholder {
    color: #9CA3AF;
    opacity: 1;
}
.auth-dialog .auth-field:focus-within {
    border-color: #191919;
}

/* Ошибка: иконка alert-20.svg (20px) — <img> прямым потомком поля */
.auth-dialog .auth-field--error {
    background: #FEF2F2;
    border-color: #EF4444;
}
.auth-dialog .auth-field--error:focus-within {
    border-color: #EF4444;
}
.auth-dialog .auth-field--error > img {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
}
.auth-dialog .auth-error {
    margin: 4px 0 0;
    font: 400 14px/1.2 Inter, sans-serif;
    color: #EF4444;
}

/* Пароль: кнопка-глаз (eye.svg 24px) справа */
.auth-dialog .auth-field--password button {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    line-height: 0;
    cursor: pointer;
}
.auth-dialog .auth-field--password button img {
    display: block;
    width: 24px;
    height: 24px;
}

/* Подтверждённый телефон: 2px зелёная рамка, галочка и бейдж справа */
.auth-dialog .auth-field--verified {
    padding: 0 14px;
    gap: 12px;
    background: #F0FDF4;
    border: 2px solid #16A34A;
    border-radius: 6px;
}
.auth-dialog .auth-field--verified > img {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
}
.auth-dialog .auth-badge {
    flex: 0 0 auto;
    margin-left: auto;
    padding: 4px 8px;
    background: #DCFCE7;
    border-radius: 4px;
    font: 600 11px/13px Inter, sans-serif;
    color: #15803D;
    white-space: nowrap;
}

/* ---------- Кнопки ---------- */
.auth-dialog .auth-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    height: 52px;
    margin: 0;
    padding: 0 24px;
    border: 0;
    border-radius: 12px;
    font: 500 16px/1 Inter, sans-serif;
    color: #FFFFFF;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}
.auth-dialog .auth-btn--primary {
    background: #EA0000;
    color: #FFFFFF;
}
.auth-dialog .auth-btn--secondary {
    background: #E0E0E0;
    color: #333333;
}
.auth-dialog .auth-btn--dark {
    height: 42px;
    padding: 0 24px;
    border-radius: 8px;
    background: #343434;
    color: #FFFFFF;
    font: 600 14px/1 Inter, sans-serif;
}
.auth-dialog .auth-btn--block {
    width: 100%;
}
.auth-dialog .auth-forgot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font: 400 12px/1.2 Inter, sans-serif;
    color: #6B7280;
    text-decoration: none;
}
.auth-dialog .auth-forgot img {
    flex: 0 0 15px;
    display: block;
    width: 15px;
    height: 15px;
}

/* ---------- Табы Физлицо / Юрлицо ---------- */
.auth-dialog .auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    box-sizing: border-box;
    width: 100%;
    height: 36px;
    margin: 4px 0;
    padding: 3px;
    background: #F4F5F7;
    border-radius: 10px;
}
.auth-dialog .auth-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font: 500 13px/1 Inter, sans-serif;
    color: #6B7280;
    cursor: pointer;
}
.auth-dialog .auth-tab.active {
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    color: #111827;
}

/* ---------- Подтверждение кода ---------- */
.auth-dialog .auth-code {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.auth-dialog .auth-code__fields {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.auth-dialog .auth-code__fields > .auth-field {
    flex: 1 1 0;
    min-width: 0;
}
.auth-dialog .auth-code__fields > .auth-btn {
    flex: 0 0 144px;
    width: 144px;
}
.auth-dialog .auth-code__fields + .auth-hint {
    margin-top: 7px;
}
.auth-dialog .auth-hint,
.auth-dialog .auth-attempts {
    margin: 0;
    font: 400 12px/1.2 Inter, sans-serif;
    color: #6B7280;
}
.auth-dialog .auth-code .auth-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    font-size: 13px;
}
.auth-dialog .auth-code .auth-error > img {
    flex: 0 0 14px;
    width: 14px;
    height: 14px;
}

/* ---------- Превышено число попыток ---------- */
.auth-dialog .auth-blocked {
    margin: 0;
    font: 400 13px/1.2 Inter, sans-serif;
    color: #EF4444;
}
.auth-dialog .auth-blocked__timer {
    display: block;
    margin-top: 4px;
    font: 600 24px/1.2 Inter, sans-serif;
    color: #374151;
}

/* ---------- Согласие ---------- */
.auth-dialog .auth-agree {
    margin: 0;
    font: 400 12px/1.2 Inter, sans-serif;
    color: #9CA3AF;
}
.auth-dialog .auth-agree a {
    color: #2A2A2A;
    text-decoration: underline;
}

/* ---------- Карточка компании (юрлицо) ---------- */
.auth-dialog .auth-company {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 0;
    align-items: start;
}
.auth-dialog .auth-company__avatar {
    grid-row: 1 / span 2;
    align-self: center;
    display: flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #F0F4FF;
    font: 700 14px/1 Inter, sans-serif;
    color: #3B5BDB;
}
.auth-dialog .auth-company__info {
    display: contents;
}
.auth-dialog .auth-company__name {
    grid-row: 1;
    grid-column: 2;
    margin: 0;
    font: 600 15px/18px Inter, sans-serif;
    color: #111827;
}
.auth-dialog .auth-company__verified {
    grid-row: 2;
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font: 400 11px/1.2 Inter, sans-serif;
    color: #16A34A;
}
.auth-dialog .auth-company__ok {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.auth-dialog .auth-company__ok::before {
    content: "";
    width: 12px;
    height: 12px;
    background: url("../../img/auth/check.svg") center / 12px no-repeat;
}
.auth-dialog .auth-company__dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #9CA3AF;
}
.auth-dialog .auth-company__opf {
    padding: 4px 8px;
    border-radius: 999px;
    background: #F3F4F6;
    font: 600 11px/13px Inter, sans-serif;
    color: #6B7280;
}
.auth-dialog .auth-company__reqs {
    grid-row: 3;
    grid-column: 1 / -1;
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px 32px;
}
.auth-dialog .auth-company__req {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.auth-dialog .auth-company__req--wide {
    flex-basis: 100%;
}
.auth-dialog .auth-company__label {
    font: 600 10px/1.2 Inter, sans-serif;
    letter-spacing: 0.6px;
    color: #9CA3AF;
}
.auth-dialog .auth-company__value {
    font: 500 13px/16px Inter, sans-serif;
    color: #374151;
}

/* ---------- Финальные экраны ---------- */
.auth-dialog .auth-final {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.auth-dialog .auth-final__picture {
    position: absolute;
    top: -48px;
    left: 0;
    z-index: 0;
    display: block;
    pointer-events: none;
}

/* ---------- Адаптив ---------- */
@media (max-width: 575.98px) {
    .auth-dialog {
        width: calc(100% - 16px);
        max-width: none;
        margin: 8px;
    }
    .auth-dialog .modal-content {
        padding: 32px 16px 24px;
        border-radius: 20px;
    }
    .auth-dialog .auth-dialog__title {
        font-size: 24px;
    }
    .auth-dialog .auth-code__fields {
        flex-direction: column;
        align-items: stretch;
    }
    .auth-dialog .auth-code__fields > .auth-field,
    .auth-dialog .auth-code__fields > .auth-btn {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* ---------- Уточнения после сверки ---------- */
.auth-dialog .auth-btn--primary,
.auth-dialog .auth-btn--secondary {
    width: 100%;
}
.auth-dialog .auth-field--verified:focus-within {
    border-color: #16A34A;
}
@media (max-width: 575.98px) {
    /* крестик (top 16, 24px) не должен наезжать на длинный заголовок */
    .auth-dialog .auth-dialog__head {
        padding-right: 24px;
    }
}

/* ---------- Код: скрытые ошибки, строки, ссылки ---------- */
.auth-dialog .auth-code {
    margin-bottom: 0;
}
.auth-dialog .auth-code .auth-error.hidden,
.auth-dialog .auth-error[hidden] {
    display: none;
}
.auth-dialog .auth-code__line {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.auth-dialog .auth-hint .rs-verify-refresh-code {
    font-size: 12px;
    color: #2A2A2A;
    text-decoration: underline;
    cursor: pointer;
}
.auth-dialog a.rs-verify-reset {
    align-self: flex-start;
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Карточка компании: кнопка "Изменить" ---------- */
.auth-dialog .auth-company__change {
    grid-row: 1;
    grid-column: 3;
    flex: 0 0 auto;
    margin-left: auto;
    padding: 0;
    border: 0;
    background: none;
    font: 600 13px/1.2 Inter, sans-serif;
    color: #3B5BDB;
    cursor: pointer;
}

/* ---------- Подсказки ИНН (выпадающий список) ---------- */
.auth-dialog .auth-inn__dropdown {
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    background: #FFFFFF;
}
.auth-dialog .auth-inn__item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid #F3F4F6;
    background: none;
    text-align: left;
    cursor: pointer;
}
.auth-dialog .auth-inn__item:last-child {
    border-bottom: 0;
}
.auth-dialog .auth-inn__item:hover {
    background: #F9FAFB;
}
.auth-dialog .auth-inn__item--disabled {
    cursor: default;
    color: #9CA3AF;
    font: 400 12px/1.3 Inter, sans-serif;
}
.auth-dialog .auth-inn__item--disabled:hover {
    background: none;
}
.auth-dialog .auth-inn__name {
    font: 600 14px/1.3 Inter, sans-serif;
    color: #111827;
}
.auth-dialog .auth-inn__meta {
    font: 400 12px/1.3 Inter, sans-serif;
    color: #6B7280;
}

/* Ошибка поля телефона, которую выводит ядро (.invalid-feedback) */
.auth-dialog .invalid-feedback {
    margin: 4px 0 0;
    font: 400 14px/1.2 Inter, sans-serif;
    color: #EF4444;
}

/* ---------- Восстановление: текст и поле (этап 5) ---------- */
.auth-dialog .auth-recover {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

/* ---------- Сверка с макетом 12.11 ---------- */

/* Фон окна: только для окон auth */
body:has(.modal.show .auth-dialog) .modal-backdrop.show {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Регистрация: padding 40px (на мобилке не меняется) */
@media (min-width: 576px) {
    .auth-dialog--form .modal-content {
        padding: 40px;
    }
}

/* Финальные экраны */
.auth-dialog--final .modal-content {
    padding: 93px 40px 40px;
}
.auth-dialog--final .modal-body {
    gap: 24px;
}
.auth-dialog--final .auth-dialog__head {
    position: relative;
    z-index: 1;
}

/* Заполненное поле контакта на шаге пароля */
.auth-dialog .auth-field--filled {
    border-color: #191919;
}

/* Подтверждённый номер: поле ввода */
.auth-dialog .auth-field--verified input {
    flex: 0 1 auto;
    color: #111827;
    field-sizing: content;
}

/* Подсказки и строки внутри .auth-code__line */
.auth-dialog .auth-hint {
    line-height: normal;
}
.auth-dialog .auth-code__line .auth-hint {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}
.auth-dialog .auth-code__line .auth-hint:empty {
    display: none;
}
.auth-dialog .auth-code__line > .auth-field + .auth-hint {
    margin-top: 7px;
}
.auth-dialog .auth-code__line > .auth-hint:first-child {
    margin-bottom: 7px;
}

/* Неверный код: попытки и кнопка */
.auth-dialog .auth-code__line > .auth-attempts {
    margin-top: 4px;
}
.auth-dialog .auth-code__line > .auth-btn {
    margin-top: 7px;
}

/* Блокировка */
.auth-dialog .auth-code__line > .auth-blocked {
    margin-top: 7px;
}
.auth-dialog .auth-btn[disabled] {
    opacity: 0.5;
    cursor: default;
}

/* «Запросить новый код» во время таймера: видна, но неактивна */
.auth-dialog .auth-code__line.rs-wait > .auth-btn.rs-verify-refresh-code {
    display: inline-flex;
    opacity: 0.5;
    pointer-events: none;
}

/* Согласие под кнопкой */
.auth-dialog .auth-agree .policy-agreement {
    margin: 0;
}
.auth-dialog .auth-agree .policy-agreement-wrapper {
    gap: 8px !important;
    align-items: flex-start;
}
.auth-dialog .auth-agree input[name="agree_with_data_policy"] {
    appearance: none;
    flex: 0 0 16px;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    border: 1px solid #D1D5DB;
    border-radius: 4px;
    background: #FFFFFF;
    cursor: pointer;
}
.auth-dialog .auth-agree input[name="agree_with_data_policy"]:checked {
    background: #EA0000 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23FFFFFF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center no-repeat;
    border-color: #EA0000;
}
.auth-dialog .auth-agree input[name="agree_with_data_policy"]:focus-visible {
    outline: 2px solid #191919;
    outline-offset: 2px;
}

/* Мобилка: финальные экраны (padding-top 93px сохраняется, бока 16px) */
@media (max-width: 575.98px) {
    .auth-dialog--final .modal-content {
        padding: 93px 16px 24px;
    }
    .auth-dialog .auth-final__picture {
        left: 16px;
        max-width: calc(100% - 32px);
    }
}

/* Кнопка "Забыли пароль ?" на входе по телефону: сброс рамки и фона браузера. Шрифт не сбрасываем, он задан в .auth-forgot выше */
.auth-dialog button.auth-forgot {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}
