/* ============================================================
   文档中心 - 专业美化版
   设计风格参考：Stripe Docs / VitePress / Docusaurus
   ============================================================ */

:root {
    /* 配色系统 */
    --sidebar-width: 280px;
    --sidebar-bg: #fafbfc;
    --sidebar-border: #eaecef;
    --main-bg: #f5f6f8;
    --text-primary: #1b1f24;
    --text-secondary: #586069;
    --text-muted: #959da5;
    --accent: #0969da;
    --accent-light: #ddf4ff;
    --accent-dark: #0550ae;
    --hover-bg: #f3f4f6;
    --active-bg: #ddf4ff;
    --border-color: #e1e4e8;
    --card-bg: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans',
                 'PingFang SC', 'Microsoft YaHei', Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-primary);
    background: var(--main-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }

/* ============================================================
   布局
   ============================================================ */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   侧边栏
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow: hidden;
    position: relative;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    max-width: 0;
    border-right: none;
}
.sidebar.collapsed .sidebar-nav,
.sidebar.collapsed .logo-text { opacity: 0; pointer-events: none; }
.sidebar.collapsed .sidebar-header-left { padding-left: 12px; }
.sidebar.collapsed .logo-icon { margin-right: 0; }

@media (max-width: 768px) {
    .sidebar {
        position: fixed !important;
        left: 0; top: 0; bottom: 0;
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width) !important;
        max-width: var(--sidebar-width) !important;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--sidebar-border) !important;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed { transform: translateX(-100%); border-right: none !important; }
    .sidebar.collapsed.open { transform: translateX(0); }
    .collapse-toggle { display: none !important; }
}

/* 侧边栏头部 */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 57px;
    border-bottom: 1px solid var(--sidebar-border);
    gap: 8px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
}

.sidebar-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    min-width: 0;
}

.menu-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 6px 8px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.menu-toggle:hover { background: var(--hover-bg); color: var(--text-primary); }

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    transition: opacity 0.25s ease;
    min-width: 0;
}
.logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}
.logo-text {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.25s ease;
}

.collapse-toggle {
    background: none;
    border: 1px solid transparent;
    font-size: 15px;
    cursor: pointer;
    padding: 5px 8px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
    line-height: 1;
}
.collapse-toggle:hover { background: var(--hover-bg); color: var(--text-secondary); }

/* 文档列表 */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    transition: opacity 0.25s ease;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 2px; }

.doc-list { list-style: none; padding: 0 8px; }
.doc-item { margin-bottom: 1px; }

.doc-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    transition: all 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.45;
}
.doc-link::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
    opacity: 0.5;
}
.doc-link:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}
.doc-link:hover::before {
    background: var(--accent);
    opacity: 1;
}
.doc-link.active {
    background: var(--active-bg);
    color: var(--accent);
    font-weight: 500;
}
.doc-link.active::before {
    background: var(--accent);
    opacity: 1;
    width: 6px;
    height: 6px;
}
.doc-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-hint {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
}
.empty-hint p { font-size: 14px; margin-bottom: 4px; }
.empty-hint small { font-size: 13px; }

/* 侧边栏搜索框 */
.sidebar-search {
    padding: 0 16px 12px;
    flex-shrink: 0;
}
.sidebar-search-input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: all 0.15s;
    background: var(--card-bg);
    color: var(--text-primary);
}
.sidebar-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(9,105,218,0.12);
}
.sidebar-search-input::placeholder { color: var(--text-muted); }

/* ============================================================
   主内容区
   ============================================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--main-bg);
    min-width: 0;
}

/* 顶部导航栏 */
.top-bar {
    display: flex;
    align-items: center;
    padding: 0 28px;
    height: 57px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 14px;
    flex-shrink: 0;
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.mobile-only { display: none !important; }

.breadcrumb {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.breadcrumb a { color: var(--accent); font-weight: 500; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .separator { margin: 0 8px; color: var(--text-muted); }

.search-box { margin-left: auto; max-width: 220px; width: 100%; }
.search-input {
    width: 100%;
    padding: 7px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    outline: none;
    transition: all 0.15s;
    background: var(--main-bg);
    color: var(--text-primary);
}
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(9,105,218,0.12);
    background: var(--card-bg);
}
.search-input::placeholder { color: var(--text-muted); }

/* 内容区域 */
.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 36px 44px;
    scroll-behavior: smooth;
}
.content-area::-webkit-scrollbar { width: 8px; }
.content-area::-webkit-scrollbar-track { background: transparent; }
.content-area::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 4px; }
.content-area::-webkit-scrollbar-thumb:hover { background: #b0b8c0; }

.article-view {
    display: flex;
    gap: 40px;
    max-width: 1460px;
    margin: 0 auto;
    width: 100%;
    align-items: flex-start;
}

/* 欢迎页面 */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 65vh;
    text-align: center;
    width: 100%;
}
.welcome-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--accent-light), var(--active-bg));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(9,105,218,0.12);
}
.welcome-screen h2 {
    font-size: 26px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}
.welcome-screen p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 36px;
}
.quick-stats { display: flex; gap: 20px; }
.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 32px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s, transform 0.2s;
}
.stat-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.stat-number { font-size: 34px; font-weight: 700; color: var(--accent); letter-spacing: -1px; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ============================================================
   MARKDOWN 文章样式
   ============================================================ */
.markdown-body {
    flex: 1;
    min-width: 0;
    max-width: 880px;
    background: var(--card-bg);
    padding: 48px 52px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    line-height: 1.75;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: auto;
    font-size: 15.5px;
}

/* 标题 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    scroll-margin-top: 76px;
}
.markdown-body h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    margin-top: 0;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    line-height: 1.35;
    letter-spacing: -0.4px;
}
.markdown-body h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 36px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    line-height: 1.4;
    letter-spacing: -0.3px;
}
.markdown-body h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 28px 0 12px;
    color: var(--text-primary);
    line-height: 1.45;
}
.markdown-body h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 24px 0 10px;
    color: var(--text-primary);
    line-height: 1.5;
}
.markdown-body h5, .markdown-body h6 {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 0 8px;
    color: var(--text-secondary);
}

/* 段落 */
.markdown-body p {
    margin: 14px 0;
    color: var(--text-primary);
    line-height: 1.8;
}

/* 行内元素 */
.markdown-body strong { font-weight: 600; }
.markdown-body em { font-style: italic; }
.markdown-body del { text-decoration: line-through; color: var(--text-muted); }
.markdown-body a {
    color: var(--accent);
    text-decoration: none;
}
.markdown-body a:hover { text-decoration: underline; }

/* 行内代码 */
.markdown-body code:not(pre code) {
    background: rgba(175,184,193,0.15);
    color: #cf222e;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: 0.86em;
    line-height: 1.5;
    word-break: break-word;
}

/* 代码块 */
.markdown-body pre {
    margin: 20px 0;
    border-radius: var(--radius-md);
    overflow: auto;
    background: #f6f8fa !important;
    padding: 20px 24px;
    line-height: 1.6;
    position: relative;
    max-height: 600px;
    white-space: pre;
    word-wrap: normal;
    word-break: normal;
    tab-size: 4;
    border: 1px solid var(--border-color);
}
.markdown-body pre code {
    background: transparent !important;
    color: #24292e !important;
    padding: 0;
    font-size: 13.5px;
    border-radius: 0;
    line-height: 1.6;
    white-space: pre;
    word-wrap: normal;
    word-break: normal;
}
.markdown-body pre::-webkit-scrollbar { height: 8px; width: 8px; }
.markdown-body pre::-webkit-scrollbar-track { background: transparent; }
.markdown-body pre::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }
.markdown-body pre::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }

/* 列表 */
.markdown-body ul,
.markdown-body ol {
    margin: 14px 0;
    padding-left: 28px;
}
.markdown-body li {
    margin: 5px 0;
    padding: 2px 0;
    color: var(--text-primary);
    line-height: 1.7;
}
.markdown-body li::marker { color: var(--accent); }
.markdown-body li > ul,
.markdown-body li > ol { margin: 4px 0; }

/* 图片 */
.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    margin: 20px 0;
    border: 1px solid var(--border-color);
    display: block;
}

/* 引用块 */
.markdown-body blockquote {
    margin: 18px 0;
    padding: 14px 20px;
    border-left: 4px solid var(--accent);
    background: #f6f8fa;
    color: var(--text-secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.markdown-body blockquote p:last-child { margin-bottom: 0; }

/* 表格 */
.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    margin: 18px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.markdown-body th,
.markdown-body td {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    text-align: left;
    vertical-align: top;
}
.markdown-body th {
    background: #f6f8fa;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}
.markdown-body tr:nth-child(even) td { background: #fafbfc; }
.markdown-body tr:hover td { background: #f3f5f8; }

/* 分隔线 */
.markdown-body hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 32px 0;
}

/* ============================================================
   右侧目录
   ============================================================ */
.toc-sidebar {
    width: 220px;
    min-width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    height: fit-content;
    max-height: calc(100vh - 88px);
    overflow-y: auto;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 18px 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    order: -1;
}
.toc-sidebar::-webkit-scrollbar { width: 3px; }
.toc-sidebar::-webkit-scrollbar-thumb { background: #d0d7de; border-radius: 2px; }

.toc-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.toc-list { list-style: none; }
.toc-item { margin: 2px 0; }
.toc-item a {
    display: block;
    padding: 5px 10px;
    font-size: 13px;
    color: var(--text-secondary);
    border-left: 2px solid transparent;
    transition: all 0.15s;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    line-height: 1.5;
}
.toc-item a:hover {
    color: var(--accent);
    background: var(--hover-bg);
    border-left-color: var(--accent);
}
.toc-level-3 a { font-size: 12.5px; padding-left: 20px; color: var(--text-muted); }
.toc-level-4 a { font-size: 12px; padding-left: 28px; color: var(--text-muted); }

/* ============================================================
   遮罩层（移动端）
   ============================================================ */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(27,31,36,0.4);
    z-index: 90;
    backdrop-filter: blur(2px);
}
.overlay.active { display: block; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1200px) {
    .markdown-body { padding: 40px 42px; }
    .content-area { padding: 28px 32px; }
}

@media (max-width: 1024px) {
    .toc-sidebar { display: none; }
    .markdown-body { padding: 36px 38px; }
    .content-area { padding: 24px 28px; }
}

@media (max-width: 768px) {
    .mobile-only { display: block !important; }
    .top-bar { padding: 0 16px; }
    .search-box { max-width: 130px; }
    .content-area { padding: 18px 14px; }
    .markdown-body { padding: 24px 18px; border-radius: var(--radius-md); }
    .welcome-screen { min-height: 50vh; }
    .welcome-icon { width: 60px; height: 60px; font-size: 26px; }
    .welcome-screen h2 { font-size: 22px; }
    .quick-stats { gap: 12px; flex-direction: column; align-items: center; }
    .stat-item { padding: 16px 24px; width: 100%; max-width: 200px; }
    .stat-number { font-size: 28px; }
    .article-view { flex-direction: column; }
    .breadcrumb { font-size: 13px; }
}
