/* Docs Layout */
.docs-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.docs-layout {
    display: flex;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar */
.docs-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    position: sticky;
    top: 61px;
    height: calc(100vh - 61px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 300;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.sidebar-inner {
    padding: 0 16px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 8px;
    padding: 0 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.88rem;
    transition: all 0.15s;
    line-height: 1.4;
}

.sidebar-link:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.sidebar-link.active {
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent);
    font-weight: 500;
}

.sidebar-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    background: rgba(88, 166, 255, 0.1);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-link.active .sidebar-num {
    background: var(--accent);
    color: var(--bg);
}

/* Main Content */
.docs-content {
    flex: 1;
    min-width: 0;
    padding: 32px 48px 60px;
    max-width: 900px;
}

.docs-article {
    line-height: 1.75;
}

.docs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 0;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Article Markdown Rendering */
.docs-article h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--accent), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.docs-article h2 {
    font-size: 1.45rem;
    margin-top: 48px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.docs-article h3 {
    font-size: 1.15rem;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--text);
}

.docs-article h4 {
    font-size: 1rem;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.docs-article p {
    margin-bottom: 16px;
    color: var(--text);
}

.docs-article a {
    color: var(--accent);
    text-decoration: none;
}
.docs-article a:hover {
    text-decoration: underline;
}

.docs-article ul, .docs-article ol {
    margin-bottom: 16px;
    padding-left: 24px;
}

.docs-article li {
    margin-bottom: 6px;
}

.docs-article li > ul, .docs-article li > ol {
    margin-top: 6px;
    margin-bottom: 0;
}

.docs-article img {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.docs-article blockquote {
    border-left: 4px solid var(--accent);
    padding: 12px 20px;
    margin: 16px 0;
    background: rgba(88, 166, 255, 0.06);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
}

.docs-article blockquote p:last-child {
    margin-bottom: 0;
}

.docs-article code {
    background: rgba(88, 166, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: 0.85em;
    color: var(--accent);
}

.docs-article pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 16px 0;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.docs-article pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.6;
}

.docs-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.docs-article th, .docs-article td {
    text-align: left;
    padding: 10px 14px;
    border: 1px solid var(--border);
}

.docs-article th {
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 600;
}

.docs-article tr:hover td {
    background: rgba(88, 166, 255, 0.03);
}

.docs-article hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 32px 0;
}

.docs-article strong {
    color: var(--text);
    font-weight: 600;
}

/* Pager */
.docs-pager {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.pager-link {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.2s;
    max-width: 48%;
}

.pager-link:hover {
    border-color: var(--accent);
    background: var(--surface-hover);
    transform: translateY(-1px);
}

.pager-link.next { margin-left: auto; text-align: right; }

.pager-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pager-title {
    font-size: 0.9rem;
    color: var(--accent);
    font-weight: 500;
}

/* Table of Contents */
.docs-toc {
    width: 220px;
    min-width: 220px;
    padding: 24px 16px;
    position: sticky;
    top: 61px;
    height: calc(100vh - 61px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.docs-toc h4 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.toc-link {
    display: block;
    padding: 4px 0 4px 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: all 0.15s;
    line-height: 1.5;
}

.toc-link:hover {
    color: var(--text);
}

.toc-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
}

.toc-link.toc-h3 {
    padding-left: 24px;
    font-size: 0.78rem;
}

/* Nav active state */
.nav-active {
    color: var(--accent) !important;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 1200px) {
    .docs-toc { display: none; }
    .docs-content { max-width: 100%; }
}

@media (max-width: 768px) {
    .docs-sidebar {
        position: fixed;
        left: -300px;
        top: 0;
        z-index: 250;
        height: 100vh;
        transition: left 0.3s ease;
        box-shadow: none;
    }

    .docs-sidebar.open {
        left: 0;
        box-shadow: 4px 0 24px rgba(0,0,0,0.5);
    }

    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }

    .docs-content { padding: 24px 16px 60px; }

    .docs-article h1 { font-size: 1.5rem; }
    .docs-article h2 { font-size: 1.2rem; }

    .docs-pager { flex-direction: column; }
    .pager-link { max-width: 100%; }
    .pager-link.next { text-align: left; }
}
