/* Custom styles for CCAT Data Center Documentation */

/* Header spacing adjustments */
.rst-content .section {
    margin-top: 20px;
}

.rst-content h1 {
    margin-top: 10px;
    margin-bottom: 15px;
}

/* Move View page source link higher */
.rst-content .headerlink {
    position: absolute;
    right: 0;
    top: 0;
}

/* Compact header layout */
.rst-content > h1:first-child {
    margin-top: 0;
    padding-top: 0;
}

/* Up link to main documentation - Subtle Version */
.up-link-container {
    background-color: transparent;
    border: none;
    padding: 4px 0;
    margin-bottom: 8px;
    margin-top: -5px;
    border-radius: 0;
}

.up-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: #6c757d;
    font-weight: 400;
    font-size: 12px;
    transition: color 0.2s ease;
    opacity: 0.8;
}

.up-link:hover {
    color: #495057;
    text-decoration: none;
    opacity: 1;
}

.up-link::before {
    content: "↑";
    margin-right: 4px;
    font-size: 12px;
    font-weight: normal;
}

/* Dark mode for up link */
[data-theme="dark"] .up-link-container,
.rst-content .up-link-container {
    background-color: transparent;
    border: none;
}

[data-theme="dark"] .up-link,
.rst-content .up-link {
    color: #adb5bd;
}

[data-theme="dark"] .up-link:hover,
.rst-content .up-link:hover {
    color: #f8f9fa;
}

/* Compact layout for better spacing */
.rst-content {
    line-height: 1.5;
}

.rst-content .section {
    margin-top: 15px;
}

.rst-content h1 {
    margin-top: 5px;
    margin-bottom: 10px;
}

.rst-content h2 {
    margin-top: 20px;
    margin-bottom: 10px;
}

/* Reduce top margin for first element after title */
.rst-content > *:first-child {
    margin-top: 0;
}

/* Compact breadcrumbs */
.breadcrumbs {
    margin-bottom: 5px;
}

/* Top-level navigation entries styling */
/* Make top-level component entries bold and more distinct */
.bd-sidebar .nav-link {
    font-weight: 500;
}

/* Specific styling for top-level entries in the navigation */
.bd-sidebar .nav-link[href*="/ops-db/docs/index"],
.bd-sidebar .nav-link[href*="/data-transfer/docs/index"],
.bd-sidebar .nav-link[href*="/ops-db-api/docs/index"],
.bd-sidebar .nav-link[href*="/ops-db-ui/docs/index"],
.bd-sidebar .nav-link[href*="/system-integration/docs/index"],
.bd-sidebar .nav-link[href*="/data-center/docs/index"] {
    font-weight: 700 !important;
    font-size: 1.05em;
    color: var(--pst-color-text-base, #000) !important;
    border-left: 3px solid transparent;
    padding-left: 8px;
    margin-left: -8px;
}

/* Hover effect for top-level entries */
.bd-sidebar .nav-link[href*="/ops-db/docs/index"]:hover,
.bd-sidebar .nav-link[href*="/data-transfer/docs/index"]:hover,
.bd-sidebar .nav-link[href*="/ops-db-api/docs/index"]:hover,
.bd-sidebar .nav-link[href*="/ops-db-ui/docs/index"]:hover,
.bd-sidebar .nav-link[href*="/system-integration/docs/index"]:hover,
.bd-sidebar .nav-link[href*="/data-center/docs/index"]:hover {
    border-left-color: var(--pst-color-primary, #007bff);
    background-color: var(--pst-color-background, #f8f9fa);
}

/* Active state for top-level entries */
.bd-sidebar .nav-link[href*="/ops-db/docs/index"].active,
.bd-sidebar .nav-link[href*="/data-transfer/docs/index"].active,
.bd-sidebar .nav-link[href*="/ops-db-api/docs/index"].active,
.bd-sidebar .nav-link[href*="/ops-db-ui/docs/index"].active,
.bd-sidebar .nav-link[href*="/system-integration/docs/index"].active,
.bd-sidebar .nav-link[href*="/data-center/docs/index"].active {
    border-left-color: var(--pst-color-primary, #007bff);
    background-color: var(--pst-color-primary, #007bff);
    color: white !important;
}

/* Dark mode adjustments */
[data-theme="dark"] .bd-sidebar .nav-link[href*="/ops-db/docs/index"],
[data-theme="dark"] .bd-sidebar .nav-link[href*="/data-transfer/docs/index"],
[data-theme="dark"] .bd-sidebar .nav-link[href*="/ops-db-api/docs/index"],
[data-theme="dark"] .bd-sidebar .nav-link[href*="/ops-db-ui/docs/index"],
[data-theme="dark"] .bd-sidebar .nav-link[href*="/system-integration/docs/index"],
[data-theme="dark"] .bd-sidebar .nav-link[href*="/data-center/docs/index"] {
    color: var(--pst-color-text-base, #fff) !important;
}

[data-theme="dark"] .bd-sidebar .nav-link[href*="/ops-db/docs/index"]:hover,
[data-theme="dark"] .bd-sidebar .nav-link[href*="/data-transfer/docs/index"]:hover,
[data-theme="dark"] .bd-sidebar .nav-link[href*="/ops-db-api/docs/index"]:hover,
[data-theme="dark"] .bd-sidebar .nav-link[href*="/ops-db-ui/docs/index"]:hover,
[data-theme="dark"] .bd-sidebar .nav-link[href*="/system-integration/docs/index"]:hover,
[data-theme="dark"] .bd-sidebar .nav-link[href*="/data-center/docs/index"]:hover {
    background-color: var(--pst-color-background, #2d3748);
}

/* Mermaid Zoom and Pan Controls */
.mermaid-zoom-wrapper {
    position: relative;
    display: block;
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: visible;
    background: #fafafa;
    width: 100%;
}

[data-theme="dark"] .mermaid-zoom-wrapper {
    border-color: #444;
    background: #1e1e1e;
}

.mermaid-viewport {
    position: relative;
    overflow: hidden;
    min-height: 200px;
    width: 100%;
}

.mermaid-viewport .mermaid {
    transform-origin: 0 0;
    transition: none;
    display: block;
    margin: 0;
    width: 100%;
}

.mermaid-controls {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 10;
}

.mermaid-controls button {
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: #333;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mermaid-controls button:hover {
    background: #f0f0f0;
    border-color: #999;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.mermaid-controls button:active {
    transform: scale(0.95);
}

[data-theme="dark"] .mermaid-controls button {
    background: #333;
    color: #fff;
    border-color: #555;
}

[data-theme="dark"] .mermaid-controls button:hover {
    background: #444;
    border-color: #777;
}

.mermaid-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    color: #333;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
}

.mermaid-expand:hover {
    background: #f0f0f0;
    border-color: #999;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transform: scale(1.05);
}

[data-theme="dark"] .mermaid-expand {
    background: #333;
    color: #fff;
    border-color: #555;
}

[data-theme="dark"] .mermaid-expand:hover {
    background: #444;
    border-color: #777;
}

/* Mermaid Modal */
.mermaid-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.mermaid-modal.active {
    background: rgba(0, 0, 0, 0.85);
}

.mermaid-modal-content {
    position: relative;
    width: 95%;
    height: 95%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

[data-theme="dark"] .mermaid-modal-content {
    background: #1e1e1e;
}

.mermaid-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0,0,0,0.1);
    color: #333;
    font-size: 32px;
    line-height: 32px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
    z-index: 11;
}

.mermaid-modal-close:hover {
    background: rgba(0,0,0,0.2);
    transform: scale(1.1);
}

[data-theme="dark"] .mermaid-modal-close {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

[data-theme="dark"] .mermaid-modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.mermaid-modal-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px;
}

.mermaid-modal-viewport .mermaid {
    transform-origin: center center;
    transition: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.mermaid-modal .mermaid-controls {
    top: 70px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mermaid-modal-content {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .mermaid-controls {
        opacity: 0.7;
    }
    
    .mermaid-controls:hover {
        opacity: 1;
    }
}

