/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS Variables for theming */
:root {
    /* Light theme colors */
    --bg-primary: #f8f9fa;
    --bg-secondary: #fff;
    --bg-tertiary: #f8f9fa;
    --text-primary: #333;
    --text-secondary: #6c757d;
    --text-heading: #2c3e50;
    --border-color: #e9ecef;
    --accent-color: #3498db;
    --accent-hover: #2980b9;
    --link-color: #5ba3e0;
    --link-hover: #4a94d1;
    --code-bg: #f8f9fa;
    --code-text: #ff6600;
    --shadow: rgba(0,0,0,0.1);
    --nav-hover: #f8f9fa;
    --nav-submenu-bg: #f8f9fa;
    --nav-submenu-hover: #e9ecef;
}

/* Dark theme colors */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --text-primary: #e5e5e5;
    --text-secondary: #b3b3b3;
    --text-heading: #ffffff;
    --border-color: #404040;
    --accent-color: #4aa3df;
    --accent-hover: #5ab4f0;
    --link-color: #7bb8ea;
    --link-hover: #8cc3ed;
    --code-bg: #3a3a3a;
    --code-text: #ff6600;
    --shadow: rgba(0,0,0,0.3);
    --nav-hover: #3a3a3a;
    --nav-submenu-bg: #404040;
    --nav-submenu-hover: #4a4a4a;
}

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

/* Scrollbar styles for dark mode */
::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Focus styles for accessibility */
*:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.theme-toggle:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* General link styles */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--link-hover);
}

/* Content area links specifically */
.doc-body a,
.content a:not(.top-nav-link):not(.nav-link):not(.section-link):not(.nav-sublink):not(.page-list a):not(.page-card a):not(.taxonomy-item a) {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
    border-bottom: 1px solid transparent;
}

.doc-body a:hover,
.content a:not(.top-nav-link):not(.nav-link):not(.section-link):not(.nav-sublink):not(.page-list a):not(.page-card a):not(.taxonomy-item a):hover {
    color: var(--link-hover);
    border-bottom: 1px solid var(--link-hover);
}

/* Container */
.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: 0 2px 4px var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-content {
    width: 100%;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

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

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 3rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    outline: none;
}

.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.search-shortcut {
    position: absolute;
    right: 0.75rem;
    background-color: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    box-shadow: 0 10px 25px var(--shadow);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.search-results-content {
    padding: 0.5rem;
}

.search-result-item {
    padding: 0.75rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--border-color);
}

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

.search-result-item:hover,
.search-result-item.selected {
    background-color: var(--nav-hover);
}

.search-result-title {
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 0.25rem;
}

.search-result-section {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.search-no-results {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .search-container {
        max-width: none;
        flex: 1;
    }
    
    .search-shortcut {
        display: none;
    }
}

/* Right side group containing navigation and theme toggle */
.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* Top Navigation */
.top-nav {
    display: flex;
}

.top-nav-list {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    margin: 0;
    padding: 0;
}

.top-nav-item {
    position: relative;
}

.top-nav-link {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.top-nav-link:hover {
    background-color: var(--nav-hover);
    color: var(--accent-color);
}

.top-nav-link.active {
    background-color: var(--accent-color);
    color: white;
}

.external-icon {
    font-size: 0.8em;
    opacity: 0.7;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    flex-shrink: 0;
}

.site-title a {
    color: var(--text-heading);
    text-decoration: none;
    transition: color 0.3s ease;
}

.site-title a:hover {
    color: var(--accent-color);
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    background-color: var(--bg-secondary);
}

.theme-toggle:hover {
    border-color: var(--accent-color);
    transform: scale(1.1);
}

.theme-toggle-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-toggle-icon {
    transform: rotate(20deg);
}

/* Main wrapper */
.main-wrapper {
    display: flex;
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 100px);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    flex-shrink: 0;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 2rem 0;
    min-height: 100vh;
    overflow-y: auto;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-content {
    padding: 0 2rem;
}

.sidebar h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-top: 2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-color);
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background-color: var(--nav-hover);
    color: var(--accent-color);
    transform: translateX(4px);
}

.nav-link.active {
    background-color: var(--accent-color);
    color: #fff;
}

/* Hierarchical navigation styles */
.nav-section {
    margin-bottom: 0.25rem;
}

.nav-section-header {
    display: flex;
    align-items: center;
    position: relative;
}

.section-link {
    flex: 1;
    margin-right: 0;
}

.nav-toggle {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-left: 0.5rem;
}

.nav-toggle:hover {
    background-color: var(--nav-hover);
    color: var(--accent-color);
}

.nav-toggle-icon {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
    line-height: 1;
}

.nav-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background-color: var(--nav-submenu-bg);
    border-radius: 6px;
    margin-top: 0.25rem;
}

.nav-submenu.expanded {
    max-height: 500px;
    padding: 0.5rem 0;
}

.nav-subitem {
    margin: 0;
}

.nav-sublink {
    padding: 0.5rem 1rem 0.5rem 2rem;
    font-size: 0.9rem;
    margin: 0;
    border-radius: 0;
    position: relative;
}

.nav-sublink:before {
    content: "•";
    position: absolute;
    left: 1.2rem;
    color: var(--text-secondary);
    font-weight: bold;
}

.nav-sublink:hover {
    background-color: var(--nav-submenu-hover);
    transform: translateX(2px);
}

.nav-sublink.active {
    background-color: var(--accent-color);
    color: #fff;
}

.nav-sublink.active:before {
    color: #fff;
}

.nav-section.expanded > .nav-section-header .nav-toggle-icon {
    transform: rotate(90deg);
}

/* Content area */
.content {
    flex: 1;
    min-width: 0;
    padding: 2rem;
    background-color: var(--bg-secondary);
    margin-left: 0;
    overflow-x: auto;
    transition: background-color 0.3s ease;
}

/* Full width content when no sidebar */
.content-full-width {
    max-width: none;
    width: 100%;
}

.content-wrapper {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
}

/* Homepage styles */
.homepage {
    padding: 2rem 0;
}

.welcome-section h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.welcome-section p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* Documentation page styles */
.doc-page {
    padding: 1rem 0;
}

.doc-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.doc-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.doc-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
}

.doc-body {
    font-size: 1rem;
    line-height: 1.7;
}

/* Add better spacing between major sections */
.doc-body h2 + * {
    margin-top: 0;
}

.doc-body h3 + * {
    margin-top: 0;
}

/* Add breathing room around code blocks */
.doc-body pre {
    margin: 1.5rem 0;
}

/* Improve spacing for blockquotes */
.doc-body blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent-color);
    background-color: var(--bg-tertiary);
}

/* Style horizontal rules for section breaks */
.doc-body hr {
    margin: 3rem 0;
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

.doc-body h1,
.doc-body h2,
.doc-body h3,
.doc-body h4,
.doc-body h5,
.doc-body h6 {
    color: var(--text-heading);
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* First heading shouldn't have top margin */
.doc-body h1:first-child,
.doc-body h2:first-child,
.doc-body h3:first-child {
    margin-top: 0;
}

.doc-body h1 {
    font-size: 1.75rem;
}

.doc-body h2 {
    font-size: 1.5rem;
}

.doc-body h3 {
    font-size: 1.25rem;
}

.doc-body p {
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.doc-body ul,
.doc-body ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

li code {
    color: orange;
}

.doc-body li {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

/* Better spacing for nested lists */
.doc-body li ul,
.doc-body li ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.doc-body code {
    background-color: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.doc-body pre {
    background-color: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 1rem;
    border-left: 4px solid var(--accent-color);
    width: 100%;
    box-sizing: border-box;
}

.doc-body pre code {
    background: none;
    padding: 0;
}

/* Table styles */
.doc-body table , .section-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    box-shadow: 0 2px 8px var(--shadow);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
}

.doc-body .table-wrapper , .section-body .table-wrapper {
    overflow-x: auto;
    margin: 1.5rem 0;
}

.doc-body .table-wrapper table , .section-body .table-wrapper table {
    margin: 0;
    min-width: 600px;
}

.doc-body thead , .section-body thead {
    background-color: var(--accent-color);
}

.doc-body thead th , .section-body thead th {
    color: white;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

.doc-body tbody tr , .section-body tbody tr {
    transition: background-color 0.2s ease;
}

.doc-body tbody tr:nth-child(even) , .section-body tbody tr:nth-child(even) {
    background-color: var(--bg-tertiary);
}

.doc-body tbody tr:hover , .section-body tbody tr:hover {
    background-color: var(--nav-hover);
}

.doc-body td , .section-body td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.doc-body tbody tr:last-child td , .section-body tbody tr:last-child td {
    border-bottom: none;
}

/* Code in tables */
.doc-body table code, .section-body table code {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Responsive design */
@media (max-width: 768px) {
    .main-wrapper {
        flex-direction: column;
        overflow: visible;
    }
    
    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem 0;
        flex-shrink: 0;
    }
    
    .content {
        padding: 1rem;
        overflow-x: auto;
    }
    
    .welcome-section h1 {
        font-size: 2rem;
    }
    
    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .site-title {
        text-align: center;
        order: 1;
    }
    
    .search-container {
        order: 2;
        max-width: none;
    }
    
    .header-right {
        justify-content: center;
        gap: 1rem;
        order: 3;
    }
    
    .top-nav-list {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }
    
    .top-nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .theme-toggle {
        width: 40px;
        height: 40px;
    }
    
    .theme-toggle-icon {
        font-size: 1.1rem;
    }
}

/* Section page styles */
.section-page,
.list-page {
    padding: 1rem 0;
}

.section-header,
.list-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.section-description,
.list-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 0.5rem;
}

/* Apply the same content styling to section pages */
.section-body {
    font-size: 1rem;
    line-height: 1.7;
}

/* Section content headings */
.section-body h1,
.section-body h2,
.section-body h3,
.section-body h4,
.section-body h5,
.section-body h6 {
    color: var(--text-heading);
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

/* First heading shouldn't have top margin */
.section-body h1:first-child,
.section-body h2:first-child,
.section-body h3:first-child {
    margin-top: 0;
}

.section-body h1 {
    font-size: 1.75rem;
}

.section-body h2 {
    font-size: 1.5rem;
}

.section-body h3 {
    font-size: 1.25rem;
}

.section-body p {
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.section-body ul,
.section-body ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

.section-body li {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

/* Better spacing for nested lists */
.section-body li ul,
.section-body li ol {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

/* Add better spacing between major sections */
.section-body h2 + * {
    margin-top: 0;
}

.section-body h3 + * {
    margin-top: 0;
}

/* Add breathing room around code blocks */
.section-body pre {
    margin: 1.5rem 0;
}

/* Improve spacing for blockquotes */
.section-body blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent-color);
    background-color: var(--bg-tertiary);
}

/* Style horizontal rules for section breaks */
.section-body hr {
    margin: 3rem 0;
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
}

.page-list {
    list-style: none;
    margin-top: 1.5rem;
}

.page-list li {
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    border-left: 4px solid var(--accent-color);
    transition: background-color 0.3s ease;
}

.page-list a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
}

.page-list a:hover {
    color: var(--accent-hover);
}

.page-list p {
    margin-top: 0.5rem;
    margin-bottom: 0;
    color: var(--text-secondary);
}

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.page-card {
    background-color: var(--bg-tertiary);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}

.page-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.page-card h3 {
    margin-bottom: 0.5rem;
}

.page-card a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.page-card a:hover {
    color: var(--accent-hover);
}

.page-card p {
    margin-bottom: 0;
    color: var(--text-secondary);
}

/* Taxonomy page styles */
.taxonomy-page {
    padding: 1rem 0;
}

.taxonomy-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.taxonomy-item {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.taxonomy-item h3 {
    margin-bottom: 0.5rem;
}

.taxonomy-item a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.taxonomy-item a:hover {
    color: var(--accent-hover);
}

/* Alert Shortcode Styles */
.alert {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border-left: 4px solid;
    position: relative;
}

.alert-content {
    margin: 0;
}

.alert-content > *:first-child {
    margin-top: 0;
}

.alert-content > *:last-child {
    margin-bottom: 0;
}

/* Info Alert - Blue */
.alert-info {
    background-color: #e8f4f8;
    border-left-color: #2196f3;
    color: #0d47a1;
}

[data-theme="dark"] .alert-info {
    background-color: #1a2b3a;
    color: #90caf9;
}

/* Success Alert - Green */
.alert-success {
    background-color: #e8f5e8;
    border-left-color: #4caf50;
    color: #1b5e20;
}

[data-theme="dark"] .alert-success {
    background-color: #1a3a1a;
    color: #a5d6a7;
}

/* Warning Alert - Yellow/Orange */
.alert-warning {
    background-color: #fff8e1;
    border-left-color: #ff9800;
    color: #e65100;
}

[data-theme="dark"] .alert-warning {
    background-color: #3a2f1a;
    color: #ffcc80;
}

/* Danger Alert - Red */
.alert-danger {
    background-color: #fce8e8;
    border-left-color: #f44336;
    color: #b71c1c;
}

[data-theme="dark"] .alert-danger {
    background-color: #3a1a1a;
    color: #ef9a9a;
}

/* Mermaid diagram styles */
.mermaid {
    margin: 2.5rem 0;
    text-align: center;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
}

/* Ensure Mermaid diagrams are responsive */
.mermaid svg {
    max-width: 100%;
    height: auto;
}

/* Dark theme adjustments for Mermaid */
[data-theme="dark"] .mermaid {
    background-color: var(--bg-tertiary);
}

/* Fix text readability in Mermaid diagrams */
.mermaid .node rect,
.mermaid .node circle,
.mermaid .node ellipse,
.mermaid .node polygon {
    stroke: var(--border-color) !important;
}

.mermaid .edgeLabel {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Ensure proper spacing around diagrams */
.content .mermaid {
    margin: 2.5rem auto;
    max-width: 100%;
}