:root {
    --bg-dark: #0b0f19;
    --bg-card: #151f32;
    --primary: #38bdf8;
    --primary-dark: #0284c7;
    --primary-light: #e0f2fe;
    --accent: #22d3ee;
    --border: #1e293b;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dark: #0f172a;
    --code-bg: #1e293b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #f43f5e;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    background-color: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

.logo {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: 1px;
    color: var(--text-main);
    margin-right: 1.5rem;
    white-space: nowrap;
}

.logo span:not(#hud-version) {
    color: var(--primary);
}

.status-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    background-color: var(--text-muted);
}

.stats-bar {
    margin-left: auto;
    display: flex;
    gap: 2rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
}

main {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    overflow: hidden;
}

section {
    background-color: var(--bg-card);
    border-radius: 0.5rem;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

h3 {
    margin-top: 0;
    border-bottom: 1px solid var(--text-muted);
    padding-bottom: 0.5rem;
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

#scenario-list, #profile-list {
    flex: 1;
    overflow-y: auto;
}

.draggable {
    background: #334155;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
    cursor: grab;
    border-left: 4px solid var(--accent);
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-run-small {
    background: var(--success);
    color: var(--bg-dark);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    opacity: 0.8;
}

.btn-run-small:hover { opacity: 1; }

.draggable:hover {
    background: #475569;
}

#composer-canvas {
    flex: 1;
    border: 2px dashed #475569;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

.empty-hint {
    color: var(--text-muted);
    text-align: center;
    margin-top: 5rem;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

input[type="text"] {
    flex: 1;
    background: var(--bg-dark);
    border: 1px solid #475569;
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
}

button {
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary { background: var(--primary); color: var(--bg-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:disabled {
    background: #475569;
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

#grid-panel {
    overflow: hidden;
    min-height: 0;
}

#worker-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.worker-card {
    background: #0f172a;
    padding: 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
    border: 1px solid #334155;
}

.worker-card.active { border-color: var(--success); }
.worker-card .role { color: var(--accent); font-weight: bold; }
.worker-card .status { float: right; color: var(--text-muted); }

/* Custom Range Input Track and Thumb styling */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    margin: 8px 0;
}
input[type="range"]:focus {
    outline: none;
}
input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #334155;
    border-radius: 3px;
    border: 1px solid #475569;
}
input[type="range"]::-webkit-slider-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -6px;
    box-shadow: 0 0 8px var(--primary);
    transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}
input[type="range"]::-moz-range-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: #334155;
    border-radius: 3px;
    border: 1px solid #475569;
}
input[type="range"]::-moz-range-thumb {
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px var(--primary);
    transition: transform 0.1s;
}
#composer-panel {
    overflow-y: auto;
}

/* Pre-Run Modal styling */
.modal {
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    overflow-y: auto;
    padding: 2rem 1rem;
    box-sizing: border-box;
}

.modal-content {
    background-color: var(--bg-card);
    margin: 5vh auto;
    padding: 2rem;
    border: 1px solid var(--primary);
    border-radius: 0.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.3);
    box-sizing: border-box;
}

.btn-pager {
    background: #334155;
    border: 1px solid #475569;
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
}
.btn-pager:hover:not(:disabled) {
    border-color: var(--primary);
    color: white;
}
.btn-pager:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

}

/* Tab Navigation Styles */
#tab-navigation {
    display: flex;
    gap: 10px;
}

.nav-tab {
    background: transparent;
    border: 1px solid #334155;
    color: var(--text-muted);
    padding: 0.3rem 0.75rem;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.nav-tab:hover {
    border-color: var(--primary);
    color: white;
}

.nav-tab.active {
    background: var(--primary);
    color: var(--bg-dark);
    border-color: var(--primary);
}

.tab-view {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

#view-scenarios {
    grid-template-columns: 300px 1fr 450px;
}

#view-system {
    grid-template-columns: 1fr;
}

/* Tree Explorer Styles */
.tree-container {
    flex: 1;
    overflow-y: auto;
    font-size: 0.85rem;
    font-family: 'JetBrains Mono', monospace;
}

.tree-node {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-node:hover {
    background: rgba(56, 189, 248, 0.1);
    color: var(--primary);
}

.tree-folder {
    color: var(--accent);
    font-weight: bold;
}

.tree-file {
    color: var(--text-main);
}

/* JSON Inspector Styles */
.inspector-container {
    flex: 1;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid #334155;
    border-radius: 4px;
    padding: 1rem;
    overflow: auto;
}

.json-code {
    margin: 0;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

.json-key { color: var(--primary); }
.json-string { color: var(--success); }
.json-number { color: #f59e0b; }
.json-boolean { color: var(--danger); }
.json-null { color: var(--text-muted); }

/* Topology Visualizer Styles */
.topology-container {
    flex: 1;
    background: #0b1120;
    border: 1px solid #334155;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.topology-container svg {
    display: block;
}

.loading {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    margin-top: 2rem;
    font-style: italic;
}

/* Responsive / Mobile Design Queries */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 250px 1fr;
        overflow-y: auto;
    }
    #grid-panel {
        grid-column: span 2;
    }
}

@media (max-width: 768px) {
    body {
        height: auto;
        overflow-y: auto;
    }
    header {
        flex-direction: column;
        gap: 10px;
        padding: 1rem;
        text-align: center;
    }
    .stats-bar {
        margin-left: 0;
        gap: 1rem;
        font-size: 0.9rem;
    }
    #license-bar {
        position: static !important;
        transform: none !important;
        flex-direction: column;
        gap: 4px;
        width: 100%;
        box-sizing: border-box;
        align-items: center;
    }
    main {
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
    }
    #composer-panel, #grid-panel, #library-panel, #history-panel {
        grid-column: span 1;
        height: auto !important;
        min-height: 0;
    }
}
