:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-solid: #1e293b;
    --card-border: rgba(148, 163, 184, 0.1);
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --secondary-color: #94a3b8;
    --success-color: #10b981;
    --danger-color: #ef4444;
}

[data-bs-theme="light"] {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-solid: #ffffff;
    --card-border: rgba(0, 0, 0, 0.1);
    --secondary-color: #475569;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.select-input {
    color: var(--text-color);
    background: var(--card-bg);
    border: 1px solid var(--card-border);
}

.select-input option {
    background-color: var(--card-solid);
    color: var(--text-color);
}

.matrix-navbar {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 1.5rem;
}

.nav-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand i {
    color: var(--accent-color);
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.main-container {
    flex: 1;
    display: flex;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    height: calc(100vh - 80px);
    /* Fill remaining height */
}

/* Sidebar Controls */
.controls-panel {
    width: 350px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    backdrop-filter: blur(20px);
    height: 100%;
    overflow-y: auto;
}

.panel-header {
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 1rem;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.section-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary-color);
    font-weight: 600;
}

/* Feature Selection - custom checkboxes */
.feature-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-color);
    width: 100%;
    /* Ensure full width in flex containers */
    box-sizing: border-box;
}

button.feature-toggle {
    text-align: center;
    justify-content: center;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

button.feature-toggle:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

button.feature-toggle i {
    font-size: 1.1em;
}

#animate-btn {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.2));
    border-color: rgba(16, 185, 129, 0.4);
    color: #34d399;
}

#animate-btn:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.3));
    border-color: #10b981;
    color: #fff;
}

#velocity-btn {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.1), rgba(249, 115, 22, 0.2));
    border-color: rgba(249, 115, 22, 0.4);
    color: #fb923c;
}

#velocity-btn:hover {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.2), rgba(249, 115, 22, 0.3));
    border-color: #f97316;
    color: #fff;
}

.feature-toggle:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.05);
}

/* Active state for feature toggle */
.feature-toggle.active {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

.feature-toggle.active .icon {
    color: var(--accent-color);
}

/* Matrix Visualization Area */
.matrix-container {
    flex: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

#matrix-canvas {
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 0.5rem;
    cursor: crosshair;
}

.tooltip {
    position: absolute;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--card-border);
    padding: 1rem;
    border-radius: 0.5rem;
    pointer-events: none;
    z-index: 20;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    max-width: 250px;
    display: none;
}

.tooltip-header {
    font-weight: 600;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.25rem;
    color: var(--accent-color);
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.correlation-matrix-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.corr-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    padding: 1rem;
    border-radius: 0.5rem;
    text-align: center;
}

.corr-value {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(to right, #60a5fa, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-radius: 50%;
    border-top-color: var(--accent-color);
    animation: spin 1s ease-in-out infinite;
}

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

/* Tabs for View Switch */
.view-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.25rem;
    border-radius: 0.5rem;
    width: fit-content;
}

.view-tab {
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--secondary-color);
    transition: all 0.2s;
}

.view-tab.active {
    background: var(--accent-color);
    color: white;
}