/* 侧边栏包装器 */
.sidebar-wrapper {
    display: flex;
    align-items: stretch;
    height: 100%;
    z-index: 50;
}

/* 侧边栏样式 */
.sidebar {
    width: 180px;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow: hidden;
    border-radius: 0 12px 12px 0;
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
    border-radius: 0;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: padding 0.3s ease;
}

.sidebar.collapsed .sidebar-header {
    padding: 20px 10px;
    transition: padding 0.3s ease;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    transition: opacity 0.3s ease, width 0.3s ease, margin 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header h3 {
    opacity: 0;
    width: 0;
    margin: 0;
    transition: opacity 0.3s ease, width 0.3s ease, margin 0.3s ease;
}

.toggle-btn {
    position: relative;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background: #f0f0f0;
}

.toggle-btn img {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toggle-btn .icon-open {
    opacity: 1;
    transform: scale(1);
}

.toggle-btn .icon-closed {
    opacity: 0;
    transform: scale(0.8);
}

.toggle-btn.rotated .icon-open {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toggle-btn.rotated .icon-closed {
    opacity: 1;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    margin: 0;
    transition: all 0.3s ease;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #555;
    text-decoration: none;
    transition: all 0.3s ease, padding 0.3s ease;
    border-left: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.sidebar.collapsed .menu-item a {
    padding: 15px 10px;
    transition: all 0.3s ease, padding 0.3s ease;
    justify-content: center;
}

.menu-item:hover a {
    background: #f5f5f5;
    color: #667eea;
}

.menu-item.active a {
    background: #f0f0f0;
    color: #667eea;
    border-left-color: #667eea;
}

.menu-icon {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    flex-shrink: 0;
    transition: all 0.3s ease, margin 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.sidebar.collapsed .menu-icon {
    margin-right: 0;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease, margin 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.menu-text {
    transition: all 0.3s ease, opacity 0.3s ease, width 0.3s ease, margin 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    font-size: 14px;
}

.sidebar.collapsed .menu-text {
    opacity: 0;
    width: 0;
    margin: 0;
    transition: all 0.3s ease, opacity 0.3s ease, width 0.3s ease, margin 0.3s ease;
}

/* 侧边栏外部切换按钮 */
.sidebar-toggle {
    width: 24px;
    height: 60px;
    background: white;
    border: none;
    border-left: none;
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: #f5f5f5;
}

body.theme-dark .sidebar-toggle {
    background: #2c2c2c;
}

body.theme-dark .sidebar-toggle:hover {
    background: #3a3a3a;
}

body.theme-dark .sidebar-toggle img {
    filter: invert(1);
}

.sidebar-toggle img {
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.sidebar-toggle .icon-open {
    opacity: 1;
    transform: scale(1);
}

.sidebar-toggle .icon-closed {
    opacity: 0;
    transform: scale(0.8);
}

.sidebar-wrapper.collapsed .sidebar-toggle .icon-open {
    opacity: 0;
    transform: scale(0.8);
}

.sidebar-wrapper.collapsed .sidebar-toggle .icon-closed {
    opacity: 1;
    transform: scale(1);
}

/* 移动端响应式设计 */
@media (max-width: 768px) {
    .sidebar-wrapper {
        height: 100%;
    }
    
    .sidebar {
        width: 140px;
        border-radius: 0 8px 8px 0;
    }
    
    .sidebar-header {
        padding: 15px 12px;
    }
    
    .sidebar-header h3 {
        font-size: 14px;
    }
    
    .sidebar.collapsed {
        width: 0;
        border-radius: 0;
        padding: 0;
        margin: 0;
    }
    
    .sidebar.collapsed .sidebar-header h3 {
        opacity: 0;
        width: 0;
    }
    
    .menu-item a {
        padding: 12px 10px;
        font-size: 13px;
    }
    
    .sidebar.collapsed .menu-item a {
        padding: 12px 5px;
    }
    
    .menu-icon {
        width: 16px;
        height: 16px;
        margin-right: 8px;
    }
    
    .sidebar.collapsed .menu-icon {
        margin-right: 0;
        opacity: 0;
    }
    
    .menu-text {
        font-size: 12px;
    }
    
    .sidebar.collapsed .menu-text {
        opacity: 0;
        width: 0;
    }
    
    .sidebar-toggle {
        height: 40px;
        width: 20px;
    }
}
