/* 浮动目录样式 - 修正版 */
.floating-toc {
    position: fixed;
    left: 1rem;
    bottom: 1rem;
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
    z-index: 9999;
    transition: all 0.3s ease;
    border: 1px solid #e1e1e1;
    overflow: hidden;
}

/* 默认状态下隐藏所有内容，只显示图标 */
.floating-toc .toc-header,
.floating-toc .toc-list {
    display: none;
}

/* 展开图标 - 始终显示 */
.toc-expand-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10000;
}

/* Dashicons图标样式 */
.toc-expand-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #555;
    transition: color 0.2s;
}

.toc-expand-icon:hover .dashicons {
    color: #0073aa;
}

/* PC端展开状态 */
.floating-toc.expanded {
    width: 280px;
    height: auto;
    max-height: 70vh;
    padding: 20px;
    overflow-y: auto;
}

.floating-toc.expanded .toc-header,
.floating-toc.expanded .toc-list {
    display: block;
}

.floating-toc.expanded .toc-expand-icon {
    display: none;
}

/* 目录头部 */
.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.toc-title {
    font-weight: 600;
    margin: 0;
}

.toc-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.toc-toggle:hover {
    color: #333;
    background-color: #f5f5f5;
}

/* 目录列表 */
.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    line-height: 1;
}

.toc-link {
    display: block;
    text-decoration: none;
    padding: 0.8rem 0;
    transition: all 0.2s;
    word-break: break-word;
    border-radius: 0 4px 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-link:hover {
    background-color: #f0f0f0;
}

.toc-link.active {
    font-weight: 600;
    background-color: #f0f0f0;
}

/* 标题层级缩进 */
.toc-h1 { padding-left: 0; font-weight: 600; }
.toc-h2 { padding-left: 0; font-weight: 600;}
.toc-h3 { padding-left: 1rem; }
.toc-h4 { padding-left: 1.5rem; }
.toc-h5 { padding-left: 2rem; }
.toc-h6 { padding-left: 2.5rem; }

/* PC端响应式 */
@media (max-width: 1200px) {
    .floating-toc.expanded {
        width: 240px;
        left: 15px;
    }
}

/* 移动端样式 */
@media (max-width: 768px) {
    .floating-toc {
        left: 15px;
        bottom: 15px;
    }
    
    /* 移动端展开状态 - 全屏覆盖，类似移动端导航 */
    .floating-toc.mobile-expanded {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 0;
        z-index: 10001;
        background: white;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        margin-top:0;
    }
    
    .floating-toc.mobile-expanded .toc-header {
        display: flex;
        position: sticky;
        top: 0;
        padding: 2rem 1rem;
        margin-bottom: 0;
        border-bottom: 1px solid #eee;
        z-index: 2;
    }
    
    .floating-toc.mobile-expanded .toc-title {
        font-size: 20px;
        flex: 1;
    }
    
    .floating-toc.mobile-expanded .toc-toggle {
        font-size: 24px;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .floating-toc.mobile-expanded .toc-list {
        display: block;
        flex: 1;
        padding: 1rem;
        overflow-y: auto;
    }
    
    .floating-toc.mobile-expanded .toc-link {
        padding: 0.8rem 0;
        border-left-width: 4px;
    }
    
    .floating-toc.mobile-expanded .toc-expand-icon {
        display: none;
    }
    
    /* 移动端层级缩进调整 */
    .floating-toc.mobile-expanded .toc-h1 { padding-left: 0; }
    .floating-toc.mobile-expanded .toc-h2 { padding-left: 1rem; }
    .floating-toc.mobile-expanded .toc-h3 { padding-left: 1.5rem; }
    .floating-toc.mobile-expanded .toc-h4 { padding-left: 2rem; }
    .floating-toc.mobile-expanded .toc-h5 { padding-left: 2.5rem; }
    .floating-toc.mobile-expanded .toc-h6 { padding-left: 3rem; }
}

/* 为文章标题添加滚动边距 */
.entry-content h1,
.entry-content h2, 
.entry-content h3, 
.entry-content h4, 
.entry-content h5, 
.entry-content h6 {
    scroll-margin-top: 100px;
}

/* 滚动条样式 */
.floating-toc.expanded::-webkit-scrollbar {
    width: 6px;
}

.floating-toc.expanded::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.floating-toc.expanded::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.floating-toc.expanded::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .floating-toc {
        border: 2px solid #000;
    }
    
    .toc-link.active {
        background-color: #e6f3ff;
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .floating-toc {
        transition: none;
    }
    
    .toc-link {
        transition: none;
    }
}