@media only screen and (min-width: 768px) {
    .wy-side-nav-search {
        /* Keep the search field visible when scrolling down */
        position: fixed;
    }
}

@media only screen and (min-width: 768px) {
    .wy-menu-vertical {
        /* Account for the fixed logo and search form */
        /* (prevents the navbar from being hidden behind it) */
        margin-top: 100px;
    }
}

/* Increase content width to utilize available browser space */
@media screen and (min-width: 1400px) {
    .wy-nav-content {
        max-width: 1200px;  /* Increase from default ~800px */
    }
}

@media screen and (min-width: 1600px) {
    .wy-nav-content {
        max-width: 1400px;  /* Utilize more space on very wide screens */
    }
}

/* Allow tables to scroll horizontally when they exceed content width */
.wy-table-responsive table td,
.wy-table-responsive table th {
    white-space: normal !important;
}

.wy-table-responsive {
    overflow: visible !important;
}

/* Optional: Make tables full-width when they have wide content */
.rst-content table.docutils {
    width: 100%;
    max-width: 100%;
}

/* Force monospace font for literal blocks (ASCII art, diagrams) */
.rst-content .literal-block,
.rst-content pre {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Lucida Console', monospace !important;
    font-size: 0.9em;
    line-height: 1.2;
    letter-spacing: 0;
    white-space: pre !important;
    overflow-x: auto;
    tab-size: 4;
}

/* Ensure code blocks also use proper monospace font */
.rst-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Lucida Console', monospace !important;
}

/* Specifically target Sphinx highlight blocks for ASCII diagrams */
.highlight,
.highlight-default,
.highlight pre,
div[class*="highlight-"] pre,
div[class*="highlight-"] code {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Lucida Console', monospace !important;
}

/* Fix vertical alignment in ASCII diagrams */
.rst-content .highlight pre span {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Lucida Console', monospace !important;
}

/* Additional rules for ASCII diagram alignment */
div.highlight,
div.highlight pre,
div.highlight-default,
div.highlight-default pre {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Lucida Console', monospace !important;
    font-size: 0.9em !important;
    line-height: 1.15 !important;
    white-space: pre !important;
    display: block !important;
}

/* Force equal character width for box-drawing characters */
.highlight-default pre span {
    font-family: 'Consolas', 'Monaco', 'Courier New', 'Lucida Console', monospace !important;
    display: inline !important;
    min-width: 0.6em !important;
}

/* Prevent line wrapping in ASCII art */
.rst-content .highlight pre,
.rst-content pre.literal-block {
    white-space: pre !important;
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    overflow-x: auto !important;
}

/* Vertically center align table cells */
.rst-content table.docutils td,
.rst-content table.docutils th,
.wy-table-responsive table td,
.wy-table-responsive table th {
    vertical-align: middle !important;
}

/* Mermaid diagram interactive features */
.mermaid {
    cursor: zoom-in;
    transition: transform 0.2s;
    background-color: transparent !important;
    border: none !important;
    position: relative; /* Useful if we ever need overlays */
}

/* Force clicks to target the .mermaid container instead of individual SVG elements */
.mermaid > svg {
    pointer-events: none;
}

.mermaid:hover {
    background-color: #f8f9fa !important;
}

/* Mermaid Modal / Lightbox */
.mermaid-modal {
    display: none; /* JS will toggle to flex */
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    cursor: default;
    align-items: center;
    justify-content: center;
}

.mermaid-modal-content {
    position: relative;
    width: 96%;
    height: 96%;
    background-color: white;
    border-radius: 4px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    overflow: hidden; 
    /* Remove flexbox, let SVG fill container */
    display: block;
}

.mermaid-modal-content svg {
    /* Make SVG fill the container, preserveAspectRatio will center it */
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    cursor: grab;
    display: block;
    pointer-events: auto !important; /* Ensure it overrides any pointer-events: none */
}

.mermaid-modal-content svg:active {
    cursor: grabbing;
}

.mermaid-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #ffffff;
    font-size: 50px;
    font-weight: 300;
    transition: 0.2s;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    z-index: 10001;
}

.mermaid-close:hover {
    color: #e74c3c;
    transform: scale(1.1);
}

/* Source Link Block Styles (DeepWiki style) */
.source-block {
    background-color: #f6f8fa;
    border-left: 4px solid #0366d6;
    padding: 12px 16px;
    margin: 1.5em 0;
    font-size: 0.9em;
    color: #24292e;
    border-radius: 0 6px 6px 0;
    line-height: 2.2; /* Increased line-height for better spacing between wrapped badges */
}

.source-block strong {
    color: #0366d6;
    font-weight: 600;
    margin-right: 8px;
    vertical-align: middle;
}

.source-block a.reference.external.source-link-split {
    text-decoration: none;
    margin: 2px 4px; /* Vertical and horizontal margins */
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease-in-out;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
    background-color: transparent;
    padding: 0;
}

.source-block a.reference.external.source-link-split:hover {
    border-color: #0366d6;
    box-shadow: 0 0 0 1px #0366d6;
}

.source-block a.reference.external.source-link-split .src-file {
    padding: 2px 8px;
    background-color: #f6f8fa;
    color: #24292e;
    border-right: 1px solid #d1d5da;
    transition: color 0.2s;
}

.source-block a.reference.external.source-link-split .src-lines {
    padding: 2px 8px;
    background-color: #e1e4e8;
    color: #24292e;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}

.source-block a.reference.external.source-link-split:hover .src-file {
    color: #0366d6;
}

.source-block a.reference.external.source-link-split:hover .src-lines {
    background-color: #0366d6;
    color: #ffffff;
}

.source-block a.reference.external.source-link-single {
    text-decoration: none;
    margin: 2px 4px;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    overflow: hidden;
    transition: all 0.2s ease-in-out;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85em;
    background-color: #f6f8fa;
    padding: 0;
}

.source-block a.reference.external.source-link-single .src-file-only {
    padding: 2px 8px;
    color: #24292e;
}

.source-block a.reference.external.source-link-single:hover {
    border-color: #0366d6;
    background-color: #e1ecf8;
}

.source-block a.reference.external.source-link-single:hover .src-file-only {
    color: #0366d6;
}
