/* =================================================================
   Wiki Knowledge Base Detail Page - 知识库详情页
   简洁风格，多级目录结构
   ================================================================= */

/* 隐藏页面滚动条 */
html:has(.wiki-page) {
    scrollbar-width: none; /* Firefox */
}

html:has(.wiki-page)::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

/* ==================== 页面容器 ==================== */
/* 覆盖全局背景图，知识库页面使用纯色背景 */
.wiki-page {
    min-height: calc(100vh - 56px);
    padding: 24px 0;
    background: var(--bg-primary);
}

/* ==================== 文章编号样式 ==================== */
.title-num {
    display: inline-block;
    color: inherit;
    font-weight: 600;
    margin-right: 8px;
}

/* 激活状态的链接中的编号显示为主题色 */
a.active .title-num {
    color: var(--primary-color);
}

/* H1外的编号 - 与H1同行 */
.article-header > .title-num {
    display: inline-block;
    font-size: 32px;
    color: var(--primary-color);
    font-weight: 700;
    margin-right: 12px;
    vertical-align: baseline;
}

.article-header h1 {
    display: inline;
}

/* ==================== 三栏布局 ==================== */
.wiki-layout {
    display: flex;
    gap: 40px;
}

/* ==================== 移动端悬浮目录 ==================== */
/* 默认隐藏 */
.mobile-nav-tab,
.mobile-nav-panel,
.mobile-nav-overlay {
    display: none;
}

/* 悬浮标签 */
.mobile-nav-tab {
    position: fixed;
    left: 0;
    bottom: 120px;
    background: var(--primary-color);
    color: #fff;
    padding: 10px 8px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.mobile-nav-tab .tab-text {
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
}

/* 目录面板 */
.mobile-nav-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: 300px;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.mobile-nav-panel.open {
    transform: translateX(0);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--primary-color);
    color: #fff;
}

.panel-title {
    font-size: 16px;
    font-weight: 600;
}

.panel-close {
    font-size: 24px;
    cursor: pointer;
    opacity: 0.8;
}

.panel-close:hover {
    opacity: 1;
}

.panel-content {
    padding: 16px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    background: var(--bg-primary);
}

.panel-category {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.panel-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.panel-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    cursor: pointer;
}

.panel-arrow {
    width: 12px;
    height: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-arrow::before {
    content: '';
    border: 4px solid transparent;
    border-left: 5px solid var(--text-tertiary);
    transition: transform 0.2s;
}

.panel-section.expanded .panel-arrow::before {
    transform: rotate(90deg);
}

.panel-section-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.panel-section-items {
    display: none;
    padding-left: 20px;
    margin-top: 4px;
}

.panel-section.expanded .panel-section-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-section-items a {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: 4px;
}

.panel-section-items a:hover {
    background: var(--bg-hover);
}

.panel-section-items a.active {
    color: var(--primary-color);
    background: rgba(var(--primary-rgb), 0.1);
}

/* 遮罩层 */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.mobile-nav-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* ==================== 左侧目录 ==================== */
.wiki-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    height: fit-content;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* 顶级栏目 */
.sidebar-category {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.category-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    transition: color 0.2s;
}

.category-title:hover {
    color: var(--primary-color);
}

/* 子栏目导航 */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* 导航分组 - 折叠功能 */
.nav-section {
    margin-bottom: 4px;
}

/* 分组头部 */
.section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

/* 折叠图标 */
.section-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-icon::before {
    content: '';
    border: 4px solid transparent;
    border-left: 5px solid var(--text-tertiary);
    transition: transform 0.2s;
}

.nav-section.expanded .section-icon::before {
    transform: rotate(90deg);
}

/* 子栏目标题 */
.section-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.2s;
    flex: 1;
}

.section-title:hover {
    color: var(--primary-color);
}

.section-title.active {
    color: var(--primary-color);
}

/* 文章列表 - 默认折叠 */
.section-items {
    padding-left: 12px;
    border-left: 1px solid var(--border-light);
    margin-left: 10px;
    margin-top: 4px;
    display: none;
    flex-direction: column;
    gap: 2px;
}

/* 展开状态 */
.nav-section.expanded .section-items {
    display: flex;
}

.section-items a {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 5px 0 5px 8px;
    transition: all 0.2s;
    border-left: 2px solid transparent;
    margin-left: -13px;
}

.section-items a:hover {
    color: var(--text-primary);
}

.section-items a.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 500;
}

/* ==================== 主内容区 ==================== */
.wiki-main {
    flex: 1;
    min-width: 0;
}


/* 文章头部 */
.article-header {
    margin-bottom: 32px;
}

.article-header h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 16px 0;
    line-height: 1.4;
}

/* 文章封面 */
.article-cover {
    margin-bottom: 32px;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.article-cover img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-tertiary);
}

.article-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.article-meta .iconfont {
    font-size: 14px;
    color: var(--text-tertiary);
}

/* 文章内容区 - 不设置样式，用户会单独定义 */
.article-body {
    /* 基础设置，具体标签样式由用户另外定义 */
}

/* 文章底部 */
.article-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

/* 上下篇导航 - 固定位置 */
.article-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.article-nav a {
    font-size: 14px;
    color: var(--text-secondary);
    transition: color 0.2s;
    min-height: 20px;
}

.article-nav a:hover {
    color: var(--primary-color);
}

/* 上一篇固定在左侧 */
.article-nav .nav-prev {
    grid-column: 1;
    text-align: left;
}

/* 下一篇固定在右侧 */
.article-nav .nav-next {
    grid-column: 2;
    text-align: right;
}

.nav-prev::before {
    content: '← ';
}

.nav-next::after {
    content: ' →';
}

/* ==================== 右侧目录 ==================== */
.wiki-toc {
    width: 180px;
    flex-shrink: 0;
    position: sticky;
    top: 80px;
    height: fit-content;
}

.toc-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-tertiary);
    margin-bottom: 12px;
}

.toc-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toc-nav a {
    font-size: 13px;
    color: var(--text-secondary);
    padding-left: 12px;
    border-left: 2px solid transparent;
    transition: all 0.2s;
    line-height: 1.5;
}

.toc-nav a:hover {
    color: var(--text-primary);
}

.toc-nav a.active {
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

/* ==================== 响应式设计 ==================== */
/* 断点: PC ≥1024px | iPad 768-1023px | 手机 <768px */

/* iPad端: 768px - 1023px */
@media (max-width: 1023px) {
    /* 隐藏右侧TOC */
    .wiki-toc {
        display: none;
    }
    
    .wiki-layout {
        gap: 24px;
    }
    
    /* 缩小左侧目录宽度 */
    .wiki-sidebar {
        width: 200px;
    }
    
    .article-header h1 {
        font-size: 26px;
    }
    
    .article-meta {
        flex-wrap: wrap;
    }
}

/* 手机端: < 768px */
@media (max-width: 767px) {
    .wiki-page {
        padding: 16px 0;
    }
    
    .wiki-layout {
        flex-direction: column;
        gap: 0;
    }
    
    /* 隐藏PC端左侧目录 */
    .wiki-sidebar {
        display: none;
    }
    
    /* 显示移动端悬浮目录标签 */
    .mobile-nav-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .mobile-nav-panel {
        display: block;
    }
    
    /* 文章头部 */
    .article-header h1 {
        font-size: 22px;
    }
    
    .article-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .article-meta span {
        margin-right: 0;
        font-size: 12px;
    }
    
    /* 上下篇导航 */
    .article-nav {
        flex-direction: column;
        gap: 12px;
    }
    
    .article-nav a {
        font-size: 13px;
    }
    
    /* 底部间距 */
    .article-footer {
        margin-top: 32px;
        padding-top: 16px;
    }
}

/* PC端隐藏移动端组件 */
@media (min-width: 768px) {
    .sidebar-toggle,
    .sidebar-overlay,
    .sidebar-close {
        display: none;
    }
}

/* 超小屏幕: < 480px */
@media (max-width: 479px) {
    .wiki-page {
        padding: 12px 0;
    }
    
    .article-header h1 {
        font-size: 20px;
    }
    
    .category-title {
        font-size: 14px;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .wiki-sidebar,
    .wiki-toc {
        display: none;
    }
    
    .wiki-main {
        width: 100%;
    }
    
    .wiki-page {
        background: white;
    }
}
