/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 头部样式 */
.header {
    background-color: #fff;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1001;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #333;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.sidebar-toggle-btn:hover {
    background-color: #f0f0f0;
}

.header h1 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0;
}

.path-display {
    font-size: 0.9rem;
    color: #666;
}

.path {
    font-weight: bold;
    color: #3498db;
}

/* 主内容区域 */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* 侧边栏样式 */
.sidebar {
    width: 300px;
    background-color: #FFFFFF;
    color: #333333;
    overflow-y: auto;
    border-right: 1px solid #e0e0e0;
    position: fixed;
    left: -300px;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease-in-out;
}

.sidebar.show {
    left: 0;
}

/* 侧边栏遮罩 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    transition: opacity 0.3s ease-in-out;
}

.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f8f9fa;
}

.sidebar-header h3 {
    font-size: 1rem;
    color: #333333;
}

/* 文件树样式 */
.file-tree {
    padding: 0.5rem 0;
}

.tree-item {
    position: relative;
}

.tree-toggle {
    position: absolute;
    left: 0.5rem;
    top: 0.5rem;
    width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666666;
    text-decoration: none;
    z-index: 1;
    cursor: pointer;
}

.tree-link {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem 0.25rem 2rem;
    color: #333333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.tree-link:hover {
    background-color: #f0f0f0;
}

.tree-link i {
    margin-right: 0.5rem;
    width: 1rem;
    text-align: center;
    color: #666666;
}

.tree-children {
    padding-left: 1rem;
}

/* TOC 目录样式 */
.toc-children {
    background-color: #f8f9fa;
    border-left: 2px solid #3498db;
}

.toc-header {
    padding: 0.5rem 0.75rem;
    background-color: #f0f0f0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333333;
    border-bottom: 1px solid #e0e0e0;
}

.toc-header h4 {
    margin: 0;
    font-size: 0.8rem;
}

.toc-item {
    font-size: 0.8rem;
    color: #333333;
    transition: background-color 0.2s;
}

.toc-item:hover {
    background-color: #e8f4fc;
}

.toc-item i {
    color: #666666;
    width: 1rem;
    text-align: center;
}

.toc-toggle-icon {
    color: #666666;
    font-size: 0.8rem;
}

/* 内容区域样式 */
.content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background-color: #ecf0f1;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #bdc3c7;
}

.content-header h2 {
    font-size: 1.2rem;
    color: #2c3e50;
}

.content-header a {
    color: #3498db;
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    margin-left: 1rem;
}

.content-header a i {
    margin-right: 0.25rem;
}

.content-header .back-button {
    background-color: #3498db;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.content-header .back-button:hover {
    background-color: #2980b9;
}

/* 文件列表样式 */
.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.file-item {
    background-color: #fff;
    border-radius: 4px;
    padding: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
}

.file-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.file-item.directory {
    border-left: 4px solid #3498db;
}

.file-item.file {
    border-left: 4px solid #95a5a6;
}

.file-icon {
    font-size: 2rem;
    margin-right: 1rem;
    color: #7f8c8d;
}

.file-item.directory .file-icon {
    color: #3498db;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: bold;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #7f8c8d;
}

/* 文件内容预览样式 */
.file-content {
    background-color: #fff;
    border-radius: 4px;
    padding: 1rem;
    min-height: 300px;
    display: none;
}

.file-content.active {
    display: block;
}

.file-list.hidden {
    display: none;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #bdc3c7;
}

.preview-header h3 {
    font-size: 1rem;
    color: #2c3e50;
}

.preview-header a {
    color: #3498db;
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.preview-header a i {
    margin-right: 0.25rem;
}

/* 图片预览 */
.image-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.image-preview img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 文本预览 */
.text-preview {
    max-height: 500px;
    overflow-y: auto;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.text-preview pre {
    margin: 0;
    padding: 1rem;
}

.text-preview code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #2c3e50;
}

/* PDF预览 */
.pdf-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.pdf-preview embed {
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

/* 视频预览 */
.video-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.video-preview video {
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 音频预览 */
.audio-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.audio-preview audio {
    width: 100%;
    max-width: 500px;
}

/* 文件信息 */
.file-info {
    text-align: center;
    padding: 2rem;
}

.file-info p {
    margin-bottom: 1rem;
    color: #7f8c8d;
}

.file-info a {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: #3498db;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.file-info a:hover {
    background-color: #2980b9;
}

.file-info a i {
    margin-right: 0.5rem;
}

/* 加载状态 */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #7f8c8d;
    font-size: 1.2rem;
}

.loading i {
    margin-right: 0.5rem;
}

/* 错误状态 */
.error {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: #e74c3c;
    font-size: 1.2rem;
}

.error i {
    margin-right: 0.5rem;
}

/* Markdown预览样式 */
.markdown-preview {
    padding: 1rem;
    line-height: 1.6;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3, .markdown-preview h4, .markdown-preview h5, .markdown-preview h6 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.markdown-preview h1 {
    font-size: 1.8rem;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3rem;
}

.markdown-preview h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3rem;
}

.markdown-preview h3 {
    font-size: 1.25rem;
}

.markdown-preview p {
    margin-bottom: 1rem;
}

.markdown-preview ul, .markdown-preview ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.markdown-preview li {
    margin-bottom: 0.5rem;
}

.markdown-preview code {
    background-color: #f6f8fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.9rem;
}

.markdown-preview pre {
    background-color: #f6f8fa;
    padding: 1rem;
    border-radius: 3px;
    overflow-x: auto;
    margin-bottom: 1rem;
}

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

.markdown-preview blockquote {
    border-left: 4px solid #ddd;
    padding-left: 1rem;
    color: #666;
    margin-bottom: 1rem;
}

.markdown-preview table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 1rem;
}

.markdown-preview th, .markdown-preview td {
    border: 1px solid #ddd;
    padding: 0.5rem;
    text-align: left;
}

.markdown-preview th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.markdown-preview img {
    max-width: 100%;
    height: auto;
    border-radius: 3px;
}

.markdown-preview a {
    color: #0366d6;
    text-decoration: none;
}

.markdown-preview a:hover {
    text-decoration: underline;
}

/* Markdown内容包装器 */
.markdown-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 目录样式 */
.toc-container {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-top: 1rem;
}

.toc-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f0f0f0;
}

.toc-header h4 {
    margin: 0;
    font-size: 1rem;
    color: #333333;
}

.toc-content {
    padding: 0.5rem 0;
    max-height: 300px;
    overflow-y: auto;
}

.toc-item {
    display: block;
    padding: 0.5rem 1rem;
    color: #333333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.toc-item:hover {
    background-color: #e8f4fc;
    border-left-color: #3498db;
}

.toc-item.toc-level-1 {
    font-weight: 600;
}

.toc-item.toc-level-2 {
    font-weight: 500;
}

.toc-item.toc-level-3,
.toc-item.toc-level-4,
.toc-item.toc-level-5,
.toc-item.toc-level-6 {
    font-weight: normal;
}

.toc-empty {
    padding: 1rem;
    color: #999999;
    font-size: 0.9rem;
    text-align: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
        height: 100vh;
    }
    
    .file-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}