/* Transform C++ namespace lists into autosummary-style tables */
.content section[id*="class"] ul:not(.simple),
.content section[id*="function"] ul:not(.simple),
.content section[id*="enum"] ul:not(.simple),
.content section[id*="typedef"] ul:not(.simple),
.content section[id*="variable"] ul:not(.simple),
.content section#classes ul:not(.simple),
.content section#functions ul:not(.simple),
.content section#enums ul:not(.simple),
.content section#typedefs ul:not(.simple),
.content section#variables ul:not(.simple) {
    display: block;
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--toc-border, #e1e4e5);
    background-color: #fff;
    margin-bottom: 20px;
}

/* Style list items to match Python autosummary table rows */
.content section[id*="class"] ul:not(.simple) li,
.content section[id*="function"] ul:not(.simple) li,
.content section[id*="enum"] ul:not(.simple) li,
.content section[id*="typedef"] ul:not(.simple) li,
.content section[id*="variable"] ul:not(.simple) li,
.content section#classes ul:not(.simple) li,
.content section#functions ul:not(.simple) li,
.content section#enums ul:not(.simple) li,
.content section#typedefs ul:not(.simple) li,
.content section#variables ul:not(.simple) li {
    display: block;
    border-bottom: 1px solid #f1f1f1;
    margin: 0;
    padding: 0;
}

.content section[id*="class"] ul:not(.simple) li:last-child,
.content section[id*="function"] ul:not(.simple) li:last-child,
.content section[id*="enum"] ul:not(.simple) li:last-child,
.content section[id*="typedef"] ul:not(.simple) li:last-child,
.content section[id*="variable"] ul:not(.simple) li:last-child,
.content section#classes ul:not(.simple) li:last-child,
.content section#functions ul:not(.simple) li:last-child,
.content section#enums ul:not(.simple) li:last-child,
.content section#typedefs ul:not(.simple) li:last-child,
.content section#variables ul:not(.simple) li:last-child {
    border-bottom: none;
}

.content section[id*="class"] ul:not(.simple) li:nth-child(even),
.content section[id*="function"] ul:not(.simple) li:nth-child(even),
.content section[id*="enum"] ul:not(.simple) li:nth-child(even),
.content section[id*="typedef"] ul:not(.simple) li:nth-child(even),
.content section[id*="variable"] ul:not(.simple) li:nth-child(even),
.content section#classes ul:not(.simple) li:nth-child(even),
.content section#functions ul:not(.simple) li:nth-child(even),
.content section#enums ul:not(.simple) li:nth-child(even),
.content section#typedefs ul:not(.simple) li:nth-child(even),
.content section#variables ul:not(.simple) li:nth-child(even) {
    background-color: #f9f9f9;
}

/* Style C++ links to match Python autosummary code elements exactly */
.content section[id*="class"] ul:not(.simple) li a,
.content section[id*="function"] ul:not(.simple) li a,
.content section[id*="enum"] ul:not(.simple) li a,
.content section[id*="typedef"] ul:not(.simple) li a,
.content section[id*="variable"] ul:not(.simple) li a,
.content section#classes ul:not(.simple) li a,
.content section#functions ul:not(.simple) li a,
.content section#enums ul:not(.simple) li a,
.content section#typedefs ul:not(.simple) li a,
.content section#variables ul:not(.simple) li a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    transition: all 0.2s ease;
    /* Reset all styling - we'll apply it to the nested elements */
    color: inherit;
    font-family: inherit;
    font-size: inherit;
}

.content section[id*="class"] ul:not(.simple) li a:hover,
.content section[id*="function"] ul:not(.simple) li a:hover,
.content section[id*="enum"] ul:not(.simple) li a:hover,
.content section[id*="typedef"] ul:not(.simple) li a:hover,
.content section[id*="variable"] ul:not(.simple) li a:hover,
.content section#classes ul:not(.simple) li a:hover,
.content section#functions ul:not(.simple) li a:hover,
.content section#enums ul:not(.simple) li a:hover,
.content section#typedefs ul:not(.simple) li a:hover,
.content section#variables ul:not(.simple) li a:hover {
    background-color: #e3f2fd;
    text-decoration: none;
}

/* Transform C++ reference links to match Python autosummary styling exactly */
.content a .std-ref {
    /* Match the exact Python autosummary styling */
    background-color: transparent !important;
    border: 1px solid var(--toc-border, #e1e4e5) !important;
    border-radius: 3px !important;
    color: #2980b9 !important;
    font-size: 14px !important;
    font-weight: normal !important;
    padding: 1px 6px !important;
    white-space: normal !important;
    text-decoration: none !important;
    display: inline !important;
}

.content a:hover .std-ref {
    background-color: #f1f8ff !important;
    border-color: #2980b9 !important;
    color: #1565c0 !important;
}

/* Alternative approach: Create code-style wrapper around C++ links */
.content a .std-ref::before {
    /* Add the same CSS classes that Python autosummary uses */
    content: "";
}

/* Make C++ links look exactly like Python autosummary code elements */
.content a .std-ref {
    /* Apply the exact same styles as Python's code elements */
    background: #f8f9fa !important;
    border: 1px solid #e9ecef !important;
    border-radius: 0.25rem !important;
    color: #2c3e50 !important;
    font-size: 87.5% !important;
    padding: 0.2em 0.4em !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

/* Override to match the exact Python autosummary appearance */
.content a .std-ref {
    /* Match Python's autosummary table code styling exactly */
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    color: #2980b9;
    font-size: 13px;
    font-weight: normal;
    padding: 2px 4px;
    text-decoration: underline;
    white-space: normal;
    display: inline;
}

.content a:hover .std-ref {
    background-color: #e3f2fd;
    border-color: #2980b9;
    color: #1565c0;
}

/* ------------------------------------------------------------------
 * Namespace toctree styling (cpp/api_cpp/namespace_*.html)
 * Make the nested li structure look like the Python autosummary tables.
 * ------------------------------------------------------------------ */
.content section[id^="namespace-"] section > h2 + ul.simple,
.content section[id^="namespace-"] > ul.simple {
    border: 1px solid var(--toc-border, #e1e4e5);
    border-radius: 4px;
    background-color: #fff;
    margin: 24px 0;
    padding: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.content section[id^="namespace-"] section > h2 + ul.simple,
.content section[id^="namespace-"] > ul.simple {
    list-style: none;
    margin: 0;
    padding: 0;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li,
.content section[id^="namespace-"] > ul.simple > li {
    margin: 0;
    border-bottom: 1px solid #f1f1f1;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li:last-child,
.content section[id^="namespace-"] > ul.simple > li:last-child {
    border-bottom: none;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li:nth-child(even),
.content section[id^="namespace-"] > ul.simple > li:nth-child(even) {
    background-color: #f9f9f9;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li:nth-child(odd),
.content section[id^="namespace-"] > ul.simple > li:nth-child(odd) {
    background-color: #fff;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li > ul > li,
.content section[id^="namespace-"] > ul.simple > li > ul > li {
    background-color: inherit;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li > p > a,
.content section[id^="namespace-"] > ul.simple > li > p > a {
    display: block;
    padding: 8px 14px;
    background-color: inherit;
    text-decoration: underline;
    color: inherit;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li > p > a:hover,
.content section[id^="namespace-"] > ul.simple > li > p > a:hover {
    background-color: #e3f2fd;
    color: #1565c0;
}

.content section[id^="namespace-"] section > h2 + ul.simple > li > p,
.content section[id^="namespace-"] > ul.simple > li > p {
    margin: 0;
}

.content section[id^="namespace-"] section > h2 + ul.simple ul a,
.content section[id^="namespace-"] > ul.simple ul a {
    padding-left: 32px;
}

.content section[id^="namespace-"] section > h2 + ul.simple ul ul a,
.content section[id^="namespace-"] > ul.simple ul ul a {
    padding-left: 50px;
}

.content section[id^="namespace-"] section > h2 + ul.simple ul ul ul a,
.content section[id^="namespace-"] > ul.simple ul ul ul a {
    padding-left: 68px;
}


.content section[id^="namespace-"] section > h2 + ul.simple code,
.content section[id^="namespace-"] > ul.simple code {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    color: #2c3e50;
    font-size: 13px;
    padding: 0.2em 0.4em;
    white-space: normal;
}

/* Clean up section headers with appropriate icons */
.content h2[id*="class"],
.content h2[id*="function"],
.content h2[id*="enum"],
.content h2[id*="typedef"],
.content h2[id*="variable"],
.content h2#classes,
.content h2#functions,
.content h2#enums,
.content h2#typedefs,
.content h2#variables {
    font-size: 1.2em;
    font-weight: bold;
    color: #404040;
    border-bottom: 1px solid var(--toc-border, #e1e4e5);
    margin-top: 30px;
    margin-bottom: 15px;
    padding-bottom: 6px;
}

/* Ensure C++ code elements match Python autosummary exactly */
.content a .std-ref,
.content code.xref {
    /* Apply Python autosummary exact styling */
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 3px;
    color: #2980b9;
    font-size: 13px;
    font-weight: normal;
    padding: 2px 4px;
    text-decoration: underline;
    white-space: normal;
    word-wrap: break-word;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
}

/* Ensure nested pre/span links (e.g., identifier names) show underline */
.content a span.pre {
    text-decoration: underline;
}

.content section ul:not(.simple) li a:hover .std-ref,
.content section ul:not(.simple) li a:hover code.xref {
    background-color: #e3f2fd;
    border-color: #2980b9;
    color: #1565c0;
}
