/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Theme Variables - Common */
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --sidebar-width: 280px;
}

/* Dark Theme Specific Colors */
:root, [data-theme="dark"] {
    --primary-color: #58a6ff;
    --secondary-color: #58a6ff;
    --accent-purple: #7c3aed;
    --accent-green: #43b581;
}

/* Light Theme Specific Colors */
[data-theme="light"] {
    --primary-color: #333333;
    --secondary-color: #555555;
    --accent-purple: #666666;
    --accent-green: #777777;
}

/* Dark Theme Variables */
:root, [data-theme="dark"] {
    --light-bg: #161b22;
    --dark-bg: #0d1117;
    --darker-bg: #0d1117;
    --text-color: #c9d1d9;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --code-bg: #161b22;
}

/* Light Theme Variables */
[data-theme="light"] {
    --light-bg: #ffffff;
    --dark-bg: #f5f5f5;
    --darker-bg: #fafafa;
    --text-color: #212121;
    --text-muted: #757575;
    --border-color: #e0e0e0;
    --code-bg: #f5f5f5;
}

body {
    /*font-family: 'Consolas', 'Monaco', 'Courier New', monospace, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto;*/
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--darker-bg);
}

/* Container Layout */
.container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Search Box */
.search-container {
    margin-bottom: 20px;
    position: relative;
}

.search-box {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--dark-bg);
    color: var(--text-color);
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--light-bg);
    box-shadow: 0 0 0 3px rgba(97, 218, 251, 0.1);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 12px;
    /*top: 50%;*/
    bottom: 5px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    border-radius: 3px;
    transition: all 0.3s ease;
    display: none;
}

.search-clear:hover {
    background: var(--border-color);
    color: var(--text-color);
}

.search-results {
    margin-top: 15px;
    padding: 10px;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: none;
}

.search-results h4 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 14px;
}

.search-result-item {
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.search-result-item a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 13px;
}

.search-result-item .search-result-path {
    color: var(--text-muted);
    font-size: 11px;
    margin-top: 2px;
}

.search-result-item .search-result-snippet {
    color: var(--text-muted);
    font-size: 12px;
    margin: 4px 0;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Theme Toggle */
.theme-toggle {
    /*position: absolute;*/
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--dark-bg);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle:hover {
    border-color: var(--primary-color);
    background: var(--light-bg);
}

.theme-toggle .theme-icon {
    font-size: 16px;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background: var(--darker-bg);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

/* Manual Tabs */
.manual-tabs {
    display: flex;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--dark-bg);
}

.manual-tab {
    flex: 1;
    padding: 12px 16px;
    background: var(--dark-bg);
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    font-size: 14px;
    font-weight: 500;
}

.manual-tab:first-child {
    border-right: 1px solid var(--border-color);
}

.manual-tab:hover {
    background: rgba(88, 166, 255, 0.1);
    color: var(--primary-color);
}

.manual-tab.active {
    background: var(--primary-color);
    color: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Manual Content */
.manual-content {
    display: none;
}

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

.sidebar::-webkit-scrollbar {
    width: 8px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--darker-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.sidebar h3 {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.sidebar h3 a {
    color: inherit;
    text-decoration: none;
}

.sidebar h4 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 1.1em;
}

.nav-section {
    margin-bottom: 25px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--dark-bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-section ul {
    list-style: none;
    padding-left: 0;
}

.nav-section li {
    margin-bottom: 4px;
}

.nav-section li a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 14px;
    border-left: 3px solid transparent;
}

.nav-section li a:hover {
    background: rgba(88, 166, 255, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    transform: translateX(5px);
}

.nav-section li.active a {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
    font-weight: 500;
    border: 1px solid rgba(124, 58, 237, 0.3);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

/* Expandable Navigation */
.nav-section-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.3s ease;
    margin-bottom: 8px;
    border: 1px solid transparent;
    background: var(--dark-bg);
}

.nav-section-header:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(88, 166, 255, 0.2);
}

.nav-section-header h4 {
    margin: 0;
    flex: 1;
    font-size: 16px;
    color: var(--primary-color);
}

.nav-section-toggle {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 10px;
    transition: transform 0.3s ease, color 0.3s ease;
}

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

.nav-section.collapsed .nav-section-toggle {
    transform: rotate(-90deg);
}

.nav-section-content {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 10px 15px 10px;
}

.nav-section.collapsed .nav-section-content {
    max-height: 0;
    padding: 0 10px 0 10px;
}

/* Chapter Groups */
.chapter-group {
    margin-bottom: 15px;
}

.chapter-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    margin-bottom: 3px;
    background: var(--darker-bg);
    border: 1px solid var(--border-color);
}

.chapter-header:hover {
    background: linear-gradient(90deg, rgba(114, 137, 218, 0.1) 0%, rgba(67, 181, 129, 0.1) 100%);
    border-color: var(--accent-purple);
}

.chapter-header h5 {
    margin: 0;
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
}

.chapter-toggle {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: 8px;
    transition: transform 0.3s ease, color 0.3s ease;
}

.chapter-header:hover .chapter-toggle {
    color: var(--accent-purple);
}

.chapter-group.collapsed .chapter-toggle {
    transform: rotate(-90deg);
}

.chapter-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 15px;
}

.chapter-group.collapsed .chapter-content {
    max-height: 0;
}

.sub-item {
    margin-bottom: 2px;
}

.sub-item a {
    padding: 5px 10px;
    font-size: 13px;
    color: var(--text-muted);
    border-left: 2px solid transparent;
}

.sub-item a:hover {
    background: linear-gradient(90deg, rgba(67, 181, 129, 0.1) 0%, rgba(76, 175, 80, 0.1) 100%);
    color: var(--accent-green);
    border-left-color: var(--accent-green);
}

.sub-item.active a {
    background: linear-gradient(90deg, rgba(67, 181, 129, 0.1) 0%, rgba(76, 175, 80, 0.1) 100%);
    color: var(--accent-green);
    border-left-color: var(--accent-green);
}

.sub-item.active a:hover {
    background: linear-gradient(90deg, rgba(67, 181, 129, 0.2) 0%, rgba(76, 175, 80, 0.2) 100%);
    color: var(--accent-green);
    border-left-color: var(--accent-green);
}

/* Main Content */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 40px;
    max-width: 900px;
    margin-right: auto;
    min-width: 0;
    overflow-x: auto;
    background-color: var(--darker-bg);
    position: relative;
}

.content-header {
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
}

/* Breadcrumb */
.breadcrumb {
    font-size: 14px;
    margin-bottom: 10px;
    color: var(--text-muted);
}

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

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb .current {
    color: var(--text-color);
    font-weight: 500;
}

/* Markdown Content Styles */
.markdown-body {
    line-height: 1.8;
}

.markdown-body h1 {
    font-size: 2.5em;
    margin-bottom: 30px;
    color: var(--primary-color);
}

.markdown-body h2 {
    font-size: 2em;
    margin-top: 40px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--primary-color);
}

.markdown-body h3 {
    font-size: 1.5em;
    margin-top: 30px;
    margin-bottom: 15px;
    color: var(--secondary-color);
}

.markdown-body h4 {
    font-size: 1.2em;
    margin-top: 25px;
    margin-bottom: 12px;
    color: var(--text-color);
}

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

.markdown-body ul, .markdown-body ol {
    margin-bottom: 16px;
    padding-left: 30px;
}

.markdown-body li {
    margin-bottom: 8px;
    color: var(--text-color);
}

.markdown-body a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.markdown-body a:hover {
    text-decoration: underline;
}

.markdown-body code {
    background-color: var(--code-bg);
    color: #79c0ff;
    padding: 3px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-color);
}

.markdown-body pre {
    background-color: var(--code-bg);
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.markdown-body pre code {
    background-color: transparent;
    padding: 0;
    font-size: 0.9em;
    line-height: 1.5;
    color: var(--text-color);
    border: none;
}

.markdown-body blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    margin: 20px 0;
    color: var(--text-muted);
    background: rgba(88, 166, 255, 0.05);
    padding: 12px 16px;
    border-radius: 0 4px 4px 0;
}

.markdown-body table {
    border-collapse: collapse;
    width: 100%;
    margin-bottom: 20px;
    background-color: var(--light-bg);
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.markdown-body table th,
.markdown-body table td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
    color: var(--text-color);
}

.markdown-body table th {
    background: var(--light-bg);
    font-weight: 600;
    color: var(--primary-color);
}

.markdown-body table tr:nth-child(even) {
    background-color: rgba(88, 166, 255, 0.05);
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin: 16px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Info boxes */
.info, .warning, .tip, .note {
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 6px;
    border-left: 4px solid;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.info {
    background: rgba(88, 166, 255, 0.1);
    border-color: #58a6ff;
    color: var(--text-color);
}

.warning {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.1) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: var(--warning-color);
    color: var(--text-color);
}

.tip {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1) 0%, rgba(67, 181, 129, 0.1) 100%);
    border-color: var(--success-color);
    color: var(--text-color);
}

.note {
    background: linear-gradient(135deg, rgba(114, 137, 218, 0.1) 0%, rgba(130, 177, 255, 0.1) 100%);
    border-color: var(--accent-purple);
    color: var(--text-color);
}

/* Footer */
.content-footer {
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.nav-links {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
}

.copyright {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

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

    .container {
        flex-direction: column;
    }
}

/* Table of Contents */
.table-of-contents {
    background: linear-gradient(135deg, var(--light-bg) 0%, var(--dark-bg) 100%);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 20px;
    margin: 20px 0 30px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.table-of-contents h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.table-of-contents ul {
    list-style: none;
    padding-left: 0;
}

.table-of-contents li {
    margin-bottom: 8px;
}

.table-of-contents a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: all 0.3s ease;
}

.table-of-contents a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Print Styles */
@media print {
    .sidebar {
        display: none;
    }

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

    .breadcrumb {
        display: none;
    }
}

/* Highlight search results */
.search-highlight {
    background: rgba(88, 166, 255, 0.3);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 600;
}

/* Hide non-matching navigation items during search */
.nav-item-hidden {
    display: none !important;
}

.nav-section-empty {
    opacity: 0.5;
}

/* Button Styles */
.btn, .button, button[type="submit"], a.button {
    display: inline-block;
    padding: 14px 28px;
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto;
    border: 1px solid rgba(124, 58, 237, 0.3);
    cursor: pointer;
}

.btn:hover, .button:hover, button[type="submit"]:hover, a.button:hover {
    background: linear-gradient(135deg, #7f23d6 0%, #7f23d6 100%);
    /*transform: translateY(-2px);*/
    /*box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);*/
}

/* Dark theme scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--darker-bg);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(145deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(145deg, var(--secondary-color) 0%, var(--primary-color) 100%);
}

/* Light theme adjustments */
[data-theme="light"] .sidebar {
    background: #fafafa;
    box-shadow: 1px 0 0 #e0e0e0;
    border-right: 1px solid #e0e0e0;
}

[data-theme="light"] .sidebar h3 {
    color: #212121;
    text-shadow: none;
}

[data-theme="light"] .sidebar h4 {
    color: #424242;
}

[data-theme="light"] .nav-section-header h4 {
    color: #212121;
    text-shadow: none;
}

[data-theme="light"] .nav-section-toggle,
[data-theme="light"] .chapter-toggle {
    color: #757575;
}

[data-theme="light"] .chapter-header {
    background: #fafafa;
    border-color: #e0e0e0;
}

[data-theme="light"] .chapter-header:hover {
    background: #f5f5f5;
    border-color: #bdbdbd;
}

[data-theme="light"] .sub-item a {
    color: #616161;
}

[data-theme="light"] .sub-item a:hover {
    background: #f5f5f5;
    color: #000000;
    border-left-color: #757575;
}

[data-theme="light"] .sub-item.active a {
    background: #f5f5f5;
    color: #000000;
    border-left-color: #757575;
}

[data-theme="light"] .sub-item.active a:hover {
    background: #eeeeee;
    color: #000000;
    border-left-color: #757575;
}

[data-theme="light"] .nav-section {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

[data-theme="light"] .nav-section li a:hover {
    background: #f5f5f5;
    color: #000000;
    border-left-color: #333333;
}

[data-theme="light"] .nav-section li.active a {
    background: #333333;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .nav-section-header:hover {
    background: #f5f5f5;
    border-color: #333333;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] h1, [data-theme="light"] h2, [data-theme="light"] h3 {
    text-shadow: none;
}

[data-theme="light"] .markdown-body h1 {
    color: #212121;
}

[data-theme="light"] .markdown-body h2 {
    color: #424242;
    border-bottom-color: #e0e0e0;
}

[data-theme="light"] .markdown-body h3 {
    color: #616161;
}

[data-theme="light"] .markdown-body a {
    color: #1976d2;
    text-decoration: none;
}

[data-theme="light"] .markdown-body a:hover {
    text-shadow: none;
    color: #0d47a1;
    text-decoration: underline;
}

[data-theme="light"] .markdown-body code {
    background: #f5f5f5;
    color: #d32f2f;
    border-color: #e0e0e0;
}

[data-theme="light"] .markdown-body pre {
    background: #f5f5f5;
    border-color: #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .markdown-body table th {
    background: #f5f5f5;
    color: #212121;
}

[data-theme="light"] .markdown-body table tr:nth-child(even) {
    background-color: #fafafa;
}

[data-theme="light"] .info {
    background: #e3f2fd;
    border-color: #1976d2;
}

[data-theme="light"] .warning {
    background: #fff3e0;
    border-color: #f57c00;
}

[data-theme="light"] .tip {
    background: #e8f5e9;
    border-color: #388e3c;
}

[data-theme="light"] .note {
    background: #f3e5f5;
    border-color: #7b1fa2;
}

[data-theme="light"] .search-highlight {
    background: rgba(255, 235, 59, 0.3);
    color: #000000;
    font-weight: 500;
}

[data-theme="light"] blockquote {
    background: #fafafa;
    border-left-color: #757575;
}

[data-theme="light"] .doc-section {
    background: var(--light-bg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .doc-section:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    border-color: #333333;
}

[data-theme="light"] .search-box {
    background: #ffffff;
    border-color: #e0e0e0;
    color: #212121;
}

[data-theme="light"] .search-box:focus {
    border-color: #424242;
    background: #ffffff;
    box-shadow: 0 0 0 2px rgba(66, 66, 66, 0.1);
}

[data-theme="light"] .search-results {
    background: #ffffff;
    border-color: #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .search-result-item:hover {
    background: #f5f5f5;
}

[data-theme="light"] .theme-toggle {
    background: #ffffff;
    border-color: #e0e0e0;
    color: #212121;
}

[data-theme="light"] .theme-toggle:hover {
    background: #f5f5f5;
    border-color: #424242;
}

[data-theme="light"] .content {
    background-color: #fafafa;
}

[data-theme="light"] .breadcrumb a {
    color: #1976d2;
}

[data-theme="light"] ::-webkit-scrollbar-track {
    background: #f5f5f5;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: #bdbdbd;
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: #9e9e9e;
}
