/**
 * 前台样式
 */

/* 布局 */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* 侧边栏 */
#sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e5e6eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e5e6eb;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 20px;
    color: #1d2129;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* 分类项 */
.category-item {
    margin-bottom: 5px;
}

.category-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.category-header:hover {
    background: #f7f8fa;
}

.category-icon {
    margin-right: 8px;
    font-size: 16px;
}

.category-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #1d2129;
}

.toggle-icon {
    font-size: 12px;
    color: #86909c;
    transition: transform 0.2s;
}

.category-item.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.category-item.collapsed .document-list,
.category-item.collapsed .category-children {
    display: none;
}

/* 文档列表 */
.document-list {
    margin-left: 24px;
    margin-top: 5px;
}

.document-item {
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.document-item:hover {
    background: #f7f8fa;
}

.document-item.active {
    background: #e8f3ff;
    color: #165dff;
}

.document-title {
    font-size: 13px;
}

/* 子分类 */
.category-children {
    margin-left: 16px;
    margin-top: 5px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 搜索容器 */
#search-container {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e6eb;
    background: #fff;
    position: relative;
}

.search-box {
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e5e6eb;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: #165dff;
}

.search-btn {
    padding: 8px 16px;
    background: #165dff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.search-btn:hover {
    background: #4080ff;
}

/* 搜索结果 */
.search-results {
    position: absolute;
    top: 100%;
    left: 20px;
    right: 20px;
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 5px;
}

.search-results.hidden {
    display: none;
}

.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f2f3f5;
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f7f8fa;
}

.result-title {
    margin: 0 0 5px 0;
    font-size: 14px;
    color: #1d2129;
}

.result-title mark {
    background: #ffe58f;
    padding: 0 2px;
}

.result-category {
    margin: 0 0 5px 0;
    font-size: 12px;
    color: #86909c;
}

.result-excerpt {
    margin: 0;
    font-size: 13px;
    color: #4e5969;
    line-height: 1.6;
}

.result-excerpt mark {
    background: #ffe58f;
    padding: 0 2px;
}

.no-results {
    padding: 30px;
    text-align: center;
    color: #86909c;
}

/* 文档查看器 */
#document-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: #fff;
}

.document-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e6eb;
}

.document-title {
    margin: 0 0 15px 0;
    font-size: 28px;
    color: #1d2129;
    line-height: 1.4;
}

.document-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: #86909c;
}

.category-badge {
    padding: 2px 8px;
    background: #f2f3f5;
    border-radius: 3px;
    color: #4e5969;
}

/* 文档内容 */
.document-content {
    font-size: 15px;
    line-height: 1.8;
    color: #4e5969;
}

.document-content h1,
.document-content h2,
.document-content h3,
.document-content h4,
.document-content h5,
.document-content h6 {
    margin: 24px 0 16px 0;
    color: #1d2129;
    line-height: 1.4;
}

.document-content h1 { font-size: 24px; }
.document-content h2 { font-size: 22px; }
.document-content h3 { font-size: 20px; }
.document-content h4 { font-size: 18px; }
.document-content h5 { font-size: 16px; }
.document-content h6 { font-size: 15px; }

.document-content p {
    margin: 12px 0;
}

.document-content ul,
.document-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.document-content li {
    margin: 6px 0;
}

.document-content a {
    color: #165dff;
    text-decoration: none;
}

.document-content a:hover {
    text-decoration: underline;
}

.document-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 16px 0;
}

.document-content code {
    padding: 2px 6px;
    background: #f2f3f5;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.document-content pre {
    padding: 16px;
    background: #f2f3f5;
    border-radius: 4px;
    overflow-x: auto;
    margin: 16px 0;
}

.document-content pre code {
    padding: 0;
    background: none;
}

.document-content blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 4px solid #165dff;
    background: #f7f8fa;
    color: #4e5969;
}

.document-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.document-content table th,
.document-content table td {
    padding: 10px;
    border: 1px solid #e5e6eb;
    text-align: left;
}

.document-content table th {
    background: #f7f8fa;
    font-weight: 500;
}

.document-content mark {
    background: #ffe58f;
    padding: 0 2px;
}

/* 加载和错误状态 */
.loading-container,
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: #86909c;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

/* 移动端菜单按钮 */
#menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    padding: 10px;
    background: #fff;
    border: 1px solid #e5e6eb;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.3s;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }
    
    #sidebar.mobile-open {
        left: 0;
    }
    
    #menu-toggle {
        display: block;
    }
    
    #document-viewer {
        padding: 60px 15px 15px 15px;
    }
    
    .document-title {
        font-size: 22px;
    }
    
    .document-content {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .document-meta {
        flex-direction: column;
        gap: 5px;
    }
}
