:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --secondary: #764ba2;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --dark: #1a202c;
    --gray-900: #2d3748;
    --gray-800: #4a5568;
    --gray-700: #718096;
    --gray-600: #a0aec0;
    --gray-500: #cbd5e0;
    --gray-400: #e2e8f0;
    --gray-300: #edf2f7;
    --gray-200: #f7fafc;
    --gray-100: #ffffff;

    --sidebar-width: 280px;
    --header-height: 64px;
    --content-max-width: 900px;

    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;

    --code-bg: #2d3748;
    --code-text: #f7fafc;

    --search-bg: #ffffff;
    --search-border: #e2e8f0;
    --search-focus: var(--primary);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --border-color: #4a5568;
    --search-bg: #2d3748;
    --search-border: #4a5568;
    --code-bg: #0f1419;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Fix SVG sizing issues */
svg {
    max-width: 100%;
    height: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.logo {
    display: flex;
    align-items: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    flex-shrink: 0;
}

.logo svg {
    width: 32px !important;
    height: 32px !important;
    max-width: 32px !important;
    margin-right: 12px;
    flex-shrink: 0;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-left: auto;
}

.header-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}

.header-nav a:hover {
    color: var(--primary);
}

.header-nav a.active {
    color: var(--primary);
}

.version-selector {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.version-selector:hover {
    border-color: var(--primary);
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: var(--primary);
    color: white;
}

.theme-toggle svg {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
}

/* Layout */
.layout {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 0;
    z-index: 50;
}

/* Header Search */
.header-search {
    flex: 1;
    max-width: 500px;
    margin: 0 auto;
    position: relative;
}

.header-search .search-input {
    width: 100%;
    padding: 8px 12px;
    padding-left: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: all 0.2s;
}

.header-search .search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: var(--bg-primary);
}

.header-search .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
    color: var(--text-secondary);
    pointer-events: none;
}

.header-search .search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

.header-search .search-results.active {
    display: block;
    animation: slideDown 0.2s ease-out;
}

/* Remove old sidebar search styles */
.sidebar-search {
    display: none;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    padding-left: 36px;
    background: var(--search-bg);
    border: 1px solid var(--search-border);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.search-input::placeholder {
    color: var(--gray-600);
}

.search-input:focus {
    outline: none;
    border-color: var(--search-focus);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
    color: var(--text-secondary);
}

.sidebar-nav {
    padding: 0 20px;
}

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

.nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.nav-item {
    display: block;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item-expandable {
    position: relative;
    cursor: pointer;
}

.nav-item-expandable::after {
    content: '▸';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.2s;
}

.nav-item-expandable.expanded::after {
    transform: translateY(-50%) rotate(90deg);
}

.nav-subitems {
    margin-left: 20px;
    display: none;
}

.nav-subitems.expanded {
    display: block;
}

/* Content */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    max-width: calc(var(--content-max-width) + 80px);
    width: 100%;
    margin-right: auto;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: var(--gray-600);
}

/* Content Typography */
.doc-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    line-height: 1.2;
}

.doc-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.doc-content h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-top: 40px;
    margin-bottom: 16px;
    color: var(--text-primary);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.doc-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.doc-content h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.doc-content p {
    margin-bottom: 16px;
    line-height: 1.7;
}

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

.doc-content li {
    margin-bottom: 8px;
}

.doc-content a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

.doc-content a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Code Blocks */
.doc-content pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 16px;
    position: relative;
}

.doc-content code {
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
}

.doc-content :not(pre) > code {
    background: var(--gray-300);
    color: var(--danger);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875em;
}

.copy-code {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--gray-700);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.doc-content pre:hover .copy-code {
    opacity: 1;
}

.copy-code:hover {
    background: var(--gray-600);
}

/* Tables */
.doc-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.doc-content th {
    background: var(--bg-secondary);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.doc-content td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.doc-content tr:last-child td {
    border-bottom: none;
}

/* Alerts */
.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    display: flex;
    align-items: start;
    gap: 12px;
}

.alert-info {
    background: rgba(102, 126, 234, 0.1);
    border-left: 4px solid var(--primary);
}

.alert-success {
    background: rgba(72, 187, 120, 0.1);
    border-left: 4px solid var(--success);
}

.alert-warning {
    background: rgba(237, 137, 54, 0.1);
    border-left: 4px solid var(--warning);
}

.alert-danger {
    background: rgba(245, 101, 101, 0.1);
    border-left: 4px solid var(--danger);
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Table of Contents */
.toc {
    position: fixed;
    right: 20px;
    top: calc(var(--header-height) + 40px);
    width: 240px;
    max-height: calc(100vh - var(--header-height) - 80px);
    overflow-y: auto;
}

.toc-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.toc-item {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 4px 0;
    transition: color 0.2s;
}

.toc-item:hover {
    color: var(--primary);
}

.toc-item-h2 {
    padding-left: 0;
}

.toc-item-h3 {
    padding-left: 16px;
}

.toc-item-h4 {
    padding-left: 32px;
}

/* Search Results */
.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
}

.search-results.active {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-result-item:hover {
    background: var(--bg-secondary);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-result-icon {
    color: var(--text-secondary);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.search-result-snippet {
    font-size: 0.813rem;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-snippet mark,
.search-highlight {
    background: rgba(102, 126, 234, 0.2);
    color: var(--primary);
    font-weight: 500;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-path {
    font-size: 0.75rem;
    color: var(--gray-600);
    font-family: 'Fira Code', monospace;
    margin-top: 2px;
}

/* Mobile Menu */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-toggle svg {
    width: 24px !important;
    height: 24px !important;
    max-width: 24px !important;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary);
}

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

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

/* Responsive */
@media (max-width: 1400px) {
    .toc {
        display: none;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }

    .header-nav {
        display: none;
    }

    .header-search {
        max-width: calc(100% - 120px);
        margin: 0;
    }

    .header-search .search-input {
        font-size: 0.813rem;
        padding: 6px 10px;
        padding-left: 32px;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
        padding: 20px;
    }

    .container {
        flex-direction: column;
    }
}

/* Tabs */
.tabs {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    display: flex;
    gap: 4px;
}

.tab {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab:hover {
    color: var(--primary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Legacy Support */
.container {
    display: flex;
    height: calc(100vh - var(--header-height));
    margin-top: var(--header-height);
}

.folder {
    margin: 0.25rem 0;
}

.folder-name {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
    font-weight: 500;
}

.folder-name:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

.document {
    display: flex;
    align-items: center;
    padding: 0.375rem 0.5rem;
    margin-left: 1.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-size: 0.9375rem;
}

.document:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

#markdownContent {
    max-width: 65ch;
    margin: 0 auto;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.75;
}

#docContent {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Navigation Item Tags */
.nav-item-title {
    display: block;
    flex: 1;
}

.nav-item-tags {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 8px;
    opacity: 0.6;
    font-style: italic;
}

.nav-item:hover .nav-item-tags {
    opacity: 0.8;
}
