/* Shell: сайдбар fixed в sidebar.css — здесь смещение main и предотвращение «каши» таблиц/секций */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
}

/* Корневой flex: колонка слева занята сайдбаром (fixed), справа — основная */
.wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    width: 100%;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

.wrapper.sidebar-hidden .main-content {
    margin-left: 0;
}

/* Основная колонка: отступ под фиксированный сайдбар */
.main-content {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--sidebar-width, 220px);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Контент под navbar — растягивается и не вылезает за экран по ширине */
.content-wrapper {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    padding: 18px 20px 28px;
    overflow-x: auto;
}

/* Отступ между крупными блоками на странице (несколько table-card подряд) */
.content-wrapper > .table-card + .table-card,
.content-wrapper > .card + .card,
.content-wrapper > .row + .row.mt-4,
.content-wrapper .page-section + .page-section {
    margin-top: 1.5rem;
}

/* Таблицы: горизонтальная прокрутка, без обрезки первого столбца */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-card .table {
    margin-bottom: 0;
}

/* Карточка вокруг таблицы — не даём содержимому наезжать на соседние блоки из-за абсолютов */
.table-card {
    position: relative;
    clear: both;
}

/* Строка действий фильтров: обёртки на узком экране не ломают сетку */
.page-toolbar-row,
.toolbar-filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    width: 100%;
    margin-bottom: 12px;
}

/* Визуально как «filter-bar»: одна строка переключателей / быстрых действий без полей формы */
.page-toolbar-row.page-toolbar-row--bar {
    padding: 12px 14px;
    background: rgba(0, 20, 40, 0.35);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-sizing: border-box;
}
[data-theme="light"] .page-toolbar-row.page-toolbar-row--bar {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

@media (max-width: 767.98px) {
    .page-toolbar-row.partner-actions-line {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .page-toolbar-row.partner-actions-line > div {
        width: 100%;
        min-width: 0;
    }

    .page-toolbar-row.partner-actions-line select,
    .page-toolbar-row.partner-actions-line input.form-control,
    .page-toolbar-row.partner-actions-line .btn {
        width: 100%;
        max-width: none !important;
    }

    /* Перебиваем инлайн max-width из шаблона промо */
    .page-toolbar-row.partner-actions-line .btn.btn-warning {
        width: 100%;
        min-width: 0 !important;
    }
}

/* Мобильный: сайдбар выезжает поверх — полная ширина контента */
@media (max-width: 992px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .content-wrapper {
        padding: 14px 12px 24px;
    }
}

/* Chart.js: фиксированная высота — иначе при h-100 карточки и flex-grow канвас тянется на всю высоту колонки */
.dashboard-chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 280px;
    min-height: 260px;
    max-height: 360px;
    flex: 0 0 auto;
}

/* ---------- Диалоги: список + чат — min-height: 0 для прокрутки внутри flex ---------- */
.dialogs-shell {
    --dialogs-shell-offset: 152px;
    align-items: stretch !important;
    min-height: min(760px, calc(100vh - var(--dialogs-shell-offset)));
}
.dialogs-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.dialogs-split-card {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}
.dialogs-scroll-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.dialogs-messages-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    position: relative;
    -webkit-overflow-scrolling: touch;
}
/* Абсолютная кнопка «вниз» привязана к карточке */
.dialogs-chat-card {
    position: relative;
}
@media (max-width: 767.98px) {
    .dialogs-shell {
        min-height: 0;
    }
}

/* ---------- Задачи: кластер фильтров (display у ряда — .filter-bar в forms.css) ---------- */
.tasks-filter-toolbar .tasks-filter-cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
}
.tasks-filter-toolbar .tasks-new-btn {
    flex-shrink: 0;
}
@media (max-width: 767.98px) {
    .filter-bar.tasks-filter-toolbar .tasks-filter-cluster {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    .filter-bar.tasks-filter-toolbar select,
    .filter-bar.tasks-filter-toolbar .btn-group {
        width: 100%;
    }
    .filter-bar.tasks-filter-toolbar .btn-group .btn {
        flex: 1 1 auto;
    }
}
@media (max-width: 576px) {
    .tasks-filter-toolbar .tasks-new-btn {
        width: 100%;
    }
}

/* Календарь FullCalendar: убираем правый отступ у тела карточки */
.tasks-calendar-card-body {
    padding-right: 0;
}

/* Вспомогательный скролл для вложенных таблиц в настройках */
.table-scroll-sm {
    max-height: 280px;
    overflow-y: auto;
}
