/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

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

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

/* 头部样式 */
.header {
    background: #2c3e50;
    color: white;
    padding: 1rem 0;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.current-file {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* 布局样式 */
.layout {
    display: flex;
    gap: 2rem;
    min-height: calc(100vh - 120px);
}

/* 侧边栏样式 */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1.5rem;
    height: fit-content;
    position: sticky;
    top: 2rem;
}

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

.file-list ul {
    list-style: none;
}

.file-list li {
    margin-bottom: 0.5rem;
}

.file-list a {
    display: block;
    padding: 0.5rem 0.8rem;
    text-decoration: none;
    color: #555;
    border-radius: 4px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
    word-break: break-all;
}

.file-list a:hover {
    background: #f8f9fa;
    color: #2c3e50;
    border-left-color: #3498db;
}

.file-list li.active a {
    background: #e3f2fd;
    color: #1976d2;
    border-left-color: #1976d2;
    font-weight: 500;
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    min-width: 0; /* 防止flex项目溢出 */
}

.markdown-content {
    padding: 2rem;
    max-width: 100%;
    overflow-wrap: break-word;
}

.markdown-content img {
    height: 100%;
    width: 100;
}

/* Markdown内容样式 */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin: 1.5rem 0 1rem 0;
    color: #2c3e50;
    line-height: 1.3;
}

.markdown-content h1 {
    font-size: 2rem;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

.markdown-content h2 {
    font-size: 1.6rem;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.3rem;
}

.markdown-content h3 {
    font-size: 1.3rem;
}

.markdown-content p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

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

.markdown-content li {
    margin-bottom: 0.3rem;
}

.markdown-content blockquote {
    border-left: 4px solid #3498db;
    background: #f8f9fa;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
}

.markdown-content code {
    background: #f1f3f4;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.markdown-content pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1.5rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1.5rem 0;
}

.markdown-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    overflow-x: auto;
    display: block;
}

.markdown-content th,
.markdown-content td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid #e2e8f0;
}

.markdown-content th {
    background: #f7fafc;
    font-weight: 600;
}

.markdown-content tr:nth-child(even) {
    background: #f8f9fa;
}

.markdown-content a {
    color: #3498db;
    text-decoration: none;
}

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

/* 图片容器样式 */
.image-container {
    margin: 2rem 0;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
}

.markdown-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    cursor: zoom-in;
    transition: all 0.3s ease;
    display: inline-block;
}

.markdown-image:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0,0,0,0.2);
}

/* 图片模态框样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.95);
    animation: fadeIn 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    max-width: 95%;
    max-height: 95vh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
}

.close {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.3s ease;
    background: rgba(0,0,0,0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close:hover {
    color: #ccc;
    background: rgba(0,0,0,0.7);
}

.image-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin: 20px 0;
    max-height: calc(95vh - 160px);
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

.modal-caption {
    color: white;
    text-align: center;
    font-size: 1.1rem;
    padding: 10px 0;
    margin-top: 10px;
    background: rgba(0,0,0,0.5);
    border-radius: 4px;
}

.modal-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.modal-btn {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-weight: 500;
}

.modal-btn:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 无文件状态 */
.no-files {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

.no-files h2 {
    margin-bottom: 1rem;
}

/* 错误样式 */
.error {
    background: #fee;
    color: #c33;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #c33;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
        padding: 0 15px;
    }
    
    .layout {
        gap: 1rem;
    }
    
    .sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
    }
    
    .markdown-content {
        padding: 1rem;
    }
    
    .header {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .modal-content {
        max-width: 98%;
        padding: 10px;
    }
    
    .modal-controls {
        gap: 10px;
    }
    
    .modal-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .close {
        top: 10px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 30px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .markdown-content {
        padding: 0.5rem;
    }
    
    .modal-controls {
        bottom: 50px;
    }
    
    .modal-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
    
    .image-wrapper {
        max-height: calc(95vh - 140px);
    }
}