/* 全域 Sidebar 樣式（含遞迴子元件 SidebarMenuNode） */

.sidebar {
    flex-shrink: 0;
    align-self: stretch;
    width: 15%;
    min-width: 100px;
    height: 100%;
    max-height: 100vh;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #1d222b;
    border-top: 5px solid #181818cc;
    border-right: 1px solid #374151;
    color: #f3f4f6;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.3);
    transition: width 0.2s ease, min-width 0.2s ease, padding 0.2s ease;
    box-sizing: border-box;
    scrollbar-gutter: stable;
}



.sidebar::-webkit-scrollbar {
    width: 6px;
}



.sidebar::-webkit-scrollbar-thumb {
    background-color: #4b5563;
    border-radius: 3px;
}



.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: #6b7280;
}



.sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    overflow: hidden;
}


.sidebar .nav-links {
    display: flex;
    flex-direction: column;
}


.sidebar .menu-item {
    margin-bottom: 0.25rem;
}



.sidebar .menu-title {
    cursor: pointer;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 500;
    border-radius: 0.5rem;
    position: relative;
    z-index: 1;
    background: transparent;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}


.sidebar .menu-title:hover {
    background-color: #585b61;
    color: white;
    transform: translateX(3px);
}

.sidebar .menu-title.active,
.sidebar .menu-title.has-active-child {
    background-color: #4b5563;
    color: white;
}


.sidebar .menu-title-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}


.sidebar .menu-chevron {
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: #9ca3af;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), color 0.25s ease;
}



.sidebar .menu-chevron.expanded {
    transform: rotate(90deg);
    color: #f3f4f6;
}



.sidebar .submenu-panel {
    display: grid;
    grid-template-rows: 0fr;
    margin-left: 0.75rem;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition:
        grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.32s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}



.sidebar .submenu-panel.expanded {
    grid-template-rows: 1fr;
    opacity: 1;
    transform: translateY(0);
}


.sidebar .submenu-panel > .submenu {
    min-height: 0;
    overflow: hidden;
}



.sidebar .submenu {
    display: flex;
    flex-direction: column;
    padding: 0.25rem 0 0.5rem 1.5rem;
    background-color: #1f2937;
    border-left: 2px solid #3b82f6;
}


.sidebar a.menu-title,
.sidebar a.submenu-item {
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
}

.sidebar .submenu-item {
    padding: 0.5rem 0.75rem;
    color: #d1d5db;
    font-size: 14px;
    cursor: pointer;
    border-radius: 0.25rem;
    display: block;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}



.sidebar .submenu-item:hover:not(.disabled):not(.submenu-branch-title) {
    background-color: #3b82f6;
    color: white;
    transform: translateX(5px);
}



.sidebar .submenu-item.active {
    background-color: #585b61;
    color: white;
    border-left: 3px solid #60a5fa;
    padding-left: calc(0.75rem - 3px);
}



.sidebar .submenu-item.disabled {
    color: #6b7280;
    cursor: not-allowed;
    pointer-events: none;
}


.sidebar .submenu-branch {
    display: flex;
    flex-direction: column;
}



.sidebar .submenu-branch-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 500;
    padding-left: calc(0.75rem + var(--tree-depth, 0) * 0.65rem);
}



.sidebar .submenu-branch-title:hover:not(.disabled) {
    background-color: #374151;
    color: white;
}



.sidebar .submenu-branch-title.active,
.sidebar .submenu-branch-title.has-active-child {
    background-color: #4b5563;
    color: white;
}



.sidebar .submenu-branch-title .menu-chevron {
    font-size: 1rem;
}



.sidebar .submenu-tree-panel {
    display: grid;
    grid-template-rows: 0fr;
    margin-left: calc(0.5rem + var(--tree-depth, 0) * 0.35rem);
    overflow: hidden;
    opacity: 0;
    transition:
        grid-template-rows 0.38s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}



.sidebar .submenu-tree-panel.expanded {
    grid-template-rows: 1fr;
    opacity: 1;
}



.sidebar .submenu-tree-panel > .submenu-tree-children {
    min-height: 0;
    overflow: hidden;
}



.sidebar .submenu-tree-children {
    display: flex;
    flex-direction: column;
    padding: 0.15rem 0 0.15rem 0.5rem;
    border-left: 1px solid #374151;
}



.sidebar .submenu-leaf {
    padding-left: calc(0.75rem + var(--tree-depth, 0) * 0.65rem);
}

