/* 侧栏控制按钮样式 */
#toggle-sidebar {
    position: fixed;
    left: 0;
    top: 20px;
    background: var(--button-hover);
    border: 2px solid #a4d1c4;
    border-radius: 0 15px 15px 0;
    padding: 8px 12px;
    cursor: pointer;
    z-index: 1002;
    font-size: 1.3rem;
    user-select: none;
    outline: none;
    transition: transform var(--duration-short) var(--ease-out-quad), background-color var(--duration-short) var(--ease-out-quad), box-shadow var(--duration-short) var(--ease-out-quad);
    will-change: transform;
    contain: layout size style;
    transform: translateZ(0);
    box-sizing: border-box;
    transform-origin: left center;
    width: 48px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* 防止布局偏移 */
    backface-visibility: hidden;
}

/* 添加初始状态，防止按钮位置跳动 */
.sidebar:not(.js-initialized) #toggle-sidebar,
.sidebar:not(.js-initialized).collapsed #toggle-sidebar {
    transform: translateZ(0);
    border-radius: 0 15px 15px 0;
}

#toggle-sidebar img {
    width: 24px;
    height: 24px;
    color: var(--text-color);
    transition: color var(--duration-short) var(--ease-default), transform var(--duration-short) var(--ease-default);
    display: none;
    /* 默认隐藏所有图标 */
    flex-shrink: 0;
    will-change: transform;
}

/* 根据侧边栏状态显示对应图标 */
.sidebar.collapsed #toggle-sidebar .show-panel {
    display: block;
    /* 侧边栏收起时显示展开图标 */
}

.sidebar:not(.collapsed) #toggle-sidebar .hide-panel {
    display: block;
    /* 侧边栏展开时显示收起图标 */
}

/* 侧边栏按钮悬停效果 - 仅在PC端生效 */
@media (hover: hover) and (pointer: fine) {
    #toggle-sidebar:hover {
        background-color: var(--button-hover);
        box-shadow: var(--theme-shadow-hover);
    }

    #toggle-sidebar:hover img {
        transform: scale(1.1);
        transition: transform var(--duration-short) var(--ease-out-quad);
    }
    
    .sidebar:not(.collapsed) #toggle-sidebar:hover {
        transform: translateX(160px) translateZ(0);
    }
}



.sidebar:not(.collapsed) #toggle-sidebar {
    transform: translateX(160px) translateZ(0);
    border-radius: 15px;
}

.sidebar.collapsed #toggle-sidebar {
    transform: translateZ(0);
    border-radius: 0 15px 15px 0;
}

/* 小于1024px时，侧栏收起状态下按钮保持在左边 */
/* 注意: 1023px 对应 BREAKPOINT_SIDEBAR (1024px) - 1 */
@media screen and (max-width: 1023px) {
    .sidebar.collapsed #toggle-sidebar,
    .sidebar:not(.js-initialized) #toggle-sidebar {
        transform: translateZ(0);
        border-radius: 0 15px 15px 0;
    }
}

/* 聚焦样式 */
#toggle-sidebar:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(43, 195, 206, 0.2);
    border-radius: 4px;
}

/* 移动端焦点状态处理 */
@media (hover: none) and (pointer: coarse) {
    #toggle-sidebar:focus,
    #toggle-sidebar:active {
        background: var(--button-hover);
        border: 1.5px solid #a4d1c4;
        outline: none;
    }
}