﻿﻿/* ================================
   布局基础样式
   ================================ */
html {
    font-size: 15px; /* 基准字号，便于 rem 计算 */
}

body {
    /* 优先使用系统字体，回退到标准无衬线体 */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    overflow-x: hidden;          /* 防止水平滚动条 */
    background-color: #f8f9fa;   /* 浅灰色背景 */
}

/* 弹性容器：左侧导航 + 右侧内容 */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh; /* 至少占满视口高度 */
}

/* ================================
   左侧导航栏（侧边栏）
   ================================ */
.sidebar {
    min-width: 280px;     /* 最小宽度 */
    max-width: 280px;     /* 最大宽度，固定尺寸 */
    height: 100vh;        /* 全屏高度 */
    position: sticky;     /* 粘性定位，随页面滚动保持可见 */
    top: 0;
    overflow-y: auto;     /* 内容超出时垂直滚动 */
    transition: all 0.3s; /* 折叠/展开动画 */
    z-index: 1000;
}

/* 侧边栏折叠状态：向左平移隐藏 */
.sidebar.active {
    margin-left: -280px;
}

/* 侧边栏头部：标题区域 */
.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-header h5 {
    margin: 0;
    font-weight: 600; /* 粗体标题 */
}

/* 菜单列表 */
.sidebar .components {
    padding: 0.5rem 0;
}

.sidebar li {
    padding: 0;
}

/* 章节链接样式 */
.sidebar .chapter-link {
    display: block;
    padding: 0.6rem 1.25rem;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 3px solid transparent; /* 左侧指示条（透明） */
    transition: all 0.2s;
}

/* 章节链接悬停效果 */
.sidebar .chapter-link:hover {
    color: #fff;
    background: rgba(255,255,255,.1);
    border-left-color: #0d6efd; /* 蓝色指示条 */
}

/* 当前活跃的章节链接 */
.sidebar li.active > .chapter-link {
    color: #fff;
    background: rgba(13,110,253,.15);
    border-left-color: #0d6efd;
}

/* 子节链接样式 */
.sidebar .section-link {
    display: block;
    padding: 0.4rem 1rem;
    color: rgba(255,255,255,.55);
    text-decoration: none;
    font-size: 0.82rem;
    border-radius: 4px;
    transition: all 0.2s;
}

/* 子节链接悬停 */
.sidebar .section-link:hover {
    color: #fff;
    background: rgba(255,255,255,.08);
}

/* 当前活跃的子节链接 */
.sidebar .section-link.active-section {
    color: #6ea8fe;
    background: rgba(13,110,253,.12);
}

/* 小节链接样式（四级标题） */
.sidebar .subsection-link {
    display: block;
    padding: 0.25rem 0.5rem;
    color: rgba(255,255,255,.4);
    text-decoration: none;
    font-size: 0.78rem;
    border-radius: 3px;
    transition: all 0.2s;
}

.sidebar .subsection-link:hover {
    color: rgba(255,255,255,.7);
}

/* 侧边栏滚动条美化 */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.2);
    border-radius: 3px;
}

/* ================================
   主内容区域
   ================================ */
#content {
    width: calc(100% - 280px); /* 减去侧边栏宽度 */
    min-height: 100vh;
    transition: all 0.3s;
    display: flex;
    flex-direction: column; /* 顶部导航 + 主体 + 底部 */
}

#content main {
    flex: 1; /* 主体撑满剩余空间 */
}

/* 侧边栏折叠时，内容占满全宽 */
.wrapper .sidebar.active + #content {
    width: 100%;
}

/* ================================
   首页 Hero 区域
   ================================ */
.hero-section .hero-icon {
    font-size: 3rem;
    color: #0d6efd;
}

/* ================================
   章节卡片
   ================================ */
.chapter-card {
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    overflow: hidden;
}

/* 卡片悬停：升高 + 阴影 */
.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,.12) !important;
}

/* 卡片图标：渐变背景 */
.chapter-card .chapter-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d6efd, #6610f2);
    color: #fff;
    border-radius: 12px;
    font-size: 1.3rem;
}

/* 卡片底部默认隐藏，悬停显示 */
.chapter-card .card-footer {
    opacity: 0;
    transition: all 0.3s;
}

.chapter-card:hover .card-footer {
    opacity: 1;
}

/* ================================
   内容区的 Markdown 渲染样式
   ================================ */
.chapter-content,
.section-content,
.subsection-content {
    line-height: 1.8;  /* 舒适的阅读行高 */
    font-size: 0.95rem;
}

/* 代码块：深色主题 */
.chapter-content pre,
.section-content pre,
.subsection-content pre {
    background: #1e1e2e;              /* 深色背景 */
    color: #cdd6f4;                   /* 浅色文字 */
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;                 /* 代码过长时横向滚动 */
    font-size: 0.85rem;
    line-height: 1.5;
    margin: 1rem 0;
}

/* 行内代码 */
.chapter-content code,
.section-content code,
.subsection-content code {
    background: #e8e8e8;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.88em;
    color: #d63384; /* 玫红色，与正文区分 */
}

/* 代码块内部的 code 标签：还原样式 */
.chapter-content pre code,
.section-content pre code,
.subsection-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* 表格 */
.chapter-content table,
.section-content table {
    margin: 1rem 0;
    font-size: 0.9rem;
}

/* 引用块：蓝色左侧边框 */
.chapter-content blockquote,
.section-content blockquote {
    border-left: 4px solid #0d6efd;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: #f0f4ff;
    border-radius: 0 8px 8px 0;
    color: #333;
}

/* 列表 */
.chapter-content ul,
.section-content ul {
    padding-left: 1.5rem;
    margin: 0.75rem 0;
}

/* 段落间距 */
.chapter-content p,
.section-content p {
    margin: 0.75rem 0;
}

/* 加粗文字：蓝色强调 */
.chapter-content strong,
.section-content strong {
    color: #0d6efd;
}

/* 分隔线 */
.chapter-content hr,
.section-content hr {
    margin: 1.5rem 0;
    opacity: 0.2;
}

/* Bootstrap 表格表头样式 */
.chapter-content .table-bordered th,
.section-content .table-bordered th {
    background: #0d6efd;
    color: #fff;
    font-weight: 600;
    font-size: 0.88rem;
}

/* ================================
   子节卡片
   ================================ */
.section-card {
    border-radius: 12px;
    overflow: hidden;
}

/* ================================
   面包屑导航
   ================================ */
.breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
}

.breadcrumb-item a {
    color: #0d6efd;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
}

/* ================================
   回到顶部按钮
   ================================ */
#backToTop {
    opacity: 0.8;
    transition: all 0.3s;
    z-index: 999;
}

#backToTop:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* ================================
   响应式适配（移动端）
   ================================ */
@media (max-width: 768px) {
    /* 小屏幕下侧边栏默认隐藏 */
    .sidebar {
        margin-left: -280px;
    }

    .sidebar.active {
        margin-left: 0;
    }

    /* 内容区域全宽 */
    #content {
        width: 100%;
    }

    .wrapper .sidebar.active + #content {
        width: 100%;
    }

    .chapter-card {
        margin-bottom: 1rem;
    }
}

/* ================================
   代码块语言标签
   在代码块顶部显示语言名称（如 bash、python）
   ================================ */
.language-bash::before,
.language-nginx::before,
.language-python::before,
.language-ini::before,
.language-toml::before,
.language-json::before {
    display: block;
    content: attr(class);
    font-size: 0.75rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 代码块容器相对定位，用于语言标签 */
pre {
    position: relative;
}

/* 搜索高亮 */
.highlight {
    background: #fff3cd;
    padding: 0 2px;
    border-radius: 2px;
}
