:root {
    --primary: #00ffb3;
    --secondary: #141414;
    --text: #e0e0e0;
    --background: #0a0a0a;
    --grid: rgba(255, 255, 255, 0.15);
    --error: #ff4d4d;
    --success: #00cc90;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Work Sans', sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

.grid-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(var(--grid) 1px, transparent 1px),
                      linear-gradient(90deg, var(--grid) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.1;
    pointer-events: none;
}

/* Header */
header {
    background-color: rgba(10, 10, 10, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.8rem 1.5rem;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: inline-flex;
    align-items: center;
    width: auto;
    max-width: min(190px, 30vw);
    text-decoration: none;
    line-height: 0;
    overflow: hidden;
}

.logo-mark {
    display: block;
    width: auto;
    height: 56px;
    max-width: 100%;
    object-fit: contain;
}

nav ul {
    display: flex;
    gap: 2rem;
    list-style: none;
}

nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.3s;
}

nav a:hover, nav a.active {
    color: var(--primary);
}

/* Main Content */
main {
    flex: 1;
    padding: 5rem 2rem 2rem;
    position: relative;
}

.container {
    display: flex;
    gap: 2rem;
    max-width: 1800px;
    margin: 0 auto;
    position: relative;
}

/* Metadata Sidebar */
.metadata-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: rgba(20, 20, 20, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1rem;
    height: calc(100vh - 8rem);
    position: sticky;
    top: 5rem;
    overflow-y: auto;
    scrollbar-gutter: stable;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
}

.refresh-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.loading-indicator {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.5s linear infinite;
    transition: opacity 0.2s ease-in-out;
}

.loading-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.3s;
    padding: 0.25rem;
    border-radius: 4px;
}

.refresh-btn:hover {
    color: var(--primary);
}

.refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.node-panel {
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.node-header {
    padding: 0.75rem;
    background: rgba(0, 255, 179, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
}

.node-status {
    color: var(--primary);
}

.node-status.online {
    color: #00ffb3;
}

.node-status.offline {
    color: #ff4757;
}

.node-files {
    padding: 0.5rem;
    overflow: hidden;
}

.file-item {
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.file-header {
    padding: 0.5rem;
    cursor: pointer;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 0.5rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    max-width: 100%;
}

.file-name {
    display: block;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
    padding-right: 0.35rem;
}

.file-toggle {
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    opacity: 0.9;
    color: var(--primary);
    border: 1px solid rgba(0, 255, 179, 0.35);
    border-radius: 999px;
    line-height: 1.1;
}

.file-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.file-columns {
    padding: 0.5rem 0 0.5rem 1rem;
}

.columns-list {
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
}

.column-item {
    padding: 0.3rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Query Section */
.query-section {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    transition: margin-right 0.25s ease;
}

.query-section.with-playbook {
    margin-right: min(460px, 92vw);
}

.query-editor {
    background: rgba(20, 20, 20, 0.5);
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1.5rem;
}

.query-editor h2 {
    font-size: 1.2rem;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    margin-bottom: 1.5rem;
}

.editor-container {
    margin-bottom: 1rem;
    border-radius: 4px;
    overflow: hidden;
}

/* CodeMirror Customization */
.CodeMirror {
    height: 300px !important;
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.3) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.CodeMirror-gutters {
    background: rgba(0, 0, 0, 0.2) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.CodeMirror-linenumber {
    color: rgba(255, 255, 255, 0.3) !important;
}

.cm-s-monokai .CodeMirror-cursor {
    border-left: 1px solid var(--primary) !important;
}

.cm-s-monokai .CodeMirror-selected {
    background: rgba(0, 255, 179, 0.2) !important;
}

.editor-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.shortcut-info {
    color: rgba(255, 255, 255, 0.5);
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
}

.execute-btn {
    background: var(--primary);
    color: var(--secondary);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s, transform 0.3s;
}

.execute-btn:hover {
    background: var(--success);
    transform: translateY(-2px);
}

/* Style the SQL syntax highlighting */
.cm-s-monokai .cm-keyword {
    color: #66d9ef !important;
}

.cm-s-monokai .cm-operator {
    color: #f92672 !important;
}

.cm-s-monokai .cm-number {
    color: #ae81ff !important;
}

.cm-s-monokai .cm-string {
    color: #e6db74 !important;
}

.cm-s-monokai .cm-comment {
    color: #75715e !important;
}

/* Style the autocomplete dropdown */
.CodeMirror-hints {
    position: absolute;
    z-index: 10;
    overflow: hidden;
    list-style: none;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--secondary);
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    max-height: 20em;
    overflow-y: auto;
}

.CodeMirror-hint {
    margin: 0;
    padding: 0.5rem 1rem;
    white-space: pre;
    color: var(--text);
    cursor: pointer;
}

li.CodeMirror-hint-active {
    background: rgba(0, 255, 179, 0.2);
    color: var(--primary);
}

/* Error message styling */
.error {
    background: rgba(255, 77, 77, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: 1rem;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    margin: 1rem 0;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
}

.loading::after {
    content: '';
    width: 1rem;
    height: 1rem;
    margin-left: 0.5rem;
    border: 2px solid var(--primary);
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 1s linear infinite;
}

/* Simple progress info */
.progress-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    gap: 0.5rem;
}

.progress-status {
    font-size: 1.1rem;
    font-weight: 600;
}

.progress-details {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Results Section */
.results-section {
    background: rgba(20, 20, 20, 0.5);
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 1.5rem;
}

.results-section h2 {
    font-size: 1.2rem;
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    margin-bottom: 1.5rem;
}

/* Results header with export button */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.results-title-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.results-header h3 {
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 1.1rem;
    margin: 0;
}

.pagination-info {
    color: rgba(255, 255, 255, 0.6);
    font-family: 'Space Mono', monospace;
    font-size: 0.8rem;
}

.export-csv-btn {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.export-csv-btn:hover {
    background: rgba(0, 255, 179, 0.08);
}

.export-csv-btn:active {
    transform: translateY(0);
}

/* Pagination controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(20, 20, 20, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.pagination-btn {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.35rem 0.6rem;
    border-radius: 4px;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: auto;
    line-height: 1;
}

.pagination-btn:hover:not(.disabled) {
    background: rgba(0, 255, 179, 0.08);
    transform: none;
}

.pagination-btn.disabled {
    opacity: 0.4;
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.3);
}

.page-info {
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 120px;
    text-align: center;
}

.page-info-inline {
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
    padding: 0 0.4rem;
}

.results-container {
    display: flex;
    flex-direction: column;
    min-height: 260px;
    height: min(52vh, 560px);
    max-width: 100%;
    overflow: hidden;
}

.results-table-scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
    width: 100%;
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: rgba(255, 255, 255, 0.3);
}

.placeholder-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.results-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.results-table th {
    background: rgba(0, 255, 179, 0.1);
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-weight: normal;
    text-align: left;
    padding: 0.75rem;
}

.results-table td {
    padding: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
}

.results-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Footer */
footer {
    background: var(--secondary);
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    max-width: 1800px;
    margin: 0 auto;
    column-gap: 1rem;
}

.footer-logo {
    display: inline-flex;
    align-items: center;
    width: auto;
    max-width: min(190px, 30vw);
    text-decoration: none;
    line-height: 0;
    overflow: hidden;
}

.footer-logo-mark {
    display: block;
    width: auto;
    height: 46px;
    max-width: 100%;
    object-fit: contain;
}

.footer-note {
    font-size: 0.9rem;
    opacity: 0.7;
    justify-self: end;
    text-align: right;
}

.footer-contact-center {
    justify-self: center;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.85;
}

.footer-contact-center a {
    color: var(--primary);
    text-decoration: none;
}

.footer-contact-center a:hover {
    text-decoration: underline;
}

/* Utilities */
.hidden {
    display: none;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

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

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

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        flex-direction: column;
    }

    .metadata-sidebar {
        width: 100%;
        height: auto;
        position: static;
    }

    .nodes-container {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        display: flex;
        text-align: center;
        gap: 1rem;
    }

    .footer-note {
        justify-self: center;
        text-align: center;
    }
} 

/* Query playbook drawer (SQL page only) */
.playbook-open-btn {
    position: fixed;
    right: 1.25rem;
    top: 7.2rem;
    transform: none;
    z-index: 120;
    background: rgba(8, 12, 18, 0.92);
    color: var(--primary);
    border: 1px solid rgba(0, 255, 179, 0.5);
    border-radius: 999px;
    padding: 0.7rem 1rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    overflow: hidden;
}

.playbook-open-btn::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from 0deg, transparent 0 60%, rgba(0, 255, 179, 0.85) 65%, transparent 70% 100%);
    animation: playbookPulse 2.2s linear infinite;
    z-index: -1;
}

.playbook-open-btn::after {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: rgba(8, 12, 18, 0.95);
    z-index: -1;
}

@keyframes playbookPulse {
    to { transform: rotate(360deg); }
}

.playbook-drawer {
    position: fixed;
    top: 5.1rem;
    right: 0;
    width: min(460px, 92vw);
    height: calc(100vh - 6.5rem);
    background: rgba(10, 10, 10, 0.96);
    border-left: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.45);
    z-index: 125;
    transform: translateX(102%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
}

.playbook-drawer.open {
    transform: translateX(0);
}

.playbook-aware {
    transition: padding-right 0.25s ease;
}

.playbook-aware.with-playbook {
    padding-right: 0;
}

.playbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.playbook-header h3 {
    color: var(--primary);
    font-family: 'Space Mono', monospace;
    font-size: 1rem;
}

.playbook-close-btn {
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: var(--text);
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 4px;
    cursor: pointer;
}

.playbook-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.8rem 1rem 0.4rem;
}

.playbook-tab {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    padding: 0.45rem 0.6rem;
    border-radius: 5px;
    font-size: 0.8rem;
    cursor: pointer;
}

.playbook-tab.active {
    border-color: rgba(0, 255, 179, 0.45);
    color: var(--primary);
    background: rgba(0, 255, 179, 0.08);
}

.playbook-tab-content {
    display: none;
    padding: 0.3rem 1rem 1rem;
    overflow-y: auto;
    flex: 1;
}

.playbook-tab-content.active {
    display: block;
}

.playbook-tab-content h4 {
    color: var(--primary);
    margin: 0.6rem 0 0.35rem;
    font-size: 0.95rem;
}

.playbook-tab-content p,
.playbook-tab-content li {
    font-size: 0.84rem;
    opacity: 0.9;
}

.playbook-tab-content p {
    margin: 0 0 0.65rem;
    line-height: 1.45;
}

.playbook-tab-content ul {
    margin: 0.35rem 0 0.8rem;
    padding-left: 1.15rem;
}

.playbook-tab-content li {
    margin-bottom: 0.45rem;
    line-height: 1.4;
}

.playbook-query-list {
    display: grid;
    gap: 0.65rem;
}

.playbook-query-item {
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    padding: 0.55rem 0.65rem;
}

.playbook-query-title {
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 600;
}

.playbook-query-note,
.playbook-query-output {
    font-size: 0.77rem;
    opacity: 0.88;
    margin-top: 0.2rem;
}

.playbook-run-query-btn {
    margin-top: 0.45rem;
    border: 1px solid rgba(0, 255, 179, 0.35);
    background: transparent;
    color: var(--primary);
    border-radius: 4px;
    padding: 0.3rem 0.55rem;
    font-size: 0.74rem;
    cursor: pointer;
}

.playbook-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.75rem 1rem 1rem;
    background: rgba(0, 0, 0, 0.22);
}

.playbook-footer p {
    font-size: 0.78rem;
    opacity: 0.86;
    margin-bottom: 0.6rem;
}

.playbook-join-btn {
    display: inline-block;
    text-decoration: none;
    border: 1px solid rgba(0, 255, 179, 0.45);
    color: var(--primary);
    border-radius: 6px;
    padding: 0.45rem 0.8rem;
    font-size: 0.78rem;
}