/* ============================================================
   UniARM · 文档样式
   ============================================================ */

/* ===== CSS 变量（继承产品主题） ===== */
:root {
    --bg-primary: #0b0d0f;
    --bg-secondary: #0d1117;
    --bg-card: #161b22;
    --bg-card-hover: #1c2128;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-bg: rgba(88, 166, 255, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
    --bg-primary: #f6f8fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f2f5;
    --border-color: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #57606a;
    --accent: #0969da;
    --accent-bg: rgba(9, 105, 218, 0.08);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

/* ===== 基础 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    transition: background 0.3s, color 0.3s;
}

/* ===== 文档容器 ===== */
.docs-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== 顶部导航 ===== */
.docs-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    transition: background 0.3s, border-color 0.3s;
}

.docs-header-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.docs-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.2rem;
}

.docs-logo i {
    color: var(--accent);
}

.docs-logo-badge {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 0.1rem 0.6rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.docs-header-nav {
    display: flex;
    gap: 1.2rem;
    align-items: center;
}

.docs-header-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.docs-header-nav a:hover {
    color: var(--text-primary);
}

/* ===== 主体布局 ===== */
.docs-body {
    display: flex;
    flex: 1;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* ===== 侧边栏 ===== */
.docs-sidebar {
    width: 280px;
    min-height: calc(100vh - 60px);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 1.2rem 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
    transition: width 0.3s, background 0.3s, border-color 0.3s, transform 0.3s;
}

.docs-sidebar::-webkit-scrollbar {
    width: 4px;
}

.docs-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.docs-sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ===== 搜索框 ===== */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 1.2rem;
    margin-bottom: 1.2rem;
}

.sidebar-search i {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.sidebar-search input {
    flex: 1;
    padding: 0.4rem 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    font-family: inherit;
}

.sidebar-search input::placeholder {
    color: var(--text-secondary);
}

/* ===== 导航目录 ===== */
.sidebar-nav {
    flex: 1;
    padding: 0 0.6rem;
    overflow-y: auto;
}

.sidebar-nav ul {
    list-style: none;
}

.sidebar-nav li {
    margin: 1px 0;
}

.sidebar-nav a {
    display: block;
    padding: 0.4rem 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.sidebar-nav a:hover {
    background: var(--accent-bg);
    color: var(--text-primary);
}

.sidebar-nav a.active {
    background: var(--accent-bg);
    color: var(--accent);
    font-weight: 500;
}

/* ===== 目录层级缩进 ===== */
.sidebar-nav .level-1 {
    padding-left: 0.6rem;
}

.sidebar-nav .level-2 {
    padding-left: 1.8rem;
}

.sidebar-nav .level-3 {
    padding-left: 3rem;
}

/* ===== 目录分组标题 ===== */
.sidebar-nav .nav-group {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.8rem 0.3rem;
    opacity: 0.6;
}

/* ===== 侧边栏底部 ===== */
.sidebar-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--accent-bg);
    color: var(--text-primary);
}

/* ===== 侧边栏收起状态 ===== */
.docs-sidebar.collapsed {
    width: 60px;
}

.docs-sidebar.collapsed .sidebar-search,
.docs-sidebar.collapsed .sidebar-nav,
.docs-sidebar.collapsed .sidebar-footer span {
    display: none;
}

.docs-sidebar.collapsed .sidebar-footer {
    justify-content: center;
}

.docs-sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* ===== 内容区 ===== */
.docs-content {
    flex: 1;
    padding: 2.5rem 3rem;
    max-width: 900px;
    min-height: calc(100vh - 60px);
    background: var(--bg-primary);
    transition: background 0.3s;
}

/* ===== 内容排版 ===== */
.docs-content h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    letter-spacing: -0.02em;
}

.docs-content h2 {
    font-size: 1.6rem;
    font-weight: 600;
    margin: 2rem 0 0.8rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border-color);
}

.docs-content h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 1.5rem 0 0.6rem;
}

.docs-content p {
    color: var(--text-secondary);
    margin: 0.8rem 0;
}

.docs-content ul,
.docs-content ol {
    color: var(--text-secondary);
    padding-left: 1.5rem;
    margin: 0.6rem 0;
}

.docs-content li {
    margin: 0.3rem 0;
}

.docs-content code {
    background: var(--bg-card);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
}

.docs-content pre {
    background: var(--bg-card);
    padding: 1rem 1.2rem;
    border-radius: 10px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    margin: 1rem 0;
}

.docs-content pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.docs-content .note {
    background: var(--accent-bg);
    border-left: 3px solid var(--accent);
    padding: 1rem 1.2rem;
    border-radius: 0 10px 10px 0;
    margin: 1rem 0;
}

.docs-content .note i {
    color: var(--accent);
    margin-right: 0.5rem;
}

.docs-content .warning {
    background: rgba(210, 153, 34, 0.1);
    border-left: 3px solid #d29922;
    padding: 1rem 1.2rem;
    border-radius: 0 10px 10px 0;
    margin: 1rem 0;
}

.docs-content .warning i {
    color: #d29922;
    margin-right: 0.5rem;
}

.docs-content .breadcrumb {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.docs-content .breadcrumb a {
    color: var(--accent);
    text-decoration: none;
}

.docs-content .breadcrumb a:hover {
    text-decoration: underline;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .docs-sidebar {
        position: fixed;
        left: 0;
        top: 60px;
        width: 280px;
        height: calc(100vh - 60px);
        transform: translateX(-100%);
        z-index: 99;
        box-shadow: var(--shadow);
    }

    .docs-sidebar.open {
        transform: translateX(0);
    }

    .docs-content {
        padding: 1.5rem 1.2rem;
    }

    .docs-header {
        padding: 0 1rem;
    }

    .docs-header-nav a span {
        display: none;
    }

    /* 移动端显示侧边栏开关 */
    .mobile-menu-btn {
        display: block !important;
    }
}

@media (max-width: 480px) {
    .docs-content {
        padding: 1rem 0.8rem;
    }

    .docs-content h1 {
        font-size: 1.6rem;
    }

    .docs-content h2 {
        font-size: 1.3rem;
    }
}

/* ===== 移动端菜单按钮 ===== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
}

/* ===== 产品切换器 ===== */
.sidebar-product-switcher {
    padding: 0.6rem 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin: 0 0.8rem 0.8rem;
}

.product-switcher-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
    display: block;
}

.product-switcher-select {
    width: 100%;
    padding: 0.4rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.product-switcher-select:hover,
.product-switcher-select:focus {
    border-color: var(--accent);
}

.product-switcher-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}