/* ==================== 文档解析器样式 ==================== */

/* 文档解析容器 - 固定高度 */
.docs-parser-container {
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    height: 700px;
    /* 固定高度 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 文档头部 */
.docs-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.docs-header h3 {
    font-size: 1.5rem;
    margin: 0 0 8px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.docs-repo-name {
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 600;
    margin: 0;
}

/* 文档主体布局 - 填充剩余空间 */
.docs-body {
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 20px;
    flex: 1;
    /* 填充剩余空间 */
    min-height: 0;
    /* 允许 flex 子项缩小 */
    overflow: hidden;
}

/* 文档侧边栏 - 文件列表 */
.docs-sidebar {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    min-height: 0;
    /* 允许 flex 子项缩小 */
}

.docs-sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.docs-file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-file-item {
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.docs-file-item:hover {
    background: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
}

.docs-file-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    color: var(--primary-color);
    font-weight: 600;
}

.docs-file-item.loading {
    opacity: 0.6;
    cursor: wait;
}

.docs-file-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

.docs-file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.docs-folder {
    margin-top: 12px;
}

.docs-folder-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 6px 0;
    padding-left: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 文档内容区域 - 固定高度滚动 */
.docs-content {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    min-height: 0;
    /* 允许 flex 子项缩小 */
}

.docs-content-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-muted);
}

.docs-content-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.docs-content-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.docs-content-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Markdown 渲染样式 */
.docs-markdown {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.docs-markdown h1 {
    font-size: 1.8rem;
    margin: 0 0 20px 0;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-primary);
}

.docs-markdown h2 {
    font-size: 1.4rem;
    margin: 28px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.docs-markdown h3 {
    font-size: 1.2rem;
    margin: 24px 0 12px 0;
    color: var(--text-primary);
}

.docs-markdown h4,
.docs-markdown h5,
.docs-markdown h6 {
    font-size: 1rem;
    margin: 20px 0 10px 0;
    color: var(--text-primary);
}

.docs-markdown p {
    margin: 12px 0;
}

.docs-markdown a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.docs-markdown a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.docs-markdown ul,
.docs-markdown ol {
    margin: 12px 0;
    padding-left: 24px;
}

.docs-markdown li {
    margin: 6px 0;
}

.docs-markdown blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--primary-color);
    background: rgba(102, 126, 234, 0.05);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
}

.docs-markdown code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--error-color);
}

.docs-markdown pre {
    margin: 16px 0;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    position: relative;
}

.docs-markdown pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* 代码块复制按钮 */
.docs-code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    font-size: 0.75rem;
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
}

.docs-markdown pre:hover .docs-code-copy-btn {
    opacity: 1;
}

.docs-code-copy-btn:hover {
    background: var(--primary-color);
    color: white;
}

.docs-code-copy-btn.copied {
    background: var(--success-color);
    color: white;
}

.docs-markdown img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.docs-markdown table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.docs-markdown th,
.docs-markdown td {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.docs-markdown th {
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--text-primary);
}

.docs-markdown tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .docs-markdown tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.docs-markdown hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

/* 文档底部操作栏 */
.docs-footer {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.docs-footer .btn {
    min-width: 140px;
}

/* 加载动画 */
.docs-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(var(--bg-primary-rgb), 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    z-index: 10;
}

/* 错误提示 */
.docs-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--error-color);
}

.docs-error-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.docs-error-message {
    margin: 0 0 16px 0;
    font-size: 1rem;
}

.docs-error-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* 目录(TOC) */
.docs-toc {
    background: rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.docs-toc-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.docs-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.docs-toc-list li {
    margin: 6px 0;
}

.docs-toc-list a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
    display: block;
    padding: 4px 0;
}

.docs-toc-list a:hover {
    color: var(--primary-color);
}

.docs-toc-list .toc-h2 {
    padding-left: 0;
}

.docs-toc-list .toc-h3 {
    padding-left: 16px;
    font-size: 0.85rem;
}

.docs-toc-list .toc-h4 {
    padding-left: 32px;
    font-size: 0.8rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .docs-parser-container {
        height: auto;
        min-height: 500px;
        max-height: 80vh;
    }

    .docs-body {
        grid-template-columns: 1fr;
    }

    .docs-sidebar {
        max-height: 150px;
    }

    .docs-content {
        max-height: none;
        min-height: 300px;
    }

    .docs-footer {
        flex-direction: column;
    }

    .docs-footer .btn {
        width: 100%;
    }
}

/* 深色主题优化 */
[data-theme="dark"] .docs-parser-container {
    background: rgba(255, 255, 255, 0.03);
}

[data-theme="dark"] .docs-sidebar,
[data-theme="dark"] .docs-content {
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .docs-markdown pre {
    background: rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .docs-toc {
    background: rgba(102, 126, 234, 0.1);
}

/* 打印样式 */
@media print {

    .docs-sidebar,
    .docs-footer {
        display: none;
    }

    .docs-body {
        grid-template-columns: 1fr;
    }

    .docs-content {
        max-height: none;
        border: none;
        padding: 0;
    }
}

/* ==================== 面包屑导航 ==================== */
.docs-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px 12px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 0.82rem;
    border: 1px solid var(--border-color);
}

.docs-breadcrumb-item {
    color: var(--primary-color);
    cursor: default;
    transition: opacity 0.2s;
}

.docs-breadcrumb-item:hover {
    opacity: 0.7;
}

.docs-breadcrumb-sep {
    color: var(--text-muted);
    margin: 0 3px;
    font-size: 0.75rem;
}

.docs-breadcrumb-current {
    color: var(--text-primary);
    font-weight: 600;
}

/* ==================== 移动端侧边栏抽屉 ==================== */
@media (max-width: 768px) {
    .docs-body {
        grid-template-columns: 1fr;
        position: relative;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 270px;
        height: 100vh;
        z-index: 1000;
        border-radius: 0 16px 16px 0;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        padding: 20px 16px;
    }

    .docs-sidebar.drawer-open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
    }

    /* 抽屉遮罩 */
    .docs-drawer-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .docs-drawer-overlay.active {
        display: block;
    }

    /* 移动端侧边栏切换按钮 */
    .docs-sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: 1px solid var(--border-color);
        background: var(--bg-tertiary);
        border-radius: 8px;
        color: var(--text-secondary);
        cursor: pointer;
        font-size: 1.1rem;
        position: absolute;
        top: -42px;
        left: 0;
        z-index: 10;
        transition: all 0.2s;
    }

    .docs-sidebar-toggle:hover {
        background: var(--primary-color);
        color: white;
        border-color: var(--primary-color);
    }

    .docs-parser-container {
        height: auto;
        min-height: 500px;
        max-height: 80vh;
    }
}

/* 大屏幕隐藏移动端控件 */
@media (min-width: 769px) {

    .docs-sidebar-toggle,
    .docs-drawer-overlay {
        display: none !important;
    }
}

/* ==================== 迷你滚动进度指示器 ==================== */
.docs-minimap {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    background: transparent;
    z-index: 5;
    pointer-events: none;
    border-radius: 2px;
    overflow: hidden;
}

.docs-minimap-thumb {
    position: absolute;
    top: 0;
    width: 100%;
    min-height: 20px;
    background: var(--primary-color);
    opacity: 0.4;
    border-radius: 2px;
    transition: opacity 0.3s;
}

.docs-content:hover .docs-minimap-thumb {
    opacity: 0.7;
}

.docs-content {
    position: relative;
}