/* 基础样式 - 扁平化设计 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
}

body {
    background-color: #f0f2f5;
    min-height: 100vh;
    padding: 20px;
    font-family: "Microsoft YaHei", "微软雅黑", Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 90vh;
}

/* 头部样式 - 扁平化设计 */
.header {
    background: #1f4977;
    color: white;
    padding: 1rem 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    border-bottom: 3px solid #0d2a4a;
    margin: 0 !important;
    width: 100% !important;
    position: relative;
    top: 0;
    left: 0;
    right: 0;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.header h1 a {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.header h1 a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.header p {
    opacity: 0.9;
    margin: 0 auto;
    line-height: 1.5;
	font-size: small;
}

/* 导航菜单 - 扁平化设计 */
.main-nav {
    margin-top: 0 !important;
    border-top: none !important;
    padding-top: 0 !important;
}

.main-nav ul {
    list-style: none !important;
    display: flex !important;
    gap: 0.5rem !important;
    flex-wrap: wrap !important;
    margin: 0 !important;
    padding: 0 !important;
}

.main-nav li {
    margin: 0 !important;
    padding: 0 !important;
}

.nav-link {
    color: white !important;
    text-decoration: none !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0 !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    transition: background-color 0.2s ease, opacity 0.2s ease !important;
    display: inline-block !important;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    opacity: 0.9 !important;
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2) !important;
    font-weight: 600 !important;
    border-left: 3px solid white !important;
}

/* 主布局 */
.main-layout {
    display: flex;
    min-height: 700px;
}

/* 侧边栏样式 - 扁平化设计 */
.sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 2px solid #dee2e6;
    padding: 1rem;
    height: calc(100vh - 120px);
    overflow-y: auto;
}

.section-title {
    color: #1f4977;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #dee2e6;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 文档选择器 - 扁平化设计 */
.doc-selector {
    margin-bottom: 1rem;
}

#docSelect {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 2px solid #ced4da;
    border-radius: 0;
    background: white;
    font-size: 1rem;
    color: #495057;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

#docSelect:focus {
    outline: none;
    border-color: #1f4977;
}

.doc-selector::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 0.375rem solid transparent;
    border-right: 0.375rem solid transparent;
    border-top: 0.375rem solid #495057;
    pointer-events: none;
}

/* 目录树 - 扁平化设计 */
.toc-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.toc-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.toc-search {
    padding: 0.75rem 1rem;
    border: 2px solid #ced4da;
    border-radius: 0;
    font-size: 0.875rem;
    width: 100%;
    margin-bottom: 1rem;
    transition: border-color 0.2s ease;
}

.toc-search:focus {
    outline: none;
    border-color: #1f4977;
}

.toc-tree {
    flex: 1;
    overflow-y: auto;
    border: 2px solid #dee2e6;
    border-radius: 0;
    background-color: #fff;
    padding: 0.5rem;
}

.toc-group {
    margin-bottom: 0.5rem;
    border: 2px solid #dee2e6;
    border-radius: 0;
    overflow: hidden;
}

.toc-group-header {
    padding: 0.75rem 1rem;
    background-color: #f8f9fa;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #1f4977;
    border-bottom: 1px solid #dee2e6;
    transition: background-color 0.15s ease-in-out;
    /* 限制目录组标题为10个字 */
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-group-header:hover {
    background-color: #e9ecef;
}

.toc-group-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: #fff;
}

.toc-group.expanded .toc-group-content {
    max-height: 500px;
}

.toc-group-toggle {
    font-size: 0.75rem;
    transition: transform 0.3s;
}

.toc-group.expanded .toc-group-toggle {
    transform: rotate(180deg);
}

.toc-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f4;
    font-size: 0.875rem;
    color: #495057;
    display: flex;
    align-items: flex-start;
    transition: background-color 0.15s ease-in-out;
    /* 限制目录项文本为10个字 */
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-item:last-child {
    border-bottom: none;
}

.toc-item:hover {
    background-color: #f8f9fa;
}

.toc-item.active {
    background-color: #e7f1ff;
    color: #1f4977;
    font-weight: 500;
    border-left: 3px solid #1f4977;
}

.toc-item-icon {
    margin-right: 0.5rem;
    color: #1f4977;
    font-size: 1rem;
}

/* 主内容区 - Bootstrap 风格 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
}

/* 搜索框 - 扁平化设计 */
.search-box {
    background-color: #fff;
    border-radius: 0;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.search-container {
    position: relative;
    display: flex;
    gap: 1rem;
}

#searchInput {
    flex: 1;
    padding: 0.75rem 1rem;
    padding-left: 3rem;
    border: 2px solid #ced4da;
    border-radius: 0;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

#searchInput:focus {
    outline: none;
    border-color: #1f4977;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #1f4977;
    font-size: 1.25rem;
}

.search-btn {
    background-color: #1f4977;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-btn:hover {
    background-color: #2a5a8f;
}

/* 搜索结果 - 扁平化设计 */
.results-section {
    background-color: #fff;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.results-header {
    background-color: #f8f9fa;
    padding: 1.25rem 1.5rem;
    border-bottom: 2px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-stats {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1f4977;
}

.stat-label {
    font-size: 0.8125rem;
    color: #6c757d;
}

.view-toggle {
    display: flex;
    background-color: #b2bbba;
    border-radius: 0;
    padding: 0.25rem;
}

.view-toggle button {
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    border-radius: 0;
    cursor: pointer;
    font-size: 0.875rem;
    color: #6c757d;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.view-toggle button.active {
    background-color: #1f4977;
    color: #fff;
}

/* 内容显示区 - 扁平化设计 */
.content-display {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.content-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.content-title {
    color: #1f4977;
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #dee2e6;
}

/* 限制页面内容中的标题为10个字 */
.page-content h2 {
    /* 限制标题文本为10个字 */
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-body {
    line-height: 1.8;
    font-size: 1rem;
    color: #333;
}

.content-body h1, .content-body h2, .content-body h3 {
    color: #1f4977;
    margin: 1.5rem 0 1rem;
}

.content-body p {
    margin-bottom: 1rem;
}

/* 图片响应式样式 - 解决图片过宽问题 */
.content-body img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 如果图片在表格中，特殊处理 */
.content-body table img {
    max-width: 100%;
    height: auto;
    margin: 0.5rem 0;
}

/* 强制重置页面内容的字体大小，防止BLUE引擎等文档的内联样式影响 */
.content-body,
.content-body * {
    /* 强制字体大小，优先级最高 */
    font-size: 1rem !important;
    line-height: 1.8 !important;
    font-weight: normal !important;
}

/* 特别重置可能影响字体大小的所有标签 */
.content-body html,
.content-body body,
.content-body div,
.content-body span,
.content-body p,
.content-body table,
.content-body td,
.content-body th,
.content-body tr,
.content-body font {
    font-size: inherit !important;
    line-height: inherit !important;
    font-weight: inherit !important;
}

/* 特别处理BLUE引擎文档的内联样式 - 强制覆盖所有可能的字体大小设置 */
.content-body *[style*="font-size"] {
    font-size: 1rem !important;
    line-height: 1.8 !important;
}

/* 处理pt单位的字体大小 */
.content-body *[style*="font-size: 11pt"] {
    font-size: 1rem !important;
}

/* 处理px单位的字体大小 */
.content-body *[style*="font-size: 12px"],
.content-body *[style*="font-size: 14px"],
.content-body *[style*="font-size: 16px"],
.content-body *[style*="font-size: 18px"],
.content-body *[style*="font-size: 20px"],
.content-body *[style*="font-size: 22px"],
.content-body *[style*="font-size: 24px"],
.content-body *[style*="font-size: 26px"],
.content-body *[style*="font-size: 28px"],
.content-body *[style*="font-size: 30px"] {
    font-size: 1rem !important;
}

/* 特别处理WinCHM模板的标题 */
.content-body #winchm_template_title {
    font-size: 1.1rem !important;
    font-weight: bold !important;
    color: #1f4977 !important;
    margin: 1rem 0 !important;
}

/* 重置页面内容中的常见标题字体大小 */
.content-body h1 {
    font-size: 1.5rem !important;
    line-height: 1.4 !important;
    margin: 1.5rem 0 1rem !important;
}

.content-body h2 {
    font-size: 1.3rem !important;
    line-height: 1.4 !important;
    margin: 1.3rem 0 0.8rem !important;
}

.content-body h3 {
    font-size: 1.1rem !important;
    line-height: 1.4 !important;
    margin: 1.1rem 0 0.6rem !important;
}

.content-body h4, .content-body h5, .content-body h6 {
    font-size: 1rem !important;
    line-height: 1.4 !important;
    margin: 1rem 0 0.5rem !important;
}

/* 重置页面内容中的字体大小标签 */
.content-body font[size="1"] { font-size: 0.7rem !important; }
.content-body font[size="2"] { font-size: 0.8rem !important; }
.content-body font[size="3"] { font-size: 0.9rem !important; }
.content-body font[size="4"] { font-size: 1rem !important; }
.content-body font[size="5"] { font-size: 1.2rem !important; }
.content-body font[size="6"] { font-size: 1.4rem !important; }
.content-body font[size="7"] { font-size: 1.6rem !important; }

/* 防止大字体影响布局 */
.content-body * {
    max-width: 100%;
}

/* 特别处理WINCHM模板元素 */
.content-body #winchm_template_title {
    font-size: 1.1rem !important;
    font-weight: bold !important;
    color: #1f4977 !important;
    margin: 1rem 0 !important;
}

.content-body #winchm_template_navigation {
    font-size: 0.8rem !important;
    color: #666 !important;
    margin: 0.5rem 0 !important;
    padding: 0.5rem 0 !important;
}

.content-body #winchm_template_content {
    font-size: 1rem !important;
    line-height: 1.6 !important;
}

/* 确保内容容器不会超出宽度 */
.content-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    max-width: 100%;
    word-wrap: break-word;
}

/* 主内容区域防止水平滚动 */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    max-width: 100%;
    overflow-x: hidden;
}

.content-body code {
    background-color: #f8f9fa;
    padding: 0.125rem 0.25rem;
    border-radius: 0;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.875rem;
}

.content-body pre {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 0;
    overflow-x: auto;
    margin: 1rem 0;
    border-left: 3px solid #1f4977;
}

/* 搜索结果列表 - 扁平化设计 */
.results-list {
    max-height: 600px;
    overflow-y: auto;
    padding: 1.25rem;
}

.result-item {
    background-color: #f8f9fa;
    border-radius: 0;
    padding: 1.25rem;
    margin-bottom: 1rem;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.result-item:hover {
    border-color: #1f4977;
}

.result-title {
    color: #1f4977;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.result-content {
    color: #495057;
    line-height: 1.6;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.result-path {
    color: #6c757d;
    font-size: 0.8125rem;
    font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    background-color: #e9ecef;
    padding: 0.25rem 0.5rem;
    border-radius: 0;
    display: inline-block;
}

/* 高亮样式 - 扁平化设计 */
.highlight {
    background: #fffacd;
    padding: 2px 5px;
    border-radius: 0;
    font-weight: bold;
    color: #c94c00;
    border: 1px solid #ffd700;
}

/* 搜索高亮动画 */
.highlight-animation {
    animation: highlight-pulse 2s infinite;
}

@keyframes highlight-pulse {
    0%, 100% { background-color: #fffacd; }
    50% { background-color: #ffeb3b; }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state h3 {
    color: #2e4a7c;
    margin: 20px 0 10px;
}

/* 页脚 */
.footer {
    text-align: center;
    padding: 20px;
    color: #666;
    background: #f8f9ff;
    border-top: 1px solid #e0e6ff;
}

/* 响应式设计 */
@media (max-width: 1024px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e6ff;
    }
}

@media (max-width: 768px) {
    .search-container {
        flex-direction: column;
    }
    
    .search-btn {
        width: 100%;
    }
    
    .results-stats {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    /* 导航菜单响应式设计 */
    .main-nav ul {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }
    
    .nav-link {
        width: 100% !important;
        text-align: center !important;
        padding: 0.75rem 1rem !important;
    }
}

/* 分页控制 */
.toc-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e6ff;
}

.toc-page-btn {
    padding: 8px 16px;
    border: 1px solid #e0e6ff;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    color: #2e4a7c;
    font-size: 14px;
}

.toc-page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toc-page-info {
    font-size: 14px;
    color: #666;
}