/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.nav ul {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.nav a {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

.nav a:hover,
.nav a.active {
    color: #3498db;
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4rem 0;
    text-align: center;
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    padding: 3rem 0;
    min-height: 60vh;
}

/* Main Content Container Layout */
.main-content .container {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    max-width: none;
    width: 90%;
}

/* Sidebar Styles */
.sidebar {
    flex: 0 0 calc(20% - 1rem);
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* Content Wrapper */
.content-wrapper {
    flex: 0 0 calc(80% - 1rem);
}

.sidebar h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

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

.category-section {
    margin-bottom: 1.5rem;
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.category-header[data-category-name]:hover {
    background-color: #f8f9fa;
    border-radius: 5px;
}

.category-header[data-category-name]:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    border-radius: 5px;
}

.category-header[data-category-name]:focus:not(:focus-visible) {
    outline: none;
}

.category-header[data-category-name]:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
    border-radius: 5px;
}

.category-header-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.expand-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #666;
    transition: transform 0.3s ease;
}

.category-section.collapsed .expand-icon {
    transform: rotate(-90deg);
}

.category-name {
    font-size: 1rem;
    color: #2c3e50;
}

.category-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #555;
    text-decoration: none;
    border-radius: 5px;
    transition: all 0.3s ease;
    font-weight: 500;
    width: 100%;
}

.category-link:hover {
    background-color: #f0f0f0;
    color: #3498db;
}

.category-link.active {
    background-color: #3498db;
    color: white;
}

.category-list .count {
    background-color: #e0e0e0;
    color: #666;
    padding: 0.2rem 0.5rem;
    border-radius: 10px;
    font-size: 0.85rem;
}

.category-link.active .count {
    background-color: rgba(255, 255, 255, 0.3);
    color: white;
}

.post-list {
    list-style: none;
    padding-left: 0;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.category-section.collapsed .post-list {
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    margin-bottom: 0;
}

.post-item {
    margin-bottom: 0.3rem;
}

.post-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: #666;
    text-decoration: none;
    font-size: 0.9rem;
    border-radius: 3px;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.post-link:hover {
    background-color: #f8f9fa;
    color: #3498db;
    padding-left: 1rem;
}

/* Posts Grid */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    width: 100%;
}

.post-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.post-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.post-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.post-content {
    padding: 1.5rem;
}

.post-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.post-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #2c3e50;
}

.post-card p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.read-more {
    color: #3498db;
    font-weight: 600;
    display: inline-block;
}

/* Post Detail Page */
.post-detail {
    background: white;
    border-radius: 8px;
    padding: 3rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    margin: 0 auto;
}

.post-detail h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.post-detail .post-meta {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #eee;
}

.post-detail .post-image {
    width: 100%;
    height: 400px;
    margin-bottom: 2rem;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.post-detail .content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #444;
}

.post-detail .content h2 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.post-detail .content p {
    margin-bottom: 1rem;
}

/* Unordered List Styles - 支持嵌套 */
.content ul {
    list-style: none;
    padding-left: 1.5rem;
    margin-left: 0;
    margin-bottom: 1rem;
}

.content ul > li {
    position: relative;
    padding-left: 1.2rem;
    margin-bottom: 0.5rem;
    line-height: 1.8;
}

.content ul > li::before {
    content: "•";
    position: absolute;
    left: 0;
    top: 0;
    color: #3498db;
    font-size: 1.2em;
    font-weight: bold;
    line-height: 1.8;
}

/* Nested unordered lists */
.content ul ul {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.content ul ul > li::before {
    content: "◦";
    font-size: 1em;
}

.content ul ul ul > li::before {
    content: "▪";
    font-size: 0.8em;
}

/* Ordered List Styles - 支持嵌套 */
.content ol {
    list-style: none;
    margin-left: 0;
    margin-bottom: 1rem;
    padding-left: 1.5rem;
    counter-reset: item;
}

.content ol > li {
    counter-increment: item;
    margin-bottom: 0.5rem;
    position: relative;
    padding-left: 1.5rem;
    line-height: 1.8;
}

.content ol > li::before {
    content: counter(item) ".";
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 600;
    color: #3498db;
    line-height: 1.8;
}

/* Nested ordered lists */
.content ol ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    counter-reset: item;
}

.content ol ol ol {
    counter-reset: item;
}

/* Mixed nested lists (ul inside ol, ol inside ul) */
.content ol ul,
.content ul ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Reset counter for ol inside ul */
.content ul ol {
    counter-reset: item;
}

.back-link {
    margin-top: 2rem;
    text-align: center;
}

.back-link a {
    color: #3498db;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.back-link a:hover {
    color: #2980b9;
}

/* Footer */
.footer {
    background-color: #2c3e50;
    color: white;
    padding: 2rem 0;
    margin-top: 4rem;
}

.footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.social-links {
    display: flex;
    gap: 1.5rem;
}

.social-links a {
    color: white;
    text-decoration: none;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: #3498db;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav ul {
        gap: 1rem;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .main-content .container {
        flex-direction: column;
    }

    .sidebar {
        position: static;
        flex: 1 1 auto;
        width: 100%;
    }

    .content-wrapper {
        flex: 1 1 auto;
        width: 100%;
    }

    .posts-grid {
        grid-template-columns: 1fr;
    }

    .post-detail {
        padding: 2rem 1.5rem;
    }

    .post-detail h1 {
        font-size: 2rem;
    }

    .footer .container {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
}

/* Loading Animation */
.loading {
    text-align: center;
    padding: 3rem;
    font-size: 1.2rem;
    color: #666;
}

/* Category Tags */
.category-tag {
    display: inline-block;
    background-color: #3498db;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* Markdown Content Styles */
.content code {
    background-color: #f4f4f4;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    color: #e83e8c;
}

.content pre {
    background-color: #f4f4f4;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
}

.content pre code {
    background-color: transparent;
    padding: 0;
    color: #333;
}

.content strong {
    font-weight: 700;
    color: #2c3e50;
}

/* Mermaid Diagram Styles */
.mermaid-container {
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
}

.mermaid {
    display: inline-block;
    margin: 0 auto;
}

.mermaid-fallback {
    text-align: left;
}

.mermaid-fallback em {
    color: #666;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.5rem;
}

.mermaid-fallback pre {
    background-color: #fff;
    text-align: left;
}

/* Table Styles */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.content table thead {
    background-color: #3498db;
    color: white;
}

.content table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

.content table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    color: #444;
}

.content table tbody tr:last-child td {
    border-bottom: none;
}

.content table tbody tr:hover {
    background-color: #f8f9fa;
    transition: background-color 0.2s ease;
}

/* Alternating row colors for better readability */
.content table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.content table tbody tr:nth-child(even):hover {
    background-color: #f0f0f0;
}

/* Markdown Image Styles */
.content .markdown-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.5rem auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.content p .markdown-image {
    display: inline-block;
    vertical-align: middle;
    margin: 0.5rem;
}

/* Table of Contents Styles */
.toc-container {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.toc {
    display: block;
}

.toc-title {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.content .toc-list li,
.toc-list li {
    margin-bottom: 0.4rem;
    line-height: 1.5;
    padding-left: 0;
    position: static;
}

.content .toc-list li::before,
.toc-list li::before {
    content: none;
    display: none;
}

.toc-list a {
    color: #555;
    text-decoration: none;
    transition: color 0.2s ease;
}

.toc-list a:hover {
    color: #3498db;
    text-decoration: underline;
}

/* TOC heading levels - indentation for different heading levels */
.content .toc-list .toc-level-2,
.toc-list .toc-level-2 {
    padding-left: 1rem;
}

.content .toc-list .toc-level-3,
.toc-list .toc-level-3 {
    padding-left: 2rem;
    font-size: 0.95em;
}