/* SIDEBAR */
.sidebar-wrapper {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    height: calc(100vh - var(--navbar-height));
    display: flex;
    align-items: flex-start;
    z-index: 1000;
}

.sidebar {
    width: 0;
    height: 100%;
    background-color: #ffffff;
    color: #111827;
    border-right: 1px solid #d1d5db;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.05);
    overflow-y: auto;
    max-height: 100%;
    padding: 0;
    opacity: 0;
    transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.active {
    width: var(--sidebar-width);
    padding: 1rem;
    opacity: 1;
}

/* TOGGLE SIDEBAR BUTTON */
.sidebar-toggle {
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(0);
    transition: transform 0.3s ease;
    background-color: #ffffff;
    color: #111827;
    border: 1px solid #d1d5db;
    border-left: none;
    border-radius: 0 5px 5px 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    z-index: 1100;
}

.sidebar-toggle.active {
    transform: translateX(var(--sidebar-width));
}

.sidebar-content {
    margin-top: 20px;
    overflow: auto;
    padding: 10px;
    border: 1px solid black;
    flex-grow: 1;
    margin-bottom: 20px;
}

/* TREE VIEW */
.sidebar-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.sidebar-tree li {
    margin: 0;
    padding: 0;
    position: relative;
    line-height: 1.8;
    list-style: none;
}

/* Ẩn ul con mặc định */
.sidebar-tree li ul {
    display: none;
    list-style: none;
    margin: 0;
    padding-left: 20px;
}

/* Hiển thị khi mở */
.sidebar-tree li ul.expanded {
    display: block;
}

/* Node con phải thụt vào */
.sidebar-tree li ul > li {
    padding-left: 20px;
}

/* Đường kẻ chỉ áp dụng cho cấp con trở đi */
.sidebar-tree li ul > li::before {
    content: "";
    position: absolute;
    top: -0.25em;
    left: 8px; /* canh theo padding-left */
    bottom: 0;
    border-left: 2px solid #9ca3af;
}

.sidebar-tree li ul > li::after {
    content: "";
    position: absolute;
    top: 1em;
    left: 8px;
    width: 12px;
    border-top: 2px solid #9ca3af;
}

/* Ẩn đường dọc ở node cuối cùng */
.sidebar-tree li ul > li:last-child::before {
    height: 1.25em;
}

/* link + icon */
.sidebar-tree li a {
    text-decoration: none;
    color: #111827;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    white-space: nowrap;
    max-width: 100%;
}

.sidebar-tree li a:hover {
    color: #2563eb;
}

/* toggle icon */
.toggle-icon {
    font-size: 12px;
    cursor: pointer;
    color: #6b7280;
    display: inline-block;
    width: 16px;
    text-align: center;
}

.toggle-icon.open::before {
    content: "▼";
}

.toggle-icon.closed::before {
    content: "▶";
}

/* Node active */
.sidebar-tree li.active > a {
    font-weight: bold;
    color: #2563eb;
}
