:root {
    --header-height: 64px;
    --sidebar-width: 280px;
    --toc-width: 240px;
    --primary-color: #0066ff;
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --text-muted: #666666;
    --border-color: #e5e7eb;
    --hover-bg: #f3f4f6;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.6;
    overflow-x: hidden;
}

.search-container {
    position: relative;
    z-index: 1001;
}

/* --- Header --- */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
}

.header-left {
    width: var(--sidebar-width);
    display: flex;
    align-items: center;
}

.hamburger-btn {
    display: none;
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: flex-start;
    padding-left: 64px;
}

.header-right {
    width: var(--toc-width);
    display: flex;
    justify-content: flex-end;
}

.logo-container {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 12px;
}

.header-logo {
    height: 60px;
}

.logo-text {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-color);
}

.search-box {
    background: var(--hover-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 400px;
}

.search-icon {
    width: 14px;
    height: 14px;
    fill: var(--text-muted);
}

#global-search {
    background: transparent;
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
}

.search-shortcut {
    font-size: 11px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 2px 4px;
    border-radius: 4px;
    background: white;
}


/* --- Layout --- */
.page-wrapper {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    width: var(--sidebar-width);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - var(--header-height));
    position: fixed;
    overflow-y: auto;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    margin-right: var(--toc-width);
    padding: 40px 64px;
    max-width: 1200px;
}

.right-sidebar {
    width: var(--toc-width);
    position: fixed;
    right: 0;
    top: var(--header-height);
    bottom: 0;
    padding: 40px 24px;
    overflow-y: auto;
}

/* --- Navigation --- */
.sidebar-nav {
    flex: 1;
    padding: 24px 0;
}

.nav-list {
    list-style: none;
}

.nav-group-title {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 16px 24px 8px;
    letter-spacing: 0.05em;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 24px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--hover-bg);
}

.nav-link.active {
    color: var(--primary-color);
    background: #e6f0ff;
}

/* --- Scrollbar Polish --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.submenu {
    list-style: none;
    padding-left: 12px;
    display: none;
}

.submenu.open {
    display: block;
}

.toggle-icon {
    transition: transform 0.2s;
}

/* --- Content --- */
.content-wrapper {
    max-width: 800px;
}

.img-fluid {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.image-box {
    margin: 24px 0;
    padding: 12px;
    background: #fdfdfd;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: inline-block;
    max-width: 100%;
}

.doc-img {
    border-radius: 8px;
    border: 1px solid #eee;
}

/* Scoped to .gitbook-theme (body class) so specificity 0-1-1 beats Tailwind Preflight's 0-0-1 */
.gitbook-theme h1 { font-size: 2.5rem; margin-bottom: 24px; font-weight: 800; }
.gitbook-theme h2 { font-size: 1.75rem; margin: 40px 0 16px; font-weight: 700; border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.gitbook-theme h3 { font-size: 1.25rem; margin: 24px 0 12px; font-weight: 600; }

/* Remove top margin when h2/h3 is the very first element (no h1 above it) */
.content-wrapper > h2:first-child,
.content-wrapper > h3:first-child,
.content-wrapper > section:first-child > h2:first-child,
.content-wrapper > section:first-child > h3:first-child { margin-top: 0; }

.gitbook-theme p { margin-bottom: 16px; color: #374151; }

.content-wrapper ul,
.content-wrapper ol {
    margin-bottom: 24px;
    padding-left: 28px;
}

.content-wrapper ul {
    list-style-type: disc;
}

.content-wrapper ol {
    list-style-type: decimal;
}

.content-wrapper li {
    margin-bottom: 12px;
    color: #374151;
    display: list-item;
}

.content-wrapper a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.content-wrapper a:hover {
    opacity: 0.8;
}

.content-wrapper ul ul, 
.content-wrapper ol ol, 
.content-wrapper ul ol, 
.content-wrapper ol ul { 
    margin-top: 8px;
    margin-bottom: 8px; 
}

blockquote {
    border-left: 4px solid var(--primary-color);
    background: #f8faff;
    padding: 16px 24px;
    margin: 24px 0;
    border-radius: 0 8px 8px 0;
}

blockquote.info { border-left-color: #3b82f6; background: #eff6ff; }
blockquote.warning { border-left-color: #f59e0b; background: #fffbeb; }

pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 24px 20px 20px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 24px 0;
    font-size: 14px;
    position: relative;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f3f4f6;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.copy-btn.copied {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

/* --- TOC --- */
.toc-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.toc-list {
    list-style: none;
}

.toc-link {
    text-decoration: none;
    color: var(--text-muted);
    font-size: 13px;
    display: block;
    padding: 4px 0;
    transition: color 0.2s;
}

.toc-link:hover { color: var(--text-color); }
.toc-link.active { color: var(--primary-color); font-weight: 600; }

.toc-h3 { padding-left: 12px; }

/* --- Footer Nav --- */
.page-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 64px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
    gap: 24px;
}

.nav-btn {
    flex: 1;
    text-decoration: none;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.2s;
}

.nav-btn:hover { border-color: var(--primary-color); background: #f9fbff; }

.nav-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.nav-title { display: block; font-weight: 600; color: var(--text-color); }

.content-footer {
    margin-top: 48px;
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Search Dropdown --- */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    max-height: 400px;
    overflow-y: auto;
    z-index: 2000;
    display: none;
}

.search-dropdown.active {
    display: block;
}

.search-result-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-color);
    border-bottom: 1px solid #f9fafb;
    transition: background 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: #f3f9ff;
}

.search-result-item .result-title {
    font-size: 14px;
    font-weight: 500;
}

.search-result-item .result-path {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.no-results-popover {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* --- Tabs Component --- */
.tabs-container {
    margin: 24px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.tabs-header {
    display: flex;
    background: #f9fafb;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-right: 1px solid var(--border-color);
    transition: all 0.2s;
    white-space: nowrap;
}

.tab-btn:hover {
    background: #f3f4f6;
    color: var(--text-color);
}

.tab-btn.active {
    background: #fff;
    color: var(--primary-color);
    font-weight: 600;
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: -1px; /* Overlap active border */
}

.tab-content {
    display: none;
    padding: 24px;
}

.tab-content.active {
    display: block;
}

/* Remove default margins for first/last elements in tab content */
.tab-content > :first-child { margin-top: 0; }
.tab-content > :last-child { margin-bottom: 0; }
