/* 全局重置与基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
body {
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
}

/* 导航栏样式 */
nav {
    background: linear-gradient(135deg, #006600 0%, #11998e 100%);
    color: white;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 1.8rem;
    font-weight: 700;
}
.nav-links {
    display: flex;
    list-style: none;
}
.nav-links li {
    margin-left: 2rem;
    position: relative;
}
.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s;
    padding: 0.5rem 0;
    display: block;
}
.nav-links a:hover {
    opacity: 0.8;
}

/* 下拉菜单样式 */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    list-style: none;
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}
.dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown-menu li {
    margin: 0;
}
.dropdown-menu a {
    color: #333;
    padding: 0.75rem 1.5rem;
    display: block;
    transition: background-color 0.2s;
}
.dropdown-menu a:hover {
    background-color: #f5f5f5;
    opacity: 1;
}

/* 主内容区布局 */
.main-container {
    max-width: 1300px;
    margin: 30px auto;
    display: flex;
    gap: 30px;
    padding: 0 20px;
}

/* 左侧导航样式 */
.sidebar {
    flex: 0 0 250px;
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 80px;
    align-self: flex-start;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}
.sidebar h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2e7d32;
}
.sidebar ul {
    list-style: none;
}
.sidebar li {
    margin-bottom: 10px;
}
.sidebar a {
    color: #555;
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s;
}
.sidebar a:hover {
    background-color: #f0fff4;
    color: #1b5e20;
}
.sidebar a.active {
    background-color: #008800;
    color: white;
}

/* 右侧内容区样式 */
.content {
    flex: 1;
    background-color: white;
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    min-width: 0;
}

/* 组件相关样式 */
.component-title-link {
    color: #1b5e20;
    text-decoration: none;
    transition: color 0.3s ease;
    display: inline-block;
    position: relative;
}
.component-title-link:hover {
    color: #4caf50;
}
.component-title-link::after {
    content: "🔗";
    font-size: 0.8em;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}
.component-title-link:hover::after {
    opacity: 1;
}
.component-description {
    color: #666;
    margin-bottom: 1rem;
    font-style: italic;
}

/* 章节标题和内容样式 */
.section {
    margin-bottom: 50px;
}
.section:last-child {
    margin-bottom: 0;
}
.section h1 {
    color: #1a252f;
    margin: 0 0 25px 0;
    padding-bottom: 15px;
    border-bottom: 3px solid #1b5e20;
    font-size: 2.2em;
    font-weight: 700;
}
.section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4caf50;
}
.section h3 {
    color: #43a047;
    margin: 25px 0 15px;
}
.section h4 {
    color: #66bb6a;
    margin: 20px 0 10px;
}
.section p {
    margin-bottom: 15px;
    color: #555;
}
.section ul, .section ol {
    margin-left: 20px;
    margin-bottom: 15px;
}
.section li {
    margin-bottom: 8px;
}

/* Markdown内容样式 */
.markdown-content h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2e7d32;
}
.markdown-content h2 {
    color: #2c3e50;
    margin: 25px 0 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid #2e7d32;
}
.markdown-content h3 {
    color: #43a047;
    margin: 20px 0 10px;
}
.markdown-content p {
    margin-bottom: 15px;
    color: #555;
}
.markdown-content ul, .markdown-content ol {
    margin-left: 20px;
    margin-bottom: 15px;
}
.markdown-content li {
    margin-bottom: 8px;
}
.markdown-content blockquote {
    border-left: 4px solid #388e3c;
    padding-left: 15px;
    margin: 15px 0;
    color: #666;
    font-style: italic;
}
.markdown-content code {
    background: rgba(175, 184, 193, 0.2);
    border-radius: 3px;
    padding: 0.2em 0.4em;
    font-size: 0.9em;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
}
.markdown-content pre {
    background: #f6f8fa;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    padding: 16px;
    overflow: auto;
    margin: 1em 0;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre;
    overflow-x: auto;
}
.markdown-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    white-space: pre;
    display: block;
    overflow-x: auto;
}

/* Markdown表格样式 */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    font-size: 0.95em;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    overflow: hidden;
}
.markdown-content table thead th {
    background-color: #00aa00;
    color: white;
    font-weight: 600;
    border-bottom: none;
    text-align: center;
}
.markdown-content th, .markdown-content td {
    padding: 12px 15px;
    text-align: left;
    border: 1px solid #e1e4e8;
}
.markdown-content th {
    background-color: #f6f8fa;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #e1e4e8;
}
.markdown-content tr:nth-child(even) {
    background-color: #f8f9fa;
}
.markdown-content tr:hover {
    background-color: #e8f5e9;
    transition: background-color 0.2s ease;
}
.markdown-content table th:first-child, .markdown-content table td:first-child {
    border-left: none;
}
.markdown-content table th:last-child, .markdown-content table td:last-child {
    border-right: none;
}
.markdown-content table th[align="left"], .markdown-content table td[align="left"] {
    text-align: left;
}
.markdown-content table th[align="center"], .markdown-content table td[align="center"] {
    text-align: center;
}
.markdown-content table th[align="right"], .markdown-content table td[align="right"] {
    text-align: right;
}

/* 图片和媒体样式 */
.markdown-content img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.markdown-content figure {
    text-align: center;
    margin: 1.5em auto;
    max-width: 100%;
}
.markdown-content figure img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}
.markdown-content figcaption {
    font-style: italic;
    color: #666;
    margin-top: 0.5em;
    font-size: 0.9em;
}

/* 图片画廊样式 */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.gallery-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid #e8f5e9;
}
.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-color: #4caf50;
}
.gallery-item img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}
.image-caption {
    padding: 15px;
    background-color: #f8f9fa;
    text-align: center;
    font-weight: 500;
    color: #555;
}

/* 单张图片样式 */
.single-image-container {
    text-align: center;
    margin: 2rem 0;
}
.single-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.image-caption {
    margin-top: 0.5rem;
    font-style: italic;
    color: #666;
    font-size: 0.9rem;
}

/* 视频样式 */
.video-container {
    margin-top: 20px;
    text-align: center;
}
.responsive-video {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.video-caption {
    margin-top: 15px;
    font-style: italic;
    color: #666;
}

/* 下载列表样式 */
.download-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 1rem;
    background: #f9f9f9;
}
.download-item .file-info h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}
.download-item .file-size {
    color: #666;
    font-size: 0.9rem;
}
.download-item .file-name {
    color: #666;
    font-size: 0.9rem;
}
.download-button {
    background: #27ae60;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}
.download-button:hover {
    background: #1e8449;
}
.access-button {
    background: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}
.access-button:hover {
    background: #0056b3;
}
.missing-badge {
    background: #ffccbc;
    color: #d84315;
    padding: 0.12rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
}
.missing-link {
    background: #e0e0e0;
    color: #757575;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.3s;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

/* mermaid图表样式 */
.mermaid {
    margin: 20px 0;
    text-align: center;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #eaeaea;
}
.markdown-content .mermaid {
    text-align: center;
    margin: 2em 0;
    padding: 1em;
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    overflow: auto;
}
.markdown-content .mermaid svg {
    max-width: 100%;
    height: auto;
}

/* html嵌套样式 */
.web-component-container {
    width: 100%;
    margin: 1rem 0;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
}
.web-component-frame {
    width: 100%;
    border: none;
    display: block;
    background: white;
    min-height: 400px;
    flex: 1;
    transition: height 0.3s ease;
}

/* 加载状态样式 */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-style: italic;
}
.component-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    height: 200px;
    background: #f8f9fa;
}
.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f1f8e9;
    border-top: 4px solid #2e7d32;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.component-loading p {
    color: #666;
    margin: 0;
}
.component-caption {
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-top: 1px solid #e1e4e8;
    color: #666;
    font-size: 0.9rem;
    text-align: center;
}
.web-component-container {
    max-width: 100%;
}

/* 移动端导航切换按钮 */
.mobile-nav-toggle {
    display: none;
    font-size: 1.2rem;
    cursor: pointer;
    font-weight: 500;
    margin-left: 15px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }
    .sidebar {
        position: static;
        max-height: none;
    }
    .content {
        padding: 25px;
    }
    .mobile-menu {
        font-size: 1.4rem;
        font-weight: 600;
        display: block;
    }
    .nav-links {
        display: none;
        position: absolute;
        top: 78px;
        left: 0;
        right: 0;
        background-color: #2c3e50;
        flex-direction: column;
        padding: 20px;
    }
    .nav-links.active {
        display: flex;
    }
    .nav-links li {
        margin: 10px 0;
    }
    .image-gallery {
        grid-template-columns: 1fr;
    }
    .web-component-frame {
        min-height: 300px;
    }
    .mobile-nav-toggle {
        display: block;
    }
    .sidebar {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        width: 80%;
        max-width: 300px;
        height: calc(100vh - 78px);
        z-index: 99;
        border-radius: 0;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    .sidebar.active {
        display: block;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 98;
    }
    .sidebar-overlay.active {
        display: block;
    }
    .markdown-content table::after {
        content: '→';
        position: absolute;
        right: 10px;
        top: 50%;
        transform: translateY(-50%);
        color: #4caf50;
        font-size: 20px;
        opacity: 0.7;
    }
    .markdown-content table {
        display: block;
        width: 100%;
        table-layout: auto;
        overflow-x: auto;
        white-space: normal;
        border-collapse: collapse;
        margin: 1em 0;
    }
    .markdown-content th, .markdown-content td {
        padding: 8px 12px;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: normal;
        min-width: 80px;
    }
}