/* 基于 rst2pdf.style 的自定义样式 */

/* 字体设置 - 使用系统中文字体 */
:root {
    --heading-color: #1a8099;
    --text-color: #383745;
    --table-header-bg: #e0f0d8;
    --table-header-color: #006699;
}

/* 正文样式 */
body, .content, main {
    font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
    color: var(--text-color) !important;
    font-size: 16px;
    line-height: 1.7;
}

/* ========== 暗色侧边栏（ReadTheDocs 风格）========== */
.light {
    --sidebar-bg: #343131;
    --sidebar-fg: #d9d9d9;
    --sidebar-non-existant: #888888;
    --sidebar-active: #ffffff;
    --sidebar-spacer: #444444;
    --sidebar-header-border-color: #4dbce9;
}

/* 侧边栏样式 */
.sidebar, nav.sidebar, .sidebar-scrollbox {
    font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
    font-size: 14px !important;
}
.sidebar .sidebar-scrollbox {
    padding-top: 0px !important;
}

/* 侧边栏章节列表 */
.sidebar .chapter, .sidebar-scrollbox .chapter {
    font-size: 14px !important;
    line-height: 1.8 !important;
    padding-top:1px;
    margin-block-start: 0;
}

.chapter li.chapter-item {
    margin-block-start: -1px;
}

/* 侧边栏链接 */
.sidebar a, .sidebar-scrollbox a {
    font-size: 14px !important;
    color: #d9d9d9 !important;
    transition: color 0.2s;
}

.sidebar a:hover, .sidebar-scrollbox a:hover {
    color: #ffffff !important;
}

/* 侧边栏当前激活链接 - 整行背景 */
.sidebar .chapter-link-wrapper:has(a.active),
.sidebar-scrollbox .chapter-link-wrapper:has(a.active) {
    background: #2980b9 !important;
    display: block;
    margin-left: -20px;
    margin-right: -10px;
    padding: 2px 10px 2px 20px;
    line-height: 35px;
}

.sidebar .chapter-link-wrapper a.active,
.sidebar-scrollbox .chapter-link-wrapper a.active {
    color: #ffffff !important;
    font-size: 16px !important;
}

/* 侧边栏分类标题 */
.sidebar .sidebar-scrollbox .chapter li.part-title {
    color: #4dbce9 !important;
    font-weight: bold;
}

/* 隐藏打印按钮和主题切换按钮 */
#print-button,
a[title="Print this book"],
#mdbook-theme-toggle {
    display: none !important;
}

/* 侧边栏滚动条 */
.sidebar-scrollbox::-webkit-scrollbar {
    width: 6px;
}
.sidebar-scrollbox::-webkit-scrollbar-track {
    background: #2b2828;
}
.sidebar-scrollbox::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}
.sidebar-scrollbox::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* 标题样式 - 青色 #1a8099 */
h1, h2, h3, h4, h5, h6,
.content h1, .content h2, .content h3, .content h4, .content h5, .content h6,
main h1, main h2, main h3, main h4, main h5, main h6 {
    color: #1a8099 !important;
    font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif !important;
    font-weight: bold !important;
    border-bottom: none !important;
}

/* 主标题 h1 - 居中，无分隔线 */
.content h1, main h1, h1 {
    font-size: 24px !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
    text-align: center !important;
}

/* 二级标题 h2 - 无分隔线 */
.content h2, main h2, h2 {
    font-size: 20px !important;
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

.content h3, main h3, h3 {
    font-size: 18px !important;
}

.content h4, main h4, h4 {
    font-size: 16px !important;
}

/* 目录样式 */
.toc {
    page-break-after: always;
    margin-bottom: 2em;
}

.toc h2 {
    color: #1a8099 !important;
    font-size: 24px !important;
    margin-bottom: 1em;
}

.toc ul {
    list-style: none;
    padding-left: 0;
}

.toc li {
    margin: 0.5em 0;
    line-height: 1.8;
}

.toc li a {
    color: #1a8099 !important;
    text-decoration: none;
}

.toc li a:hover {
    text-decoration: underline;
}

/* 一级目录 */
.toc > ul > li > a {
    font-weight: bold;
    font-size: 14px;
}

/* 二级目录 */
.toc > ul > li > ul {
    padding-left: 1.5em;
}

.toc > ul > li > ul > li > a {
    font-size: 13px;
}

/* 三级目录 */
.toc > ul > li > ul > li > ul {
    padding-left: 1.5em;
}

.toc > ul > li > ul > li > ul > li > a {
    font-size: 12px;
}

/* 表格样式 */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 1em 0;
}

th {
    background-color: #e0f0d8 !important;
    color: #006699 !important;
    font-weight: bold;
    text-align: left;
    padding: 8px 12px;
    border: 1px solid #ccc;
}

td {
    padding: 8px 12px;
    border: 1px solid #ccc;
}

/* 代码块样式 */
pre, code {
    font-family: "Source Code Pro", "Consolas", "Monaco", monospace;
    font-size: 14px;
    background-color: #f5f5f5;
}

pre {
    padding: 12px;
    border-radius: 4px;
    overflow-x: auto;
    position: relative;
}

/* 复制按钮成功提示样式 - 显示在下方 */
.tooltiptext {
    top: 28px !important;
    left: 0 !important;
    transform: translateX(-60%) !important;
    white-space: nowrap !important;
    font-size: 14px !important;
}

/* 引用/提示框基础样式 */
blockquote {
    border-left: 4px solid #1a8099 !important;
    padding: 1em 1em 1em 1.2em !important;
    margin: 1em 0 !important;
    border-radius: 0 8px 8px 0 !important;
    background-color: #f0f9fc !important;
}

/* 提示框标题样式 - 隐藏英文显示中文 */
blockquote .blockquote-tag-title {
    font-weight: bold !important;
    margin-bottom: 0.5em !important;
    font-size: 0 !important;  /* 隐藏原文字 */
}

blockquote .blockquote-tag-title svg {
    font-size: 14px;
    vertical-align: middle;
    margin-right: 6px;
}

/* Important => 重要 */
blockquote.blockquote-tag-important .blockquote-tag-title::after {
    content: "重要" !important;
    font-size: 15px !important;
}

/* Warning => 警告 */
blockquote.blockquote-tag-warning .blockquote-tag-title::after {
    content: "警告" !important;
    font-size: 15px !important;
}

/* Tip => 提示 */
blockquote.blockquote-tag-tip .blockquote-tag-title::after {
    content: "提示" !important;
    font-size: 15px !important;
}

/* Note => 注意 */
blockquote.blockquote-tag-note .blockquote-tag-title::after {
    content: "注意" !important;
    font-size: 15px !important;
}

/* Caution => 小心 */
blockquote.blockquote-tag-caution .blockquote-tag-title::after {
    content: "小心" !important;
    font-size: 15px !important;
}

/* Important 提示框 - 青色 */
blockquote.blockquote-tag-important,
blockquote:has(.blockquote-tag-title:contains("Important")) {
    border-left-color: #1a8099 !important;
    background-color: #e8f4f8 !important;
}

blockquote.blockquote-tag-important .blockquote-tag-title {
    color: #1a8099 !important;
}

/* Warning 提示框 - 橙色 */
blockquote.blockquote-tag-warning {
    border-left-color: #e6a23c !important;
    background-color: #fdf6ec !important;
}

blockquote.blockquote-tag-warning .blockquote-tag-title {
    color: #e6a23c !important;
}

/* Tip 提示框 - 绿色 */
blockquote.blockquote-tag-tip {
    border-left-color: #67c23a !important;
    background-color: #f0f9eb !important;
}

blockquote.blockquote-tag-tip .blockquote-tag-title {
    color: #67c23a !important;
}

/* Note 提示框 - 蓝色 */
blockquote.blockquote-tag-note {
    border-left-color: #409eff !important;
    background-color: #ecf5ff !important;
}

blockquote.blockquote-tag-note .blockquote-tag-title {
    color: #409eff !important;
}

/* Caution 提示框 - 红色 */
blockquote.blockquote-tag-caution {
    border-left-color: #f56c6c !important;
    background-color: #fef0f0 !important;
}

blockquote.blockquote-tag-caution .blockquote-tag-title {
    color: #f56c6c !important;
}

/* 图片居中 */
img {
    display: block;
    margin: 1em auto;
    max-width: 100%;
}

/* 链接样式 */
a {
    color: #1a8099 !important;
}

/* 打印/PDF 特定样式 */
@media print {
    body, .content, main {
        font-size: 12pt !important;
        color: #383745 !important;
    }

    h1, h2, h3, h4, h5, h6,
    .content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
        color: #1a8099 !important;
        border-bottom: none !important;
    }

    h1, .content h1 {
        font-size: 18pt !important;
        text-align: center !important;
    }

    h2, .content h2 {
        font-size: 16pt !important;
    }

    h3, .content h3 {
        font-size: 14pt !important;
    }

    /* 目录页后分页 */
    .toc {
        page-break-after: always;
    }

    /* 主要章节前分页 */
    h2 {
        page-break-before: always;
    }

    h2:first-of-type {
        page-break-before: avoid;
    }

    /* PDF 中显示目录 */
    .pdf-toc {
        display: block !important;
    }
}

/* ========== 侧边栏返回按钮 ========== */
.sidebar-back-wrapper {
    text-align: right;
    position: absolute;
    top: 0;
    right: 5px;
    z-index: 5;
}

.sidebar-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px !important;
    padding: 4px;
    border-radius: 4px;
    color: #d9d9d9 !important;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    text-decoration: none !important;
}

.sidebar-back-btn:hover {
    opacity: 1;
    color: #ffffff !important;
    background: rgba(255,255,255,0.1);
}

/* ========== PDF 专用目录（HTML 中隐藏）========== */
.pdf-toc {
    display: none;
}

@media print {
    .sidebar-back-btn { display: none !important; }
}

/* 左侧 sidebar 页内目录 */
.on-this-page {
    margin-left: -10px !important;
    border-inline-start-color: #4dbce9 !important;
}

/* 隐藏 sidebar 中的"目录"条目（由 mdbook-toc 生成） */
.on-this-page li:has(> .chapter-link-wrapper > a[href="#目录"]) {
    display: none !important;
}

/* 当前章节高亮 - 铺满整行（暗色侧边栏适配） */
.sidebar .chapter-link-wrapper:has(.current-header),
.sidebar-scrollbox .chapter-link-wrapper:has(.current-header) {
    background: rgba(255,255,255,0.12);
    margin-left: -50px;
    margin-right: -20px;
    padding-left: 50px;
    padding-right: 20px;
}
