/* Global Styles */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --text-color: #333;
    --border-color: #ddd;
    --bg-color: #f8f9fa;
    --hover-color: #ecf0f1;
    --sidebar-width: 250px;
    --toc-width: 250px;
}

/* LXGW WenKai Font - Load from CDN */
@import url('https://cdn.jsdelivr.net/npm/lxgw-wenkai@1.7.2/style.css');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'LXGW WenKai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color);
    background-color: #fff;
}

body {
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background-color: var(--primary-color);
    color: white;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 60px;
}

.logo a {
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo a:hover {
    opacity: 0.9;
}

.navbar-nav {
    display: flex;
    gap: 30px;
}

.nav-item {
    color: white;
    text-decoration: none;
    transition: opacity 0.3s;
    font-size: 16px;
    padding: 8px 0;
    border-bottom: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    opacity: 0.8;
    border-bottom-color: var(--secondary-color);
}

/* Main Container */
.container {
    display: flex;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
    gap: 0;
}

/* Sidebar Left - Navigation */
.sidebar-left {
    width: var(--sidebar-width);
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px - 60px);
}

.sidebar-content {
    padding: 20px 0;
}

.year-section {
    margin-bottom: 20px;
}

.year-title {
    padding: 10px 15px;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary-color);
    border-left: 4px solid var(--secondary-color);
    margin: 0;
}

.year-section ul {
    list-style: none;
    padding: 0;
}

.year-section li {
    margin: 0;
}

.year-section .nav-link {
    display: block;
    padding: 8px 20px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.year-section .nav-link:hover,
.year-section .nav-link.active {
    background-color: var(--hover-color);
    border-left-color: var(--secondary-color);
    color: var(--secondary-color);
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    max-height: calc(100vh - 60px - 60px);
    min-width: 0;
}

.article {
    max-width: 1200px;
    line-height: 1.8;
}

.article h1 {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 32px;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 10px;
}

.article h2 {
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 24px;
}

.article h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 18px;
}

.article h4,
.article h5,
.article h6 {
    margin-top: 15px;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.article p {
    margin-bottom: 15px;
}

.article ul,
.article ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.article li {
    margin-bottom: 8px;
}

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

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

.article code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.article pre {
    background-color: #f4f4f4;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 15px;
    border-left: 4px solid var(--secondary-color);
}

.article pre code {
    background-color: transparent;
    padding: 0;
}

.article blockquote {
    border-left: 4px solid var(--secondary-color);
    padding-left: 15px;
    margin-left: 0;
    margin-bottom: 15px;
    color: #666;
    font-style: italic;
}

.article table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.article table th,
.article table td {
    border: 1px solid var(--border-color);
    padding: 10px;
    text-align: left;
}

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

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

/* Home Content */
.home-content {
    text-align: center;
}

.home-logo {
    max-width: 200px;
    height: auto;
    margin-bottom: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.home-content h2 {
    font-size: 36px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

.home-content > p {
    font-size: 18px;
    color: #666;
    margin-bottom: 40px;
}

.year-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.stat {
    background-color: var(--bg-color);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 32px;
    font-weight: bold;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: #666;
}

/* Chart Styles */
.chart-container {
    background-color: var(--bg-color);
    padding: 30px;
    border-radius: 8px;
    margin: 30px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    height: 400px;
    width: 100%;
}

.chart-container canvas {
    max-height: 400px;
}

.total-stats {
    text-align: center;
    margin-top: 20px;
    padding: 15px;
    background-color: var(--bg-color);
    border-radius: 5px;
}

.total-stats p {
    font-size: 18px;
    color: var(--primary-color);
}

/* About Content */
.about-content {
    max-width: 600px;
}

.about-content h2 {
    margin-bottom: 20px;
}

.about-content h3 {
    margin-top: 25px;
    margin-bottom: 15px;
}

.about-content p {
    margin-bottom: 15px;
}

.about-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.about-content li {
    margin-bottom: 10px;
}

/* Sidebar Right - TOC */
.sidebar-right {
    width: var(--toc-width);
    background-color: var(--bg-color);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px - 60px);
    padding: 20px 0;
}

.toc-title {
    padding: 15px 15px;
    font-weight: 600;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    margin-bottom: 10px;
}

.stats-panel {
    padding: 0 15px;
}

.stats-panel p {
    margin-bottom: 10px;
    font-size: 14px;
}

.toc {
    padding: 0 15px;
}

.toc-empty {
    padding: 15px;
    color: #999;
    font-size: 14px;
    text-align: center;
}

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

.toc li {
    margin: 0;
}

.toc a {
    display: block;
    padding: 6px 0 6px 12px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc a:hover {
    color: var(--secondary-color);
    border-left-color: var(--secondary-color);
    background-color: var(--hover-color);
}

.toc ul ul {
    margin-left: 0;
    padding-left: 0;
}

.toc ul ul a {
    padding-left: 24px;
    font-size: 13px;
}

.toc ul ul ul a {
    padding-left: 36px;
    font-size: 12px;
}

/* Footer */
.footer {
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 14px;
    margin-top: auto;
}

/* Footnotes */
.footnote {
    display: inline;
}

.footnote sup {
    font-size: 0.85em;
    margin: 0 2px;
}

.footnote a {
    color: var(--secondary-color);
    text-decoration: none;
    border-bottom: 1px dotted var(--secondary-color);
    transition: opacity 0.2s;
}

.footnote a:hover {
    opacity: 0.7;
}

/* Footnote list at bottom of article */
.footnotes {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
    color: #666;
}

.footnotes h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.footnotes ol {
    list-style: decimal;
    padding-left: 20px;
}

.footnotes li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.footnotes li p {
    margin: 0;
    display: inline;
}

.footnotes li a {
    color: var(--secondary-color);
    text-decoration: none;
    margin-left: 5px;
    font-weight: 500;
}

.footnotes li a:hover {
    text-decoration: underline;
}

.footnotes li a.footnote-backref {
    font-size: 0.9em;
}

/* Margin Notes - Inline with content */
.margin-note-inline {
    float: right;
    clear: right;
    width: 300px;
    margin: 0 0 20px 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-left: 3px solid var(--secondary-color);
    border-radius: 3px;
    font-size: 13px;
    line-height: 1.6;
    color: #555;
}

.margin-note-inline p {
    margin: 0 0 8px 0;
    font-size: 13px;
}

.margin-note-inline p:last-child {
    margin-bottom: 0;
}

.margin-note-inline a {
    color: var(--secondary-color);
    text-decoration: none;
}

.margin-note-inline a:hover {
    text-decoration: underline;
}

/* Responsive: Stack margin notes on tablets and below */
@media (max-width: 1200px) {
    .margin-note-inline {
        float: none;
        clear: both;
        width: 100%;
        margin: 15px 0 15px 0;
    }

    .sidebar-right {
        display: none;
    }
}

@media (max-width: 768px) {
    .navbar-container {
        flex-direction: column;
        height: auto;
        padding: 10px 15px;
        gap: 10px;
    }

    .navbar-nav {
        gap: 15px;
        width: 100%;
        justify-content: center;
    }

    .container {
        flex-direction: column;
    }

    .sidebar-left {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        position: relative;
        top: auto;
    }

    .sidebar-right {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
        height: auto;
        position: relative;
        top: auto;
    }

    .main-content {
        max-height: none;
        padding: 20px;
    }

    .year-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 300px;
        padding: 20px;
    }

    .home-logo {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 15px;
    }

    .article h1 {
        font-size: 24px;
    }

    .article h2 {
        font-size: 20px;
    }

    .year-stats {
        grid-template-columns: 1fr;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .sidebar-left,
    .sidebar-right,
    .footer {
        display: none;
    }

    .container {
        flex-direction: column;
    }

    .main-content {
        max-width: 100%;
        padding: 0;
    }
}
