/* =====================================================================
 * 用户帮助文档样式 v2
 *
 * 布局：顶栏（含搜索） + 左目录（可折叠） + 中正文 + 右大纲
 * 增强：阅读进度条、键盘快捷键、代码块语言标签、复制按钮常驻
 * ===================================================================== */

:root {
    --docs-primary: #4f46e5;
    --docs-primary-hover: #4338ca;
    --docs-primary-soft: #eef2ff;
    --docs-text: #1f2937;
    --docs-text-mute: #6b7280;
    --docs-border: #e5e7eb;
    --docs-bg: #ffffff;
    --docs-bg-soft: #f9fafb;
    --docs-code-bg: #f3f4f6;

    --docs-sidebar-w: 250px;
    --docs-toc-w: 200px;
    --docs-topbar-h: 60px;
}

* { box-sizing: border-box; }

.docs-body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    color: var(--docs-text);
    background: var(--docs-bg);
    line-height: 1.7;
    font-size: 15px;
}

a { color: var(--docs-primary); text-decoration: none; }
a:hover { color: var(--docs-primary-hover); text-decoration: underline; }
kbd {
    background: var(--docs-bg-soft);
    border: 1px solid var(--docs-border);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 12px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color: var(--docs-text);
}

/* ================== 顶栏 ================== */
.docs-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--docs-border);
    height: var(--docs-topbar-h);
}

.docs-topbar-inner {
    max-width: none;
    height: 100%;
    margin: 0;
    padding: 0 32px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.docs-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--docs-text);
    font-weight: 700;
    font-size: 17px;
    flex-shrink: 0;
}
.docs-brand:hover { text-decoration: none; color: var(--docs-primary); }
.docs-brand i { color: var(--docs-primary); }
.docs-brand-sub {
    font-size: 13px;
    font-weight: 500;
    color: var(--docs-text-mute);
    padding-left: 8px;
    border-left: 1px solid var(--docs-border);
    margin-left: 4px;
}

/* 搜索框 */
.docs-search {
    flex: 1;
    max-width: 480px;
    position: relative;
    display: flex;
    align-items: center;
}
.docs-search > i {
    position: absolute;
    left: 12px;
    color: var(--docs-text-mute);
    font-size: 13px;
}
.docs-search input {
    width: 100%;
    height: 36px;
    padding: 0 36px 0 34px;
    border: 1px solid var(--docs-border);
    border-radius: 8px;
    background: var(--docs-bg-soft);
    font-size: 14px;
    color: var(--docs-text);
    transition: all 0.15s ease;
}
.docs-search input::placeholder { color: var(--docs-text-mute); }
.docs-search input:focus {
    outline: none;
    background: white;
    border-color: var(--docs-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}
.docs-search-kbd {
    position: absolute;
    right: 8px;
    pointer-events: none;
}
.docs-search input:focus ~ .docs-search-kbd { opacity: 0; }

.docs-topbar-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.docs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.2;
}
.docs-btn:hover { text-decoration: none; }
.docs-btn-primary { background: var(--docs-primary); color: white; }
.docs-btn-primary:hover { background: var(--docs-primary-hover); color: white; }
.docs-btn-ghost { color: var(--docs-text); border-color: var(--docs-border); background: white; }
.docs-btn-ghost:hover { background: var(--docs-bg-soft); color: var(--docs-text); }
.docs-btn-lg { padding: 12px 24px; font-size: 15px; }

.docs-mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--docs-text);
    cursor: pointer;
    padding: 8px;
}

/* ================== 主布局：左目录 + 内容（完全铺满） ================== */
.docs-shell {
    max-width: none;
    margin: 0;
    padding: 0 32px;
    display: grid;
    grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr);
    gap: 56px;
    min-height: calc(100vh - var(--docs-topbar-h));
}

/* ================== 左侧目录 ================== */
.docs-sidebar { padding: 24px 0; }
.docs-sidebar-inner {
    position: sticky;
    top: calc(var(--docs-topbar-h) + 16px);
    max-height: calc(100vh - var(--docs-topbar-h) - 32px);
    overflow-y: auto;
    padding-right: 8px;
}
.docs-sidebar-inner::-webkit-scrollbar { width: 6px; }
.docs-sidebar-inner::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 3px; }
.docs-sidebar-inner::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

.docs-section { margin-bottom: 4px; }
.docs-section-title {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--docs-text-mute);
    text-align: left;
    transition: background 0.15s ease;
}
.docs-section-title:hover { background: var(--docs-bg-soft); color: var(--docs-text); }
.docs-section-title > i:first-child { color: var(--docs-primary); font-size: 13px; }
.docs-section-name { flex: 1; }
.docs-section-caret {
    font-size: 11px;
    transition: transform 0.2s ease;
    opacity: 0.6;
}
.docs-section:not(.expanded) .docs-section-caret { transform: rotate(-90deg); }
.docs-section:not(.expanded) .docs-section-pages { display: none; }

.docs-section-pages {
    list-style: none;
    padding: 4px 0 8px 8px;
    margin: 0;
}
.docs-section-pages li { margin: 0; }
.docs-section-pages a {
    display: block;
    padding: 5px 12px;
    margin: 1px 0;
    border-radius: 6px;
    color: var(--docs-text);
    font-size: 13.5px;
    border-left: 2px solid transparent;
    transition: all 0.12s ease;
}
.docs-section-pages a:hover {
    background: var(--docs-bg-soft);
    text-decoration: none;
    color: var(--docs-primary);
}
.docs-section-pages a.active {
    background: var(--docs-primary-soft);
    color: var(--docs-primary);
    font-weight: 600;
    border-left-color: var(--docs-primary);
}
/* 搜索高亮（JS 注入 <mark>） */
.docs-section-pages mark {
    background: #fef08a;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.docs-search-empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--docs-text-mute);
    font-size: 13px;
}
.docs-search-empty i { display: block; font-size: 24px; margin-bottom: 8px; opacity: 0.5; }

/* ================== 主内容区 ================== */
.docs-main { padding: 0; min-width: 0; }

/* 文档页：中正文 + 右大纲（2 列）；首页只有 .docs-article（1 列） */
.docs-article-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--docs-toc-w);
    gap: 56px;
    padding: 32px 64px 80px 0;
}
/* 正文限宽保证可读（行宽 ~70 字符），居中放置在拉宽的网格内 */
.docs-article {
    max-width: 820px;
    min-width: 0;
    width: 100%;
    margin: 0 auto;
}

/* 阅读进度条 */
.docs-progress {
    position: fixed;
    top: var(--docs-topbar-h);
    left: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--docs-primary), #7c3aed);
    z-index: 99;
    transition: width 0.05s linear;
}

/* ================== 首页（无右大纲，1 列居中） ================== */
.docs-main > .docs-article {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 32px 80px;
}

.docs-hero {
    padding: 48px 0 32px;
    text-align: center;
    border-bottom: 1px solid var(--docs-border);
    margin-bottom: 40px;
}
.docs-hero h1 {
    font-size: 34px;
    font-weight: 700;
    margin: 0 0 12px;
    background: linear-gradient(120deg, var(--docs-primary), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.docs-hero-sub { font-size: 16px; color: var(--docs-text-mute); margin: 0 0 24px; }
.docs-hero-actions { display: flex; gap: 12px; justify-content: center; }

.docs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 0 0 40px;
}
.docs-card {
    display: flex;
    gap: 14px;
    padding: 20px;
    border: 1px solid var(--docs-border);
    border-radius: 12px;
    background: white;
    color: var(--docs-text);
    transition: all 0.2s ease;
}
.docs-card:hover {
    border-color: var(--docs-primary);
    box-shadow: 0 10px 30px -10px rgba(79, 70, 229, 0.25);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--docs-text);
}
.docs-card-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--docs-primary-soft);
    color: var(--docs-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.docs-card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.docs-card ul {
    margin: 0;
    padding-left: 16px;
    color: var(--docs-text-mute);
    font-size: 13px;
    line-height: 1.7;
}
.docs-card-more { color: var(--docs-primary); list-style: none; margin-left: -16px; }

.docs-help-block {
    text-align: center;
    padding: 32px 24px;
    background: var(--docs-bg-soft);
    border-radius: 12px;
}
.docs-help-block h2 { margin: 0 0 8px; font-size: 17px; }
.docs-help-block p { margin: 0; color: var(--docs-text-mute); }

/* 面包屑 */
.docs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--docs-text-mute);
    margin-bottom: 12px;
}
.docs-breadcrumb i { font-size: 9px; }
.docs-breadcrumb .active { color: var(--docs-text); font-weight: 500; }

/* ================== Markdown 正文 ================== */
.docs-markdown { font-size: 16px; line-height: 1.8; }

.docs-markdown h1 {
    font-size: 30px;
    font-weight: 700;
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--docs-border);
    scroll-margin-top: calc(var(--docs-topbar-h) + 16px);
}
.docs-markdown h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 36px 0 14px;
    scroll-margin-top: calc(var(--docs-topbar-h) + 16px);
}
.docs-markdown h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 28px 0 10px;
    scroll-margin-top: calc(var(--docs-topbar-h) + 16px);
}
.docs-markdown h4 { font-size: 16px; font-weight: 600; margin: 22px 0 8px; }

.docs-markdown p { margin: 0 0 14px; }
.docs-markdown ul, .docs-markdown ol { margin: 0 0 14px; padding-left: 26px; }
.docs-markdown li { margin-bottom: 4px; }
.docs-markdown li > p { margin-bottom: 6px; }

.docs-markdown blockquote {
    margin: 16px 0;
    padding: 10px 16px;
    border-left: 3px solid var(--docs-primary);
    background: var(--docs-bg-soft);
    color: var(--docs-text);
    border-radius: 0 6px 6px 0;
}
.docs-markdown blockquote p:last-child { margin-bottom: 0; }

/* 行内代码 */
.docs-markdown code {
    background: var(--docs-code-bg);
    color: #db2777;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* 代码块 */
.docs-markdown pre {
    position: relative;
    background: #0f172a;
    color: #e2e8f0;
    padding: 36px 18px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-size: 13.5px;
    line-height: 1.65;
}
.docs-markdown pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: inherit;
}
.docs-markdown .highlight { margin: 16px 0; }

/* 代码块顶部小条：左语言标签 + 右复制按钮（始终可见） */
.docs-code-langbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 28px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    font-size: 11.5px;
}
.docs-code-lang {
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
.docs-copy-btn {
    background: transparent;
    color: #cbd5e1;
    border: none;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s ease;
}
.docs-copy-btn:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.docs-copy-btn.copied { color: #4ade80; }

/* 表格 */
.docs-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}
.docs-markdown th, .docs-markdown td {
    padding: 9px 12px;
    border: 1px solid var(--docs-border);
    text-align: left;
}
.docs-markdown th { background: var(--docs-bg-soft); font-weight: 600; }

.docs-markdown img {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--docs-border);
    margin: 16px 0;
    display: block;
}

/* admonition */
.docs-markdown .admonition {
    margin: 16px 0;
    padding: 10px 14px;
    border-radius: 8px;
    background: var(--docs-primary-soft);
    border-left: 3px solid var(--docs-primary);
}
.docs-markdown .admonition.warning { background: #fffbeb; border-left-color: #f59e0b; }
.docs-markdown .admonition.danger { background: #fef2f2; border-left-color: #ef4444; }
.docs-markdown .admonition.tip { background: #f0fdf4; border-left-color: #22c55e; }
.docs-markdown .admonition-title {
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--docs-primary);
    font-size: 14px;
}
.docs-markdown .admonition.warning .admonition-title { color: #b45309; }
.docs-markdown .admonition.danger .admonition-title { color: #b91c1c; }
.docs-markdown .admonition.tip .admonition-title { color: #15803d; }
.docs-markdown .admonition p:last-child { margin-bottom: 0; }

/* ================== 右侧大纲 ================== */
.docs-toc { padding-top: 8px; }
.docs-toc-inner {
    position: sticky;
    top: calc(var(--docs-topbar-h) + 24px);
    max-height: calc(100vh - var(--docs-topbar-h) - 48px);
    overflow-y: auto;
    border-left: 1px solid var(--docs-border);
    padding-left: 16px;
}
.docs-toc-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--docs-text-mute);
    margin-bottom: 8px;
}
.docs-toc-list { list-style: none; padding: 0; margin: 0; }
.docs-toc-list li { margin: 0; }
.docs-toc-list a {
    display: block;
    padding: 4px 0;
    color: var(--docs-text-mute);
    font-size: 13px;
    line-height: 1.4;
    border-left: 2px solid transparent;
    padding-left: 10px;
    margin-left: -12px;
    transition: all 0.12s ease;
}
.docs-toc-list a:hover { color: var(--docs-primary); text-decoration: none; }
.docs-toc-list a.active {
    color: var(--docs-primary);
    border-left-color: var(--docs-primary);
    font-weight: 500;
}
.docs-toc-list .docs-toc-h3 a {
    padding-left: 22px;
    font-size: 12.5px;
    color: #9ca3af;
}

/* 大纲为空时整列隐藏，正文自动撑满 */
.docs-article-shell.no-toc {
    grid-template-columns: minmax(0, 1fr);
}
.docs-article-shell.no-toc .docs-toc { display: none; }

/* ================== 上下篇 + 反馈 ================== */
.docs-prevnext {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 48px 0 16px;
    padding-top: 28px;
    border-top: 1px solid var(--docs-border);
}
.docs-prevnext-item {
    flex: 1;
    max-width: 48%;
    padding: 12px 16px;
    border: 1px solid var(--docs-border);
    border-radius: 8px;
    color: var(--docs-text);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all 0.15s ease;
}
.docs-prevnext-item:hover {
    border-color: var(--docs-primary);
    text-decoration: none;
    color: var(--docs-primary);
    transform: translateY(-1px);
}
.docs-prevnext-next { align-items: flex-end; text-align: right; }
.docs-prevnext-label {
    font-size: 11px;
    color: var(--docs-text-mute);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.docs-prevnext-title { font-weight: 600; font-size: 14.5px; }

.docs-feedback {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px;
    color: var(--docs-text-mute);
    font-size: 13px;
    border-top: 1px dashed var(--docs-border);
    margin-top: 8px;
}
.docs-feedback-shortcut { margin-left: auto; font-size: 12px; }

/* 移动端遮罩 */
.docs-mobile-overlay {
    display: none;
    position: fixed;
    inset: var(--docs-topbar-h) 0 0 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
}

/* ================== 回到顶部按钮 ================== */
.docs-back-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    color: var(--docs-primary);
    border: 1px solid var(--docs-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    z-index: 80;
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: all 0.2s ease;
}
.docs-back-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.docs-back-top:hover {
    background: var(--docs-primary);
    color: white;
    border-color: var(--docs-primary);
    transform: translateY(-2px);
}

/* ================== 响应式 ================== */
@media (max-width: 1280px) {
    .docs-shell { padding: 0 24px; gap: 40px; }
    .docs-article-shell { padding: 32px 24px 80px 0; }
}

@media (max-width: 1100px) {
    .docs-article-shell {
        grid-template-columns: minmax(0, 1fr);
        padding: 32px 0 80px;
    }
    .docs-toc { display: none; }
}

@media (max-width: 960px) {
    .docs-search { display: none; }

    .docs-shell {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .docs-sidebar {
        position: fixed;
        top: var(--docs-topbar-h);
        left: 0;
        bottom: 0;
        width: 280px;
        background: white;
        z-index: 95;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        padding: 16px;
        border-right: 1px solid var(--docs-border);
        overflow-y: auto;
    }
    .docs-sidebar-inner { position: static; max-height: none; padding-right: 0; }
    .docs-sidebar.open { transform: translateX(0); }
    .docs-mobile-overlay.open { display: block; }
    .docs-mobile-toggle { display: inline-flex; }

    .docs-article-shell { padding: 24px 0 60px; }
    .docs-hero h1 { font-size: 26px; }
    .docs-hero-sub { font-size: 14px; }
    .docs-prevnext { flex-direction: column; }
    .docs-prevnext-item { max-width: 100%; }
    .docs-prevnext-next { align-items: flex-start; text-align: left; }
    .docs-feedback-shortcut { display: none; }
}

@media (max-width: 600px) {
    .docs-brand-sub { display: none; }
    .docs-topbar-actions .docs-btn-ghost { display: none; }
    .docs-shell { padding: 0 14px; }
}
