/* ============================================================
   DESKTOP SIDEBAR — фиксированный слева 260px
   ============================================================ */

/* ===== Скрываем overlay и close-btn (только для mobile) ===== */
.sidebar-overlay,
.sidebar-close-btn {
    display: none !important;
}

/* ===== Сайдбар ===== */
.app-sidebar {
    position: fixed;
    top: 60px;
    left: 0;
    width: 260px;
    height: calc(100vh - 60px);
    background: #1a1a2e;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    z-index: 90;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Всегда открыт */
.app-sidebar.open {
    left: 0;
}

/* ===== ШАПКА САЙДБАРА ===== */
.sidebar-header {
    padding: 16px 18px 12px;
    border-bottom: 1px solid #2d2d44;
    flex-shrink: 0;
    position: relative;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.logo-icon {
    font-size: 22px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
}

.logo-version {
    font-size: 10px;
    color: #6B82F8;
    background: rgba(79, 107, 246, 0.15);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: auto;
}

/* ===== АВАТАРКА → SETTINGS ===== */
.sidebar-user-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
    border-radius: 10px;
    transition: background 0.2s ease;
    padding: 4px;
}

.sidebar-user-link:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2d2d44;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 12px;
    color: #94A3B8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== СЕКЦИИ ===== */
.sidebar-section {
    padding: 4px 0;
}

.sidebar-section-header {
    display: flex;
    justify-content: flex-start;   /* ← прижать к левому краю */
    align-items: center;
    gap: 8px;                      /* ← пробел между стрелкой и текстом */
    padding: 10px 18px 6px;
    cursor: pointer;
    user-select: none;
}

.sidebar-section-header:hover .section-title {
    color: #E2E8F0;
}

.sidebar-section-header .section-title {
    font-size: 12px;
    font-weight: 600;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s;
    /* flex: 1; — НЕ надо, если хотим, чтобы текст был рядом со стрелкой */
}

.sidebar-section-content {
    display: none;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sidebar-section-content.open {
    display: block;
}

.section-arrow {
    display: inline-block;
    font-size: 12px;
    color: #64748B;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;   /* не сжимается */
}

.btn-add {
    background: none;
    border: none;
    color: #64748B;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-add:hover {
    color: #6B82F8;
    background: rgba(79, 107, 246, 0.1);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 12px 18px;
}

/* ===== МЕНЮ ===== */
.sidebar-menu {
    flex: 1;
    padding: 8px 10px;
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: #94A3B8;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #E2E8F0;
}

.sidebar-link.active {
    background: rgba(79, 107, 246, 0.15);
    color: #6B82F8;
}

.sidebar-link .link-icon {
    font-size: 16px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.sidebar-link .link-text {
    font-size: 14px;
    font-weight: 500;
}

/* ===== ДЕРЕВО ===== */
.sidebar-tree {
    list-style: none;
    padding: 0;
    padding-left: 0;
    margin: 0;
}

.sidebar-tree-nested {
    padding-left: 40px;
}

.tree-item {
    list-style: none;
}

.tree-item-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    min-height: 34px;
}

.tree-item-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.tree-toggle {
    font-size: 10px;
    color: #64748B;
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.tree-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.tree-name {
    flex: 1;
    color: #E2E8F0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.tree-count {
    font-size: 12px;
    color: #64748B;
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
}

.tree-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    color: #94A3B8;
    border: 1px solid rgba(255, 255, 255, 0.06);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ===== ВЛОЖЕННЫЕ ЭЛЕМЕНТЫ ===== */
.tree-children {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.tree-children .tree-item-header { padding-left: 24px !important; }
.tree-children .tree-children .tree-item-header { padding-left: 40px !important; }
.tree-children .tree-children .tree-children .tree-item-header { padding-left: 56px !important; }
.tree-children .tree-children .tree-children .tree-children .tree-item-header { padding-left: 72px !important; }

/* ===== ЦВЕТА ДОСТУПА ===== */
.tree-item.access-secret .tree-name { color: #ef4444 !important; }
.tree-item.access-secret .tree-icon { color: #ef4444; }
.tree-item.access-secret .tree-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.tree-item.access-protected .tree-icon { color: #6B82F8; }
.tree-item.access-private .tree-icon { color: #f59e0b; }
.tree-item.active .tree-name { color: #6B82F8 !important; }

/* ===== ПУСТОЕ СОСТОЯНИЕ ===== */
.empty-state {
    color: #64748B;
    font-size: 13px;
    padding: 12px 18px;
    text-align: center;
}

/* ===== ФУТЕР САЙДБАРА ===== */
.sidebar-footer {
    padding: 12px 18px;
    border-top: 1px solid #2d2d44;
    text-align: center;
    flex-shrink: 0;
}

.footer-text {
    font-size: 10px;
    color: #4a4a6a;
}

/* ===== ВЫХОД ===== */
.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 8px 10px;
    border-radius: 10px;
    color: #ef4444;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ===== ОТСТУП ОСНОВНОГО КОНТЕНТА ===== */
body.has-sidebar .app-main {
    margin-left: 260px;
}