/*
  ==========================================
  ГЛОБАЛЬНЫЕ СТИЛИ (применяются ко всему документу)
  ==========================================
*/

/* Основной шрифт для всего тела документа */
body {
    font-family: Verdana, Tahoma, Arial, sans-serif !important;
    overflow-y: hidden !important;
}

/* Шрифты для заголовков */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: "Trebuchet MS", Georgia, "Times New Roman", serif !important;
    scroll-padding-top: 30px !important;
}

.bodywrapper {
    height: calc(100vh - 30px) !important;
    overflow-y: auto !important;
}


/* Шрифты для навигации, футера и сайдбара */
.sphinxsidebar,
.navigation,
.related,
.footer {
    font-family: Verdana, Tahoma, Arial, sans-serif !important;
}

/* Моноширинный шрифт для кода */
.highlight,
code,
pre,
.highlight pre {
    font-family: "Courier New", Courier, monospace !important;
}

/*
  ==========================================
  СТИЛИ ТЕМЫ (для экранов)
  ==========================================
*/

/* Закрепляем сайдбар и задаем его ширину */
.sphinxsidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 250px !important;
    display: flex;
    flex-direction: column;
}

/* Обертка для сайдбара - делаем flex-контейнером, чтобы распределить пространство */
.sphinxsidebarwrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
    /* margin: 12px; */
    /* Чтобы не было прокрутки у всей обертки */
}

/* Логотип и другие элементы выше оглавления должны оставаться без прокрутки */
/* Список оглавления должен занимать оставшееся пространство и иметь прокрутку */
.sphinxsidebarwrapper ul.current {
    flex-grow: 1;
    overflow-y: auto;
}

/* Стилизация полосы прокрутки для списка */
.sphinxsidebarwrapper ul.current::-webkit-scrollbar {
    width: 8px;
}

.sphinxsidebarwrapper ul.current::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sphinxsidebarwrapper ul.current::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.sphinxsidebarwrapper ul.current::-webkit-scrollbar-thumb:hover {
    background: #555;
}





/* Стилизация таблиц */
table.docutils thead th {
    background-color: #f2f2f2
        /*шапка таблицы*/
    ;
    color: black;
    padding: 10px;
    font-weight: bold;
}

table.docutils tbody tr td:first-child {
    background-color: #f2f2f2;
    /*боковик таблицы*/
    font-weight: bold;
}


/* Установка ширины основного контента */
.bodywrapper {
    margin-left: 250px !important;
    width: calc(100% - 250px) !important;
}

.document {
    width: calc(100% - 250px) !important;
}

.body {
    max-width: 1200px !important;
}

/*
  ==========================================
  Стиль для мобильного
  ==========================================
*/
@media screen and (max-width: 875px) {

    /* Сбрасываем позиционирование сайдбара */
    .sphinxsidebar {
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        float: none !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Сбрасываем обертки */
    .document,
    .documentwrapper,
    .bodywrapper {
        width: 100% !important;
        max-width: none !important;
        margin-left: 0 !important;
        display: block !important;
        float: none !important;
    }

    /* Основной контент - правильная ширина и переносы */
    .body {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 15px !important;
        box-sizing: border-box;
        overflow-wrap: break-word;
        word-wrap: break-word;
        word-break: normal;
        hyphens: auto;
    }

    /* Обеспечиваем правильное отображение текста */
    .body p,
    .body li,
    .body td,
    .body th {
        word-wrap: break-word;
        overflow-wrap: break-word;
        word-break: normal;
        hyphens: auto;
    }

    /* Код и преформатированный текст */
    .body pre,
    .body code {
        white-space: pre-wrap !important;
        word-wrap: break-word;
        max-width: 100%;
    }

    /* Таблицы адаптируются под мобильный экран */
    .body table {
        width: 100% !important;
        max-width: 100% !important;
        display: block;
        overflow-x: auto;
    }

    /* Убираем фиксированную высоту у списка в мобильной версии */
    .sphinxsidebarwrapper ul.current {
        max-height: none !important;
        height: auto !important;
    }
}

/*
  ==========================================
  СТИЛИ ДЛЯ ПЕЧАТИ
  ==========================================
*/
@media print {

    /* Скрываем сайдбар */
    .sphinxsidebar,
    .sphinxsidebarwrapper {
        display: none !important;
    }

    /* Сбрасываем стили для основного контента */
    .document,
    .bodywrapper,
    .body {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
        float: none !important;
    }

    /* Обеспечиваем, что блоки кода не обрезаются и переносятся */
    .highlight pre {
        overflow-x: visible !important;
        white-space: pre-wrap !important;
        word-wrap: break-word !important;
        max-width: 100% !important;
    }

    /* Общие настройки для печати */
    .body {
        font-size: 12pt;
        line-height: 1.4;
    }

    /* Убедимся, что изображения не выходят за границы */
    .body img {
        max-width: 100% !important;
        height: auto !important;
    }
}