/* ========================================
   Article Detail Page - 文章详情页
   ======================================== */

/* Main Layout */
.main-layout {
    display: flex;
    max-width: 1840px;
    margin: 0 auto;
    padding: 1rem 5%;
    gap: 1.5rem;
}

/* TOC Sidebar */
.toc-sidebar {
    width: var(--toc-width);
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.toc-container {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.toc-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-list {
    list-style: none;
}

.toc-item {
    margin-bottom: 0.15rem;
}

.toc-link {
    display: block;
    padding: 0.35rem 0.6rem;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.toc-link:hover {
    color: var(--secondary-color);
    background: var(--light-bg);
}

.toc-link.active {
    color: var(--secondary-color);
    background: rgba(52, 152, 219, 0.1);
    border-left-color: var(--secondary-color);
    font-weight: 500;
}

.toc-link.level-3 {
    padding-left: 1.2rem;
    font-size: 0.8rem;
}

.toc-empty {
    color: var(--text-light);
    font-size: 0.85rem;
    text-align: center;
    padding: 0.75rem;
}

/* Article Main */
.article-main {
    flex: 1.8;
    min-width: 0;
}

.article-container {
    max-width: 100%;
}

.article-card {
    background: var(--article-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
}

.article-content-wrapper {
    padding: 1.5rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary-color);
    text-decoration: none;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.back-link:hover {
    gap: 0.75rem;
}

.article-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.article-title {
    font-size: 1.75rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
    line-height: 1.3;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-light);
    font-size: 0.85rem;
}

.article-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-meta .topic {
    color: var(--secondary-color);
    text-decoration: none;
    transition: all 0.3s;
}

.article-meta .topic:hover {
    text-decoration: underline;
}

/* Article Body */
.article-body {
    font-size: 0.85rem;
    line-height: 1.8;
}

.article-body [id] {
    scroll-margin-top: 100px;
}

.article-body h2 {
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem;
    color: var(--primary-color);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--secondary-color);
    display: inline-block;
}

.article-body h3 {
    font-size: 1.1rem;
    margin: 1.25rem 0 0.5rem;
    color: var(--primary-color);
}

.article-body h4 {
    font-size: 1rem;
    margin: 1rem 0 0.5rem;
    color: var(--primary-color);
}

.article-body p {
    margin-bottom: 0.75rem;
    color: #444;
}

.article-body strong {
    color: var(--primary-color);
}

.article-body pre {
    background: #282c34;
    color: #abb2bf;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

.article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-family: inherit;
}

.article-body code {
    background: var(--light-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 0.85em;
    color: #e74c3c;
}

.article-body ul, 
.article-body ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.article-body li {
    margin-bottom: 0.35rem;
    color: #444;
}

.article-body li::marker {
    color: var(--secondary-color);
}

.article-body blockquote {
    border-left: 4px solid var(--secondary-color);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: var(--light-bg);
    border-radius: 0 8px 8px 0;
    color: var(--text-light);
    font-style: normal;
}

.article-body img {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.article-body a {
    color: var(--secondary-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s;
}

.article-body a:hover {
    border-bottom-color: var(--secondary-color);
}

.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.article-body table th,
.article-body table td {
    border: none;
    padding: 0.75rem;
    text-align: left;
}

.article-body table th {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.article-body table tr:nth-child(even) {
    background: var(--light-bg);
}

.article-body hr {
    border: none;
    border-top: 2px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Tags */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.tag {
    background: var(--light-bg);
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-light);
    transition: all 0.3s;
    cursor: pointer;
}

.tag:hover {
    background: var(--secondary-color);
    color: white;
}

/* Article Navigation */
.article-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.article-nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.article-nav a:hover {
    gap: 0.75rem;
}

.article-nav a.next {
    margin-left: auto;
}

/* Mobile TOC Toggle */
.toc-toggle-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    z-index: 1000;
    font-size: 1.25rem;
    transition: all 0.3s;
}

.toc-toggle-btn:hover {
    transform: scale(1.1);
}

.toc-mobile-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1001;
}

.toc-mobile-panel.hidden {
    display: none;
}

.toc-mobile-content {
    position: absolute;
    top: 0;
    right: 0;
    width: 300px;
    height: 100%;
    background: white;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.3s;
}

.toc-mobile-content.open {
    transform: translateX(0);
}

.toc-mobile-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-color);
    color: white;
}

.toc-mobile-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

.toc-mobile-body {
    padding: 1.5rem;
}

/* Responsive */
@media (max-width: 1024px) {
    .main-layout {
        gap: 1.5rem;
    }
    
    .toc-sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .toc-sidebar {
        display: none;
    }
    
    .toc-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .toc-mobile-panel {
        display: block;
    }
    
    .article-content-wrapper {
        padding: 1rem;
    }
    
    .article-title {
        font-size: 1.35rem;
    }
    
    .article-nav {
        flex-direction: column;
        gap: 1rem;
    }
    
    .article-nav a.next {
        margin-left: 0;
    }
}
