/* ========================================
   MSE 使用说明书 - 独立样式
   ShowDoc 风格，默认白色主题，可切换深色
   ======================================== */

/* CSS 变量 - 浅色主题（默认） */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #f0f1f3;
    --bg-code: #f5f6f8;
    --bg-highlight: #fff3cd;
    --border-color: #e8e8e8;
    --border-light: #f0f0f0;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-tertiary: #999999;
    --text-heading: #1a1a1a;
    --link-color: #3b82f6;
    --link-hover: #2563eb;
    --accent-color: #3b82f6;
    --shadow-light: 0 1px 4px rgba(0,0,0,0.08);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.12);
    --sidebar-width: 280px;
    --topbar-height: 56px;
}

/* CSS 变量 - 深色主题 */
[data-theme="dark"] {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252525;
    --bg-tertiary: #2d2d2d;
    --bg-code: #2d2d2d;
    --bg-highlight: #4a4520;
    --border-color: #333333;
    --border-light: #3a3a3a;
    --text-primary: #d4d4d4;
    --text-secondary: #a0a0a0;
    --text-tertiary: #707070;
    --text-heading: #e6e6e6;
    --link-color: #60a5fa;
    --link-hover: #93c5fd;
    --accent-color: #60a5fa;
    --shadow-light: 0 1px 4px rgba(0,0,0,0.3);
    --shadow-medium: 0 2px 8px rgba(0,0,0,0.4);
}

/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* ========================================
   顶部导航栏
   ======================================== */
.docs-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    transition: background 0.3s, border-color 0.3s;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-heading);
}

.topbar-back {
    font-size: 14px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.topbar-back:hover {
    background: var(--bg-tertiary);
    color: var(--link-color);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.topbar-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.topbar-btn svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   主容器
   ======================================== */
.docs-container {
    display: flex;
    margin-top: var(--topbar-height);
    height: calc(100vh - var(--topbar-height));
}

/* ========================================
   左侧边栏
   ======================================== */
.docs-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s, background 0.3s, border-color 0.3s;
}

.sidebar-search {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    height: 36px;
    padding: 0 12px 0 36px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* 目录项 */
.nav-chapter {
    margin-bottom: 4px;
}

.nav-chapter-title {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-heading);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: all 0.2s;
}

.nav-chapter-title:hover {
    background: var(--bg-tertiary);
}

.nav-chapter-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.nav-chapter.collapsed .nav-chapter-arrow {
    transform: rotate(-90deg);
}

.nav-chapter.collapsed .nav-sections {
    display: none;
}

.nav-sections {
    padding-left: 12px;
}

.nav-section {
    padding: 6px 16px 6px 32px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    margin: 2px 8px;
    transition: all 0.2s;
    text-decoration: none;
    display: block;
}

.nav-section:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-section.active {
    background: var(--accent-color);
    color: #ffffff;
}

/* 搜索结果 */
.search-results {
    padding: 12px;
}

.search-result-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.search-result-item:hover {
    border-color: var(--accent-color);
    box-shadow: var(--shadow-light);
}

.search-result-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 4px;
}

.search-result-context {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-highlight {
    background: var(--bg-highlight);
    padding: 1px 3px;
    border-radius: 2px;
}

/* ========================================
   右侧内容区
   ======================================== */
.docs-content {
    flex: 1;
    overflow-y: auto;
    padding: 40px 60px;
    background: var(--bg-primary);
    transition: background 0.3s;
}

.docs-content::-webkit-scrollbar {
    width: 8px;
}

.docs-content::-webkit-scrollbar-track {
    background: transparent;
}

.docs-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.docs-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

.content-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

/* 章节标题 */
.section-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.subsection-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-heading);
    margin: 32px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* 正文内容 */
.content-body {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
}

.content-body p {
    margin-bottom: 16px;
}

.content-body ul,
.content-body ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.content-body li {
    margin-bottom: 8px;
}

.content-body a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.content-body a:hover {
    color: var(--link-hover);
    border-bottom-color: var(--link-hover);
}

/* 代码块 */
.content-body code {
    background: var(--bg-code);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary);
}

.content-body pre {
    background: var(--bg-code);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    overflow-x: auto;
}

.content-body pre code {
    background: transparent;
    padding: 0;
    font-size: 13px;
    line-height: 1.6;
}

/* 截图占位 */
.screenshot-placeholder {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 60px 20px;
    text-align: center;
    margin: 20px 0;
    color: var(--text-tertiary);
    font-size: 14px;
}

.screenshot-placeholder::before {
    content: "📷 ";
    font-size: 24px;
    display: block;
    margin-bottom: 8px;
}

/* 表格 */
.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background: var(--bg-primary);
}

.content-body th,
.content-body td {
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    text-align: left;
}

.content-body th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-heading);
}

.content-body tr:hover {
    background: var(--bg-secondary);
}

/* 提示框 */
.tip-box {
    background: var(--bg-secondary);
    border-left: 4px solid var(--accent-color);
    padding: 16px 20px;
    margin: 20px 0;
    border-radius: 4px;
}

.tip-box.warning {
    border-left-color: #f59e0b;
}

.tip-box.danger {
    border-left-color: #ef4444;
}

.tip-box-title {
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 8px;
}

/* 快捷键标签 */
kbd {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 2px 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ========================================
   全屏模式
   ======================================== */
body.fullscreen-mode .docs-sidebar {
    width: 0;
    overflow: hidden;
}

body.fullscreen-mode .docs-topbar {
    background: transparent;
    border-bottom: none;
    box-shadow: none;
}

body.fullscreen-mode .docs-content {
    padding: 40px 80px;
}

/* 全屏模式下浮动返回按钮 */
.fullscreen-exit-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 1001;
    display: none;
}

body.fullscreen-mode .fullscreen-exit-btn {
    display: block;
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 768px) {
    .docs-sidebar {
        position: fixed;
        left: -100%;
        top: var(--topbar-height);
        height: calc(100vh - var(--topbar-height));
        z-index: 999;
        transition: left 0.3s;
    }
    
    .docs-sidebar.open {
        left: 0;
    }
    
    .docs-content {
        padding: 24px 20px;
    }
    
    .section-title {
        font-size: 24px;
    }
    
    .subsection-title {
        font-size: 20px;
    }
}
