/* ==============================================================
 * 文档管理系统 全局样式表
 * 路径：/域名或IP地址/-System/index.css
 * 功能：统一管理所有页面样式，按模块划分，便于维护
 * ============================================================== */

/* -------------------------- 全局CSS变量 -------------------------- */
:root {
    /* 字体设置 */
    --primary-font: "Microsoft YaHei", sans-serif;
    --base-font-size: 16px;
    --base-line-height: 1.6;
    --primary-text-color: #364863;
    
    /* Markdown字体设置 */
    --markdown-font-size: 17px;
    --markdown-line-height: 1.8;
    --h1-font-size: 31px;
    --h2-font-size: 27px;
    --h3-font-size: 23px;
    --h4-font-size: 20px;
    --h5-font-size: 18px;
    --h6-font-size: 16px;
}

/* 字体加载完成后更新字体变量 */
.font-loaded {
    --primary-font: 'CustomFont', "Microsoft YaHei", sans-serif;
}

/* -------------------------- 全局样式重置 & 基础配置 -------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--primary-font);
    font-size: var(--base-font-size);
    line-height: var(--base-line-height);
    color: var(--primary-text-color);
}

/* 确保字体回退行为正确 */
body {
    font-family: var(--primary-font);
    font-size: var(--base-font-size);
    line-height: var(--base-line-height);
    color: var(--primary-text-color);
}

/* -------------------------- Markdown内容字体大小 -------------------------- */
.markdown-body {
    font-size: var(--markdown-font-size);
    line-height: var(--markdown-line-height);
}

.markdown-body h1 {
    font-size: var(--h1-font-size);
}

.markdown-body h2 {
    font-size: var(--h2-font-size);
}

.markdown-body h3 {
    font-size: var(--h3-font-size);
}

.markdown-body h4 {
    font-size: var(--h4-font-size);
}

.markdown-body h5 {
    font-size: var(--h5-font-size);
}

.markdown-body h6 {
    font-size: var(--h6-font-size);
}

/* -------------------------- 顶部菜单栏样式 -------------------------- */
.top-menu {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 60px;
}

/* -------------------------- 主内容区域布局 -------------------------- */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f5f7fa;
    margin-top: 60px;
}

/* 内容展示区域 */
.content-area {
    flex: 1;
    padding: 20px 40px;
    overflow-y: auto;
    background: #ffffff;
    margin-top: 0;
}

.menu-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 30px;
    max-width: 100%;
}

/* 顶部控制按钮样式 */
.menu-controls {
    display: flex;
    align-items: center;
}

.menu-toggle-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(22, 119, 255, 0.1);
    color: #1677ff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.menu-toggle-btn:hover {
    background: rgba(22, 119, 255, 0.2);
    transform: scale(1.05);
}

/* 左侧边栏导航 */
.sidebar {
    width: 22%;
    min-width: 200px;
    max-width: 60%;
    border-right: 1px solid #e5e7eb;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
    position: relative;
    flex-shrink: 0;
}

/* 大纲容器样式 */
.outline-container {
    width: 20%;
    min-width: 180px;
    max-width: 400px;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.03);
    display: none;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

/* PC端默认展开大纲 */
@media (min-width: 1025px) {
    .outline-container {
        display: flex;
    }
}

/* 移动端浮窗侧边栏样式 */
.mobile-sidebar,
.mobile-outline {
    position: fixed;
    top: 60px;
    height: calc(100vh - 60px);
    width: 280px;
    background: white;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.15);
    z-index: 3000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.mobile-sidebar {
    left: 0;
    transform: translateX(-100%);
}

.mobile-sidebar.active {
    transform: translateX(0);
}

.mobile-outline {
    right: 0;
    transform: translateX(100%);
}

.mobile-outline.active {
    transform: translateX(0);
}

.mobile-sidebar-header,
.mobile-outline-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f5f7fa;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 移动端大纲容器关闭按钮样式 */
.mobile-outline-header .mobile-outline-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(22, 119, 255, 0.1);
    color: #1677ff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-outline-header .mobile-outline-close:hover {
    background: rgba(22, 119, 255, 0.2);
    transform: scale(1.05);
}

/* 确保在移动端正常情况下不显示浮窗 */
@media (max-width: 1024px) {
    .mobile-sidebar,
    .mobile-outline {
        transform: translateX(-100%);
    }
    
    .mobile-outline {
        transform: translateX(100%);
    }
    
    .mobile-sidebar.active {
        transform: translateX(0);
    }
    
    .mobile-outline.active {
        transform: translateX(0);
    }
}

.mobile-sidebar-header h3,
.mobile-outline-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.mobile-sidebar-close,
.mobile-outline-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(22, 119, 255, 0.1);
    color: #1677ff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.mobile-sidebar-close:hover,
.mobile-outline-close:hover {
    background: rgba(22, 119, 255, 0.2);
    transform: scale(1.05);
}

.mobile-sidebar-content,
.mobile-outline-content {
    padding: 20px;
}

/* 响应式布局 - 平板和手机 */
@media (max-width: 1024px) {
    /* 隐藏PC端侧边栏和大纲 */
    .sidebar,
    .outline-container {
        display: none;
    }
    
    /* 主容器只显示内容区域 */
    .main-container {
        display: flex;
        flex: 1;
        overflow: hidden;
        background: #f5f7fa;
        margin-top: 60px;
    }
    
    /* 内容区域占据整个主容器 */
    .content-area {
        flex: 1;
        padding: 20px 10px;
        min-width: 0;
        width: 100%;
    }
    
    /* 隐藏侧边栏拖拽手柄 */
    .sidebar-resizer {
        display: none;
    }
    
    /* 显示顶部控制按钮 */
    .menu-toggle-btn {
        display: flex;
    }
    
    /* 显示移动端浮窗侧边栏和大纲 */
    .mobile-sidebar,
    .mobile-outline {
        display: block;
    }
}

/* 在PC端隐藏移动端浮窗 */
@media (min-width: 1025px) {
    .mobile-sidebar,
    .mobile-outline {
        display: none;
    }
}

/* 响应式布局 - 手机 */
@media (max-width: 768px) {
    .menu-list {
        gap: 20px;
    }
    
    .menu-item {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .content-area {
        padding: 15px;
    }
    
    .markdown-body img {
        max-width: 100%;
    }
}

/* 响应式布局 - 小屏幕手机 */
@media (max-width: 480px) {
    .menu-nav {
        display: none;
    }
    
    .menu-logo {
        font-size: 16px;
    }
    
    .content-area {
        padding: 10px;
    }
}
.menu-logo {
    font-size: 18px;
    font-weight: 600;
    color: #1677ff;
    padding: 8px 16px;
    cursor: pointer;
    user-select: none;
    border-radius: 10px;
    transition: all 0.2s ease;
}
.menu-logo:hover {
    background: #e5f3ff;
    color: #1677ff;
}
.menu-nav {
    flex: 1;
    margin-left: 60px;
}
.menu-list {
    display: flex;
    list-style: none;
    gap: 40px;
}
.menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    border-radius: 10px;
    transition: all 0.2s ease;
    position: relative;
}
.menu-item:hover {
    color: #1677ff;
    background: #e5f3ff;
}
.menu-item.active {
    color: #1677ff;
    font-weight: 500;
}
.menu-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 16px;
    right: 16px;
    height: 2px;
    background: #1677ff;
    border-radius: 1px;
}

/* -------------------------- 页面整体布局 -------------------------- */
.page-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* -------------------------- 主内容区域布局 -------------------------- */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    background: #f5f7fa;
    margin-top: 60px;
}

/* -------------------------- 左侧边栏导航 -------------------------- */
.sidebar {
    width: 22%;
    min-width: 200px;
    max-width: 60%;
    border-right: 1px solid #e5e7eb;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
    position: relative;
    flex-shrink: 0;
}

/* -------------------------- 侧边栏拖拽手柄样式 -------------------------- */
.sidebar-resizer {
    width: 3px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: all 0.2s ease;
    align-self: stretch;
    margin-left: -1px;
}
.sidebar-resizer:hover {
    background: rgba(22, 119, 255, 0.5);
    width: 5px;
}
.sidebar-resizer.active {
    background: rgba(22, 119, 255, 0.8);
    width: 5px;
    cursor: col-resize;
}

/* -------------------------- 自定义滚动条样式 -------------------------- */
/* 滚动条轨道 */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

/* 滚动条滑块悬停 */
::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.25);
}

/* 滚动条轨道背景 */
::-webkit-scrollbar-track {
    background-color: transparent;
}

/* Firefox 滚动条样式 */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* -------------------------- 右侧内容展示区 -------------------------- */
.content-area {
    flex: 1;
    padding: 20px 40px;
    overflow-y: auto;
    background: #ffffff;
    margin-top: 0;
}

/* -------------------------- 大纲容器样式 -------------------------- */
.outline-container {
    width: 20%;
    min-width: 180px;
    max-width: 400px;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.03);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

/* 大纲容器隐藏时的样式 */
.outline-container.collapsed {
    width: 0;
    min-width: 0;
    background: transparent;
    box-shadow: none;
    border-left: none;
    overflow: hidden;
}

/* 大纲隐藏时内容区域自适应宽度 */
.main-container:has(.outline-container.collapsed) .content-area {
    flex: 1;
}


.outline-container.collapsed {
    width: 0;
    background: transparent;
    box-shadow: none;
    border-left: none;
    overflow: hidden;
}
.outline-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f5f7fa;
    position: sticky;
    top: 0;
    z-index: 5;
}
.outline-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin: 0;
}
.outline-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* -------------------------- 大纲内联按钮样式 -------------------------- */
.outline-toggle-inline {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(22, 119, 255, 0.8);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.outline-toggle-inline:hover {
    background: #1677ff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* -------------------------- 大纲浮窗按钮样式 -------------------------- */
.outline-toggle-float {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(22, 119, 255, 0.8);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: fixed;
    right: 12px;
    top: 80px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: none;
}
.outline-toggle-float:hover {
    background: #1677ff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.outline-container.collapsed + .outline-toggle-float {
    display: flex;
    animation: fadeIn 0.3s ease;
}
.outline-toggle-float::before {
    content: '≡';
}

/* -------------------------- 动画效果 -------------------------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* -------------------------- 大纲头部样式调整 -------------------------- */
.outline-header {
    position: relative;
    padding-right: 50px;
}
.outline-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.outline-item {
    margin: 4px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 10px;
}
.outline-item:hover {
    background: #e5f3ff;
}
.outline-item a {
    display: block;
    padding: 6px 12px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
}
.outline-item.level-1 a {
    font-size: 16px;
    font-weight: 600;
    color: #1677ff;
}
.outline-item.level-2 a {
    font-size: 14px;
    font-weight: 500;
    margin-left: 12px;
    color: #333;
}
.outline-item.level-3 a {
    font-size: 13px;
    margin-left: 24px;
    color: #666;
}
.outline-item.active a {
    color: #1677ff;
    font-weight: 500;
}
.outline-item.active {
    background: #e5f3ff;
}

/* -------------------------- 导航树基础样式 -------------------------- */
.nav-tree {
    list-style: none;
}
.nav-node {
    margin: 4px 0;
}
.nav-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: var(--base-font-size);
    user-select: none;
    color: var(--primary-text-color);
}
.nav-item:hover {
    background: #e5f3ff;
    color: #1677ff;
}
.nav-item.active {
    background: #1677ff;
    color: #ffffff;
    font-weight: 500;
}

/* -------------------------- 文件夹导航样式 -------------------------- */
.folder-node > .nav-item {
    position: relative;
    padding-right: 30px;
}
.folder-node > .nav-item::before {
    content: "";
    margin-right: 8px;
}
.folder-node > .nav-item::after {
    content: "";
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 6px;
    height: 6px;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transition: all 0.3s ease;
}
.folder-node.open > .nav-item::after {
    transform: translateY(-50%) rotate(225deg);
    border-color: #1677ff;
}
.folder-children {
    list-style: none;
    padding-left: 24px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.6s ease-out;
    background-color: #fcfcfc;
}
.folder-node.open > .folder-children {
    max-height: 500px;
    transition: max-height 0.6s ease-in;
}

/* -------------------------- 文件导航样式 -------------------------- */
.file-node > .nav-item {
    padding-right: 30px;
}
.file-node > .nav-item::before {
    content: "📄";
    margin-right: 8px;
    font-size: 12px;
}

/* -------------------------- 提示文本样式 -------------------------- */
.loading-tip {
    color: #1677ff;
    text-align: center;
    margin-top: 120px;
    font-size: 16px;
}
.error-tip {
    color: #ff4d4f;
    text-align: center;
    margin-top: 120px;
    font-size: 16px;
}

/* -------------------------- Markdown内容渲染样式 -------------------------- */
.markdown-body {
    line-height: 1.8;
    max-width: 100%;
    color: var(--primary-text-color);
    font-size: 15px;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
    margin: 24px 0 16px 0;
    color: var(--primary-text-color);
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}
.markdown-body p {
    margin: 12px 0;
}
.markdown-body img {
    max-width: 60%;
    border-radius: 10px;
    margin: 16px 0;
    display: block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: zoom-in;
    transition: transform 0.2s;
}
.markdown-body img:hover {
    transform: scale(1.02);
}
.markdown-body video {
    max-width: 100%;
    border-radius: 10px;
    height: auto;
    display: block;
    margin: 16px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* -------------------------- 表格样式 -------------------------- */
.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 14px;
}

.markdown-body table th,
.markdown-body table td {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.markdown-body table th {
    background-color: #f9fafb;
    font-weight: 600;
}

.markdown-body table tr:nth-child(even) {
    background-color: #f9fafb;
}

/* -------------------------- 引用块样式 -------------------------- */
.markdown-body blockquote {
    border-left: 4px solid #1677ff;
    padding: 12px 16px;
    margin: 16px 0;
    background-color: #f0f7ff;
    color: #333;
}

/* -------------------------- 列表样式 -------------------------- */
.markdown-body ul,
.markdown-body ol {
    margin: 16px 0;
    padding-left: 24px;
}

.markdown-body ul li,
.markdown-body ol li {
    margin: 8px 0;
}

/* 任务列表样式 */
.markdown-body ul.task-list {
    list-style: none;
    padding-left: 24px;
}

.markdown-body ul.task-list li {
    position: relative;
}

.markdown-body ul.task-list li input[type="checkbox"] {
    margin-right: 8px;
}

/* -------------------------- 分割线样式 -------------------------- */
.markdown-body hr {
    border: 0;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

/* -------------------------- 代码样式 -------------------------- */
.markdown-body code {
    background-color: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* -------------------------- 链接样式 -------------------------- */
.markdown-body a {
    color: #1677ff;
    text-decoration: none;
}

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

/* -------------------------- 代码块样式 -------------------------- */
pre {
    background: #f6f8fa;
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    white-space: pre-wrap;
    border: 1px solid #e5e7eb;
}

/* -------------------------- HTML预览容器样式 -------------------------- */
.html-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: calc(100vh - 120px);
}
.html-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #f5f7fa;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}
.html-toolbar button {
    padding: 6px 16px;
    background: #1677ff;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}
.html-toolbar button:hover {
    background: #4096ff;
}
.html-iframe {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* -------------------------- 图片灯箱样式 -------------------------- */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    transform: scale(1);
    transition: transform 0.3s;
}
.lightbox-content img {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}
.lightbox-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 10000;
}
.lightbox-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}
.lightbox-close {
    font-size: 24px;
}