/**
 * 文章目录样式
 */

/* 文章标题容器 */
.article-title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.article-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.article-actions .button {
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.8);
    color: #4a5568;
    transition: all 0.3s ease;
}

.article-actions .button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-1px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .article-title-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .article-actions {
        align-self: flex-end;
    }
}

.article-toc {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%) translateX(-100%);
    width: 300px;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0 12px 12px 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: none;
    opacity: 0;
}

.article-toc.show {
    transform: translateY(-50%) translateX(0);
    opacity: 1;
    display: block;
}

.article-toc:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) translateX(0) scale(1.01);
}

/* 目录头部 */
.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.toc-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.toc-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.toc-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* 目录列表 */
.toc-list {
    max-height: calc(70vh - 60px);
    overflow-y: auto;
    padding: 8px 0;
}

.toc-list::-webkit-scrollbar {
    width: 4px;
}

.toc-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

.toc-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.toc-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

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

.toc-item {
    margin: 0;
}

.toc-link {
    display: flex;
    align-items: center;
    padding: 8px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
    border-left: 3px solid transparent;
}

.toc-link:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border-left-color: #667eea;
}

.toc-link.active {
    background: rgba(102, 126, 234, 0.15);
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 600;
}

.toc-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word;
}

.toc-progress {
    width: 4px;
    height: 20px;
    background: rgba(102, 126, 234, 0.3);
    border-radius: 2px;
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toc-link.active .toc-progress {
    opacity: 1;
}

/* 不同层级的缩进 */
.toc-level-1 .toc-link { padding-left: 20px; }
.toc-level-2 .toc-link { padding-left: 30px; }
.toc-level-3 .toc-link { padding-left: 40px; }
.toc-level-4 .toc-link { padding-left: 50px; }
.toc-level-5 .toc-link { padding-left: 60px; }
.toc-level-6 .toc-link { padding-left: 70px; }

/* 嵌套列表 */
.toc-items .toc-items {
    margin-left: 0;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .article-toc {
        right: 10px;
        width: 260px;
    }
}

@media (max-width: 768px) {
    .article-toc {
        position: fixed;
        top: auto;
        bottom: 20px;
        right: 20px;
        left: 20px;
        transform: none;
        width: auto;
        max-height: 50vh;
    }
    
    .toc-header h3 {
        font-size: 14px;
    }
    
    .toc-link {
        padding: 6px 16px;
        font-size: 13px;
    }
    
    .toc-level-1 .toc-link { padding-left: 16px; }
    .toc-level-2 .toc-link { padding-left: 24px; }
    .toc-level-3 .toc-link { padding-left: 32px; }
    .toc-level-4 .toc-link { padding-left: 40px; }
    .toc-level-5 .toc-link { padding-left: 48px; }
    .toc-level-6 .toc-link { padding-left: 56px; }
}

/* 黑暗模式 */
.dark-theme .article-toc {
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.dark-theme .article-toc:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.dark-theme .toc-header {
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-theme .toc-link {
    color: #e2e8f0;
}

.dark-theme .toc-link:hover {
    background: rgba(102, 126, 234, 0.2);
    color: #90cdf4;
}

.dark-theme .toc-link.active {
    background: rgba(102, 126, 234, 0.25);
    color: #90cdf4;
}

.dark-theme .toc-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.dark-theme .toc-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

.dark-theme .toc-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 动画效果 */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.article-toc {
    animation: slideInRight 0.5s ease-out;
}

/* 进度条 */
.toc-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transition: width 0.3s ease;
    z-index: 1;
}

/* 隐藏状态 */
.article-toc.hidden {
    transform: translateY(-50%) translateX(100%);
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    .article-toc.hidden {
        transform: translateY(100%);
    }
}
