/* ===== SIDEBAR OPTIMIZED STYLES ===== */
:root {
    --sidebar-width: 264px;
    --sidebar-transition: all 0.35s ease-in-out;
    --sidebar-shadow: 0 0 35px 0 rgba(49, 57, 66, 0.5);
    --sidebar-border-radius: 0.375rem;
    --sidebar-item-spacing: 0.5rem;
}

/* Layout skeleton */
.wrapper {
    align-items: stretch;
    display: flex;
    width: 100%;
}

#sidebar {
    max-width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    transition: var(--sidebar-transition);
    box-shadow: var(--sidebar-shadow);
    z-index: 1111;
    background-color: var(--bs-body-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
}

/* Sidebar collapse */
#sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    overflow: hidden;
    transition: var(--sidebar-transition);
}

/* Sidebar logo */
.sidebar-logo {
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
}

.sidebar-logo a {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bs-body-color) !important;
    transition: color 0.2s ease;
}

.sidebar-logo a:hover {
    color: var(--bs-primary) !important;
}

/* Sidebar navigation */
.sidebar-nav {
    padding: 0;
    margin: 0;
    list-style: none;
    flex: 1;
    overflow: hidden;
}

.sidebar-header {
    padding: 0.75rem 1.5rem;
    margin: 0;
    cursor: pointer;
    font-weight: 600;
    color: var(--bs-body-color);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header:hover {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-primary);
}

.sidebar-header[data-bs-toggle="collapse"] {
    border-bottom-color: var(--bs-primary);
}

.sidebar-header[data-bs-toggle="collapse"].collapsed {
    border-bottom-color: transparent;
}

/* Sidebar dropdown */
.sidebar-dropdown {
    background-color: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.sidebar-dropdown .sidebar-item {
    margin: 0;
}

/* Sidebar links */
.sidebar-link {
    padding: 0.625rem 1.5rem;
    color: var(--bs-body-color) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    position: relative;
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.sidebar-link:hover {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-primary) !important;
    transform: translateX(4px);
}

.sidebar-link.active {
    background-color: var(--bs-primary);
    color: white !important;
}

.sidebar-link[data-bs-toggle="collapse"]::after {
    border: solid;
    border-width: 0 0.075rem 0.075rem 0;
    content: "";
    display: inline-block;
    padding: 2px;
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    transition: var(--sidebar-transition);
}

.sidebar-link[data-bs-toggle="collapse"].collapsed::after {
    transform: translateY(-50%) rotate(-135deg);
}

/* Nested sidebar items */
.sidebar-dropdown .sidebar-link {
    padding-left: 2.5rem;
    font-size: 0.9em;
}

.sidebar-dropdown .sidebar-dropdown .sidebar-link {
    padding-left: 3.5rem;
}

/* Sidebar footer */
.sidebar-footer {
    background-color: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    margin-top: auto;
}

.sidebar-footer .sidebar-nav {
    flex: none;
}

.sidebar-footer .sidebar-link {
    padding: 0.75rem 1.5rem;
    margin: 0;
    border-radius: 0;
}

.sidebar-footer .sidebar-link:hover {
    background-color: var(--bs-secondary-bg);
    transform: none;
}

/* Dropdown in sidebar footer */
.sidebar-footer .dropdown-toggle::after {
    display: none;
}

.sidebar-footer .dropup .dropdown-menu {
    position: fixed !important;
    bottom: 70px !important; /* Расстояние от нижнего края */
    left: 20px !important;
    right: auto !important;
    top: auto !important;
    width: 200px !important;
    margin: 0 !important;
    transform: none !important;
    z-index: 9999;
}

/* Убедимся, что меню не скрывается */
.sidebar-footer .dropup .dropdown-menu.show {
    display: block !important;
}

/* Анимация появления */
.sidebar-footer .dropup .dropdown-menu {
    animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sidebar-footer .dropdown-item {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-footer .dropdown-item.active {
    background-color: var(--bs-primary);
    color: white;
}

.sidebar-footer .dropdown-item .bi-check2 {
    font-size: 0.875rem;
    margin-left: auto;
}

/* Scrollbar styling for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: var(--bs-secondary-bg);
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 2px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--bs-primary);
}

/* Responsive design */
@media (max-width: 767.98px) {
    #sidebar {
        position: fixed;
        height: 100vh;
    }
    
    .main {
        margin-left: 0;
    }
    
    #sidebar:not(.collapsed) + .main::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1110;
    }
}

/* Icon alignment */
.bi::before,
[class*=" bi-"]::before,
[class^="bi-"]::before {
    vertical-align: -0.2em;
    width: 1em;
    text-align: center;
}

/* ===== REST OF YOUR EXISTING STYLES ===== */
/* (Keep your existing styles below this line, they will work alongside the optimized sidebar styles) */

.content {
    flex: 1;
    max-width: 100vw;
    width: 100vw;
}

@media (min-width: 768px) {
    .content {
        width: auto;
    }
}

.popover {
    max-width: 600px;
}

.imagePreview {
    width: 100%;
    height: 100px;
    background-position: center center;
    background-color: #fff;
    background-size: contain;
    background-repeat: no-repeat;
    display: inline-block;
    border: 1px solid var(--bs-border-color);
}

.avatar-list {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.w-95 {
    width: 95px;
}

textarea {
    resize: both;
}

.cursor-pointer {
    cursor: pointer;
}

.form-control,
.input-group-text,
.input-group button {
    margin-top: -1px;
}

.kanban-column {
    max-height: calc(100vh - 150px);
    min-height: calc(100vh - 150px);
    overflow-y: auto;
    position: relative;
    overflow-x: hidden !important;
}

.kanban-column::-webkit-scrollbar {
    width: 5px;
    background: var(--bs-secondary-bg-subtle);
}

.kanban-column::-webkit-scrollbar-thumb {
    background-color: #797979;
    border-radius: 6px;
    transition: background-color 0.3s;
}

div.kanban-card.dragging {
    opacity: .5;
    transform: scale(.8);
}

div.kanban-column.drop {
    background-color: var(--bs-tertiary-bg);
}

#mobile-kanban-menu {
    font-size: 0.9em;
}

.kanban-card .info {
    color: var(--bs-gray);
}

.sortable-ghost {
    border: 1px solid var(--bs-border-color);
    background-color: var(--bs-secondary-bg);
}

.kanban-placeholder {
    height: 100px;
    opacity: 0;
    margin: 10px;
    position: absolute;
    width: calc(100% - 20px);
}

td.clickable-cell:hover {
    background-color: var(--bs-secondary-bg) !important;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

table.dataTable td {
    border-left: 3px solid transparent;
    transition: border-color 0.3s ease;
    position: relative;
}

table.dataTable td:not(:first-child) {
    padding-left: 13px !important;
}

.navbar-expand .navbar-toggler {
    display: block !important;
    border: none;
}




/* ===== DISABLE LINK STYLES IN FORMS AND DATATABLES ===== */

/* Отключаем стили ссылок внутри форм */
form a,
form a:hover,
form a:focus,
form a:active {
    text-decoration: none !important;
    color: inherit !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Отключаем стили ссылок внутри таблиц DataTables */
table.dataTable a,
table.dataTable a:hover,
table.dataTable a:focus,
table.dataTable a:active {
    text-decoration: none !important;
    color: inherit !important;
    background-color: transparent !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Особые случаи для кнопок-ссылок в таблицах */
table.dataTable a.btn,
table.dataTable a.btn:hover,
table.dataTable a.btn:focus,
table.dataTable a.btn:active {
    color: var(--bs-btn-color) !important;
    background-color: var(--bs-btn-bg) !important;
    border-color: var(--bs-btn-border-color) !important;
}

/* Для ссылок в модальных окнах */
.modal a,
.modal a:hover,
.modal a:focus,
.modal a:active {
    text-decoration: none !important;
    color: inherit !important;
}

/* Для ссылок в карточках (кроме заголовков) */
.card:not(.card-header) a,
.card:not(.card-header) a:hover,
.card:not(.card-header) a:focus,
.card:not(.card-header) a:active {
    text-decoration: none !important;
    color: inherit !important;
}

/* Сохраняем стили для навигационных элементов */
.nav a,
.navbar a,
.pagination a,
.breadcrumb a {
    text-decoration: none !important;
}

/* Исключения для явно стилизованных ссылок */
a.btn,
a.dropdown-item,
a.nav-link,
a.list-group-item {
    /* Сохраняем стандартное поведение для элементов UI */
    text-decoration: none !important;
}

/* Для ячеек таблиц с кликабельными ссылтами */
table.dataTable td.clickable-cell a,
table.dataTable td.clickable-cell a:hover {
    color: inherit !important;
    text-decoration: none !important;
}

/* Отключаем синее выделение при клике на мобильных устройствах */
a {
    -webkit-tap-highlight-color: transparent !important;
    tap-highlight-color: transparent !important;
}

/* Сохраняем pointer для кликабельных элементов */
table.dataTable a,
form a {
    cursor: pointer !important;
}