/* ==========================================================================
   ROERICH PEAK ARCHITECTURE - REGULAR UI MODALS
   File: static/css/components/modal.css
   ========================================================================== */

/* 1. БЛОКИРОВКА СКРОЛЛА СТРАНИЦЫ */
body.roerich-modal-open {
    overflow: hidden !important;
    touch-action: none;
}

/* 2. ОВЕРЛЕЙ ОБЫЧНЫХ МОДАЛОК (z-index: 10000) */
.roerich-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(10, 17, 40, 0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    padding: 1rem;
    box-sizing: border-box;
}

.roerich-modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* 3. КАРТОЧКА МОДАЛКИ (АРТЕФАКТ) */
.roerich-modal-overlay .roerich-modal-artifact {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(243, 240, 223, 0.9));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: var(--radius-lg, 1.5rem);
    box-shadow: var(--elevation-layer-4);
    padding: 1.75rem;
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 🔥 ДОБАВИТЬ ЭТУ СТРОКУ */
    transform: scale(0.92) translateY(15px);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.roerich-modal-overlay.active .roerich-modal-artifact {
    transform: scale(1) translateY(0);
}

/* 4. ШАПКА МОДАЛКИ */
.roerich-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 0.85rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid rgba(0, 80, 136, 0.1);
    flex-shrink: 0;
}

.roerich-modal-title {
    font-family: var(--font-majestic);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--color-roerich-ultramarine);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.roerich-modal-close {
    background: rgba(0, 80, 136, 0.05);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-abyss-ink);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    flex-shrink: 0;
}

.roerich-modal-close:hover {
    background: rgba(200, 55, 55, 0.1);
    color: var(--color-cinnabar-red);
}

/* 5. ВНУТРЕННИЙ СКРОЛЛ КОНТЕНТА */
.roerich-modal-body {
    overflow-y: auto;
    flex-grow: 1;
    min-height: 0; /* 🔥 ДОБАВИТЬ ЭТУ СТРОКУ (Критично для Flexbox) */
    padding-right: 0.25rem;
    margin-bottom: 1.25rem;
}

.roerich-modal-body::-webkit-scrollbar {
    width: 4px;
}
.roerich-modal-body::-webkit-scrollbar-thumb {
    background: rgba(0, 80, 136, 0.2);
    border-radius: 4px;
}

/* 6. ПАНЕЛЬ ДЕЙСТВИЙ (Кнопки) */
.roerich-modal-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 80, 136, 0.1);
}

/* 7. ТАБЫ СОРТИРОВКИ */
.roerich-modal-tabs {
    display: flex;
    background: rgba(0, 80, 136, 0.05);
    border-radius: var(--radius-md, 0.75rem);
    padding: 3px;
    gap: 3px;
    width: 100%;
    box-sizing: border-box;
}

.roerich-tab-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius-md, 0.75rem) - 2px);
    font-family: var(--font-utility);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--color-roerich-ultramarine);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.roerich-tab-btn.active {
    background: var(--color-snow-summit);
    color: var(--color-fiery-orange);
    box-shadow: var(--elevation-layer-1);
}

/* 8. ЧЕКБОКС-СЛАЙДЕР (Для телефона) */
.roerich-switch-card {
    background: rgba(0, 80, 136, 0.04);
    border: 1px solid rgba(0, 80, 136, 0.08);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    cursor: pointer;
    user-select: none;
    width: 100%;
}

.switch-input { display: none; }

.switch-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: rgba(10, 17, 40, 0.2);
    border-radius: 50px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.switch-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #ffffff;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch-input:checked + .switch-slider {
    background: var(--color-fiery-orange);
}

.switch-input:checked + .switch-slider::before {
    transform: translateX(20px);
}

/* Спец-подгонка TomSelect внутри модалок */
.roerich-modal-body .roerich-form-group {
    margin-bottom: 0 !important;
}

.roerich-modal-body .ts-wrapper.roerich-select-ts .ts-control {
    background: rgba(0, 80, 136, 0.04) !important;
    border-radius: var(--radius-sm) !important;
}

@media (max-width: 640px) {
    .roerich-modal-overlay .roerich-modal-artifact {
        padding: 1.25rem;
        max-height: 90vh;
    }
}
.roerich-modal-artifact > form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    margin: 0;
}