/* Ordo Scriptorum - Custom Styles */

/* --- Variables --- */
:root {
    --bs-primary-rgb: 108, 92, 231; /* #6c5ce7 */
    --bs-secondary-rgb: 108, 117, 125; /* #6c757d */
    --bs-success-rgb: 28, 200, 138;   /* #1cc88a */
    --bs-info-rgb: 54, 185, 204;    /* #36b9cc */
    --bs-warning-rgb: 246, 194, 62;   /* #f6c23e */
    --bs-danger-rgb: 231, 74, 59;     /* #e74a3b */
    --bs-light-rgb: 248, 249, 252;   /* #f8f9fc */
    --bs-dark-rgb: 90, 92, 105;     /* #5a5c69 */

    --sidebar-width: 240px;
    --sidebar-collapsed-width: 90px; /* Немного шире для иконок + текста */
    --sidebar-bg: #4e73df; /* Основной цвет SB Admin */
    --sidebar-link-color: rgba(255, 255, 255, 0.8);
    --sidebar-link-hover-color: #ffffff;
    --sidebar-link-active-color: #ffffff;
    --sidebar-link-active-bg: rgba(255, 255, 255, 0.1);
    --content-bg: #f8f9fc;
}

body {
    font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    font-size: 0.9rem;
    background-color: var(--content-bg);
    color: #5a5c69;
}

/* --- Sidebar Styles --- */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-link-color);
    position: fixed; /* Используем fixed для прилипания */
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030; /* Выше чем navbar */
    transition: width 0.3s ease, left 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.active {
    width: var(--sidebar-collapsed-width);
}
.sidebar.active .sidebar-text {
    display: none;
}
.sidebar.active .sidebar-header h3 {
    font-size: 1.5rem; /* Показывать только иконку */
}
.sidebar.active .sidebar-header h3 .sidebar-text { display: none; }
.sidebar.active .dropdown-toggle::after { display: none; }

.sidebar .sidebar-header {
    padding: 1.2rem 1rem;
    text-align: center;
    background-color: rgba(0,0,0,0.1);
}
.sidebar .sidebar-header h3 {
    color: #fff;
    margin-bottom: 0;
    white-space: nowrap; /* Предотвращаем перенос текста */
}
.sidebar .sidebar-header h3 i {
    font-size: 1.5rem;
}

.sidebar ul.components {
    padding: 10px 0;
}

.sidebar ul li a {
    padding: 10px 1.5rem; /* Отступы */
    display: block;
    color: var(--sidebar-link-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap; /* Предотвращаем перенос */
}
.sidebar ul li a:hover {
    color: var(--sidebar-link-hover-color);
    background-color: var(--sidebar-link-active-bg);
}
.sidebar ul li.active > a {
    color: var(--sidebar-link-active-color);
    background-color: var(--sidebar-link-active-bg);
    font-weight: 600;
}

.sidebar ul li a i.fa-fw {
    margin-right: 0.75rem;
    width: 1.2em; /* Выравниваем иконки */
    text-align: center;
}

.sidebar ul ul { /* Стили для подменю */
    background-color: rgba(0,0,0,0.1);
    padding-left: 0; /* Убираем стандартный отступ */
}
.sidebar ul ul a {
    padding: 8px 1.5rem 8px 3.2rem; /* Доп. отступ для вложенности */
    font-size: 0.85rem;
    color: var(--sidebar-link-color);
}
.sidebar ul ul a:hover,
.sidebar ul ul li.active > a {
    background-color: rgba(255,255,255,0.15);
    color: #fff;
}

.sidebar .dropdown-toggle::after {
    display: inline-block;
    margin-left: auto; /* Двигаем стрелку вправо */
    vertical-align: .255em;
    content: "";
    border-top: .3em solid;
    border-right: .3em solid transparent;
    border-bottom: 0;
    border-left: .3em solid transparent;
    transition: transform .2s ease-in-out;
}
.sidebar .dropdown-toggle[aria-expanded="true"]::after {
     transform: rotate(-180deg);
}

/* Стили для свернутого сайдбара */
.sidebar.active ul li a {
    padding: 12px 1rem;
    text-align: center;
}
.sidebar.active ul li a i.fa-fw {
    margin-right: 0;
    display: block;
    margin-bottom: 0.3rem; /* Отступ между иконкой и текстом (если будет) */
    font-size: 1.1rem;
}
.sidebar.active ul ul {
    position: absolute; /* Выпадающее меню */
    left: var(--sidebar-collapsed-width);
    background-color: var(--sidebar-bg);
    border: 1px solid rgba(0,0,0,0.2);
    border-radius: 0 .25rem .25rem 0;
    box-shadow: 0 .5rem 1rem rgba(0,0,0,.15);
    min-width: 180px; /* Ширина выпадающего меню */
    display: none; /* Скрыто по умолчанию */
    z-index: 1031; /* Выше контента */
}
.sidebar.active ul li:hover > ul {
    display: block; /* Показываем при наведении на родительский li */
}
.sidebar.active ul ul a {
    padding: 8px 1rem;
    text-align: left;
}

.sidebar .sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* --- Content Wrapper --- */
.content-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
    min-height: 100vh; /* Чтобы футер был внизу */
    display: flex;
    flex-direction: column;
}
.sidebar.active + .content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* --- Navbar --- */
.navbar { z-index: 1029; } /* Ниже сайдбара */

/* --- Main Content Area --- */
.main-content {
    flex-grow: 1; /* Занимает все доступное пространство */
}

/* --- Footer --- */
.footer {
    font-size: 0.8rem;
}

/* --- Bootstrap Component Overrides & Helpers --- */
.card-header {
    background-color: #f8f9fc;
    border-bottom: 1px solid #e3e6f0;
}
.card {
    border: 1px solid #e3e6f0;
    border-radius: .35rem;
}
.shadow-sm { box-shadow: 0 .125rem .25rem rgba(0,0,0,.075)!important; }

/* Кнопки с иконками */
.btn-icon-split { padding: 0; display: inline-flex; align-items: stretch; }
.btn-icon-split .icon { padding: .375rem .75rem; background-color: rgba(0,0,0,0.1); line-height: 1.5; }
.btn-icon-split .text { padding: .375rem .75rem; line-height: 1.5; }
.btn-sm .icon { padding: .25rem .5rem; }
.btn-sm .text { padding: .25rem .5rem; }

/* Маленькие заголовки и текст форм */
.form-label-sm { font-size: .75rem; margin-bottom: .2rem; color: #858796; font-weight: 700; }
.form-control-sm, .form-select-sm { font-size: .8rem; }
.form-text { font-size: .75rem; }

/* Улучшение Select2 */
.select2-container--bootstrap-5 .select2-selection--multiple { font-size: .8rem; min-height: calc(1.5em + .5rem + 2px); }
.select2-container--bootstrap-5 .select2-selection--single { font-size: .8rem; height: calc(1.5em + .5rem + 2px); }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { padding-left: .5rem; }
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow { height: calc(1.5em + .5rem); }

/* --- Адаптивность --- */
@media (max-width: 768px) {
    .sidebar {
        left: calc(-1 * var(--sidebar-width)); /* Скрыт за экраном */
        width: var(--sidebar-width); /* Полная ширина при открытии */
    }
    .sidebar.active {
        left: 0; /* Показываем */
        width: var(--sidebar-width); /* Остается полной ширины */
    }
     .sidebar.active .sidebar-text { display: inline-block; } /* Текст виден в мобильной версии */
     .sidebar.active ul li a i.fa-fw { display: inline-block; margin-bottom: 0; font-size: inherit; } /* Иконки не увеличиваются */
     .sidebar.active ul ul { position: static; background-color: rgba(0,0,0,0.1); border: none; box-shadow: none; min-width: auto; display: block !important; } /* Подменю всегда видно */
     .sidebar.active ul ul a { padding-left: 3.2rem !important; text-align: left; }


    .content-wrapper {
        margin-left: 0;
        width: 100%;
    }
    /* При открытом сайдбаре контент не сдвигается (сайдбар поверх) */
}