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

body {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    background: #0d0d0d;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ============================================
   TAB BAR
   ============================================ */
.tab-bar {
    background: linear-gradient(180deg, #1a1a1a 0%, #141414 100%);
    border-bottom: 1px solid #2a2a2a;
    padding: 0 16px;
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    height: 44px;
    align-items: flex-end;
}

.tab-button {
    padding: 10px 24px;
    background: transparent;
    border: none;
    border-radius: 8px 8px 0 0;
    color: #888;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    letter-spacing: 0.3px;
}

.tab-button:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #b0b0b0;
}

.tab-button.active {
    background: #1e1e1e;
    color: #00d4aa;
    border: 1px solid #2a2a2a;
    border-bottom: 1px solid #1e1e1e;
    margin-bottom: -1px;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00d4aa, transparent);
}

/* ============================================
   TAB CONTENT
   ============================================ */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    flex-direction: column;
}

.tab-content.active {
    display: flex;
}

/* ============================================
   MENU BAR (legacy)
   ============================================ */
.menu-bar {
    background: #2a2a2a;
    border-bottom: 1px solid #404040;
    padding: 8px 16px;
    display: flex;
    gap: 24px;
    flex-shrink: 0;
}

.menu-item {
    position: relative;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.menu-item:hover {
    background: #3a3a3a;
}

.menu-item.active {
    background: #4a4a4a;
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #2a2a2a;
    border: 1px solid #404040;
    border-radius: 4px;
    margin-top: 4px;
    min-width: 200px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.menu-item.active .menu-dropdown {
    display: block;
}

.menu-dropdown-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.menu-dropdown-item:hover {
    background: #3a3a3a;
}

/* ============================================
   MAIN LAYOUT (Simulation Tab)
   ============================================ */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: 250px;
    background: #1a1a1a;
    border-right: 1px solid #2a2a2a;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
}

.panel-section {
    margin-bottom: 24px;
}

.panel-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.tool-button {
    width: 100%;
    padding: 8px 12px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
}

.tool-button:hover {
    background: #2a2a2a;
    border-color: #444;
}

.tool-button.active {
    background: #00d4aa;
    border-color: #00d4aa;
    color: #000;
}

.agents-section {
    margin-top: 24px;
}

.agents-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.agent-list {
    margin-top: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.agent-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin-bottom: 6px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 11px;
}

.agent-item.enabled {
    border-color: #00d4aa;
    background: #1a2a25;
}

.agent-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    accent-color: #00d4aa;
}

.agent-item-name {
    flex: 1;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-item-remove {
    background: #ff4757;
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    margin-left: 8px;
    font-family: inherit;
}

.agent-item-remove:hover {
    background: #ff6b7a;
}

.settings-section {
    margin-top: 24px;
}

.settings-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.setting-item {
    margin-bottom: 16px;
}

.setting-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
}

.play-pause-button {
    width: 100%;
    padding: 10px 12px;
    background: #00d4aa;
    border: none;
    border-radius: 6px;
    color: #000;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.play-pause-button:hover {
    background: #00e6b8;
}

.play-pause-button.paused {
    background: #feca57;
}

.play-pause-button.paused:hover {
    background: #fed96a;
}

.speed-slider {
    width: 100%;
    margin-bottom: 4px;
    accent-color: #00d4aa;
}

.speed-value {
    font-size: 11px;
    color: #666;
    text-align: right;
}

.snake-count-input {
    width: 100%;
    padding: 8px;
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 13px;
    font-family: inherit;
}

.snake-count-input:focus {
    outline: none;
    border-color: #00d4aa;
}

/* Viewport */
.viewport-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0a0a0a;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: #1a1a1a;
    border-left: 1px solid #2a2a2a;
    padding: 16px;
    overflow-y: auto;
    flex-shrink: 0;
    display: none;
}

.sidebar.visible {
    display: block;
}

/* Status Bar */
.status-bar {
    background: #141414;
    border-top: 1px solid #2a2a2a;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #666;
    flex-shrink: 0;
}

.status-left, .status-right {
    display: flex;
    gap: 20px;
}

/* ============================================
   TRAINING DASHBOARD
   ============================================ */
.training-dashboard {
    flex: 1;
    background: #0d0d0d;
    overflow-y: auto;
    padding: 0;
}

.dashboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #333;
    border-top-color: #00d4aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

/* Dashboard Header */
.dashboard-header {
    background: linear-gradient(180deg, #1a1a1a 0%, #141414 100%);
    border-bottom: 1px solid #2a2a2a;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-selector label {
    font-size: 12px;
    color: #888;
    font-weight: 500;
}

.model-selector select {
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #e0e0e0;
    padding: 8px 12px;
    font-size: 12px;
    font-family: inherit;
    min-width: 250px;
    cursor: pointer;
}

.model-selector select:focus {
    outline: none;
    border-color: #00d4aa;
}

.refresh-btn {
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    color: #888;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: #2a2a2a;
    color: #00d4aa;
    border-color: #00d4aa;
}

.dashboard-status {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
}

#pollStatus {
    font-weight: 500;
}

#lastUpdate {
    color: #666;
}

/* Dashboard Panels Grid */
.dashboard-panels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding: 24px;
    min-height: calc(100vh - 140px);
}

@media (max-width: 1200px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

/* Individual Panel */
.dashboard-panel {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s ease;
    min-height: 300px;
}

.dashboard-panel:hover {
    border-color: #333;
}

.dashboard-panel.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.panel-header {
    background: linear-gradient(180deg, #222 0%, #1a1a1a 100%);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2a2a2a;
    cursor: grab;
}

.panel-header:active {
    cursor: grabbing;
}

.panel-title {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    letter-spacing: 0.3px;
}

.panel-drag-handle {
    color: #444;
    font-size: 14px;
    user-select: none;
}

.panel-content {
    padding: 16px;
    height: calc(100% - 45px);
}

/* Chart containers */
.panel-content > div {
    width: 100%;
    height: 100%;
    min-height: 250px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    height: 100%;
}

@media (max-width: 800px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: linear-gradient(135deg, #1e1e1e 0%, #252525 100%);
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: #333;
    transform: translateY(-2px);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #00d4aa;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* ============================================
   PLOTLY OVERRIDES
   ============================================ */
.js-plotly-plot .plotly .modebar {
    background: transparent !important;
}

.js-plotly-plot .plotly .modebar-btn {
    color: #666 !important;
}

.js-plotly-plot .plotly .modebar-btn:hover {
    color: #00d4aa !important;
}
