/* ============================================================
   Модальные окна — компонент Components/Ui/Modal.razor и модуль js/modal.js.

   Значения сведены из Bootstrap 5.1 (.modal-*) и наших прежних переопределений в Commands.css,
   так что окно выглядит и стоит на странице так же, как при Bootstrap. Отличия намеренные:
   - подложка — фон самого окна, а не отдельный элемент в body: появляется и гаснет плавно,
     вместе с окном, а не рывком через 150 мс после него;
   - видимостью управляет js атрибутами data-shown и data-open. Blazor эти атрибуты не рисует
     и при перерисовке не трогает.
   ============================================================ */

.tb-modal {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1055;
    display: none;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    outline: 0;
    /* Прежняя подложка: blackAlpha-600 с opacity .5 от Bootstrap — итоговые 24% чёрного. */
    background-color: rgba(0, 0, 0, 0.24);
    opacity: 0;
    transition: opacity 0.15s linear;
    /* Колесо у края длинного окна не должно листать страницу под ним. */
    overscroll-behavior: contain;
}

.tb-modal[data-shown] {
    display: block;
}

.tb-modal[data-open] {
    opacity: 1;
}

.tb-modal-dialog {
    position: relative;
    display: flex;
    align-items: center;
    width: auto;
    min-height: calc(100% - 1rem);
    margin: 0.5rem;
    /* Поля вокруг окна пропускают клик к подложке — так работает «клик мимо». */
    pointer-events: none;
    animation: scaleOut 0.2s forwards;
}

.tb-modal[data-open] .tb-modal-dialog {
    animation: scaleIn 0.2s forwards;
}

/* Длинное окно, у которого прокручивается тело, а шапка и подвал стоят на месте. */
.tb-modal-dialog-scrollable {
    height: calc(100% - 1rem);
}

.tb-modal-dialog-scrollable .tb-modal-content {
    max-height: 100%;
    overflow: hidden;
}

.tb-modal-dialog-scrollable .tb-modal-body {
    overflow-y: auto;
}

@media (min-width: 576px) {
    .tb-modal-dialog {
        max-width: 500px;
        min-height: calc(100% - 3.5rem);
        margin: 1.75rem auto;
    }

    .tb-modal-dialog-scrollable {
        height: calc(100% - 3.5rem);
    }
}

.tb-modal-content {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 32rem;
    pointer-events: auto;
    color: inherit;
    background-color: var(--container-bg);
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    outline: transparent solid 2px;
    outline-offset: 2px;
    box-shadow: rgba(0, 0, 0, 0.1) 0 0 0 1px, rgba(0, 0, 0, 0.2) 0 5px 10px, rgba(0, 0, 0, 0.4) 0 15px 40px;
}

.tb-modal-header {
    display: flex;
    flex: 0 1 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    border-top-left-radius: calc(0.3rem - 1px);
    border-top-right-radius: calc(0.3rem - 1px);
    font-size: 1.25rem;
    font-weight: 600;
}

/* Заголовок h5 в окнах заказа и плейлиста — прежний .modal-title. */
.tb-modal-title {
    margin-bottom: 0;
    line-height: 1.5;
}

.tb-modal-body {
    position: relative;
    flex: 1 1 auto;
    padding: 1.5rem;
}

.tb-modal-footer {
    display: flex;
    flex-wrap: wrap;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    border-bottom-right-radius: calc(0.3rem - 1px);
    border-bottom-left-radius: calc(0.3rem - 1px);
}

.tb-modal-footer > * {
    margin: 0.25rem;
}

/* В окне плашка модератора идёт в обычном потоке после текста. На странице она — блок
   flex-контейнера, и отступ даёт его gap. */
.tb-modal-body .mod-warning {
    margin-top: var(--tearinbot-space-4);
}

/* ---------- содержимое окон ----------
   Вместо bootstrap-овских утилит (mb-3, mt-2, small, d-flex…) — классы по роли блока, значения
   прежние. */

/* Поле формы и отступ под ним (было form-group mb-3). */
.modal-field {
    margin-bottom: 1rem;
}

/* Подпись слева, переключатель справа — «Включена» в окнах наград. */
.modal-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.modal-switch-row .form-label {
    margin-bottom: 0;
}

/* Образцы цвета награды. */
.reward-colors {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: 340px;
}

/* Пояснение над содержимым окна: короткое и с отступом побольше. */
.modal-lead {
    margin-bottom: 0.5rem;
}

.modal-intro {
    margin-bottom: 1rem;
}

/* Сообщение сразу под полем: ошибка, подсказка, переменные. */
.modal-message {
    margin-top: 0.5rem;
}

/* Новый смысловой блок после предыдущего: подпись следующего поля, ошибка под формой. */
.modal-section {
    margin-top: 1rem;
}

.modal-small {
    font-size: 0.875em;
}

/* Мелкая подсказка под полем. */
.modal-hint {
    margin-top: 0.25rem;
    font-size: 0.875em;
}

/* Заметка с иконкой слева. */
.modal-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.875em;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes scaleOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@media (prefers-reduced-motion: reduce) {
    .tb-modal {
        transition: none;
    }

    .tb-modal-dialog,
    .tb-modal[data-open] .tb-modal-dialog {
        animation: none;
    }
}
