/* metrics.css - Styling for the metrics dashboard */

:root {
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --background-color: #f5f7fa;
    --card-bg-color: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --grid-line-color: #f0f0f0;
    --self-play-active: #4caf50;
    --self-play-inactive: #f44336;
}

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

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
    padding: 0;
    margin: 0;
}

.metrics-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    margin-bottom: 30px;
    position: relative;
}

h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    font-size: 28px;
}

h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 22px;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 5px;
}

h3 {
    font-size: 18px;
    margin-bottom: 10px;
    color: var(--text-color);
}

.version {
    position: absolute;
    top: 0;
    right: 0;
    font-family: monospace;
    font-size: 12px;
    color: #666;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.nav-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.nav-button:hover {
    background-color: #3a7bc8;
}

.connection-status {
    font-size: 14px;
    padding: 5px 10px;
    border-radius: 4px;
    background-color: #f0f0f0;
}

.connection-status.connected {
    background-color: var(--success-color);
    color: white;
}

.connection-status.disconnected {
    background-color: var(--error-color);
    color: white;
}

/* Nano connection status */
.nano-connection-status {
    margin-bottom: 30px;
}

.nano-panel {
    background-color: var(--card-bg-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    display: flex;
    align-items: center;
}

#nanoConnectionStatus {
    font-weight: bold;
    font-size: 18px;
    margin-right: 10px;
}

#nanoLastSeen {
    font-size: 14px;
    color: #666;
    margin-left: 15px;
}

.status-connected {
    color: var(--success-color);
}

.status-disconnected {
    color: var(--error-color);
}

/* Self-Play Status Panel */
.self-play-status {
    margin-bottom: 30px;
}

.self-play-panel {
    background-color: var(--card-bg-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.status-indicator {
    display: flex;
    align-items: center;
}

.status-light {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin-right: 10px;
}

.status-light.active {
    background-color: var(--self-play-active);
    box-shadow: 0 0 10px 2px rgba(76, 175, 80, 0.5);
    animation: pulse 2s infinite;
}

.status-light.inactive {
    background-color: var(--self-play-inactive);
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.self-play-stats {
    display: flex;
    gap: 20px;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    grid-gap: 20px;
}

.metrics-panel {
    margin-bottom: 30px;
}

.metrics-panel.full-width {
    grid-column: 1 / -1;
}

.metrics-card {
    background-color: var(--card-bg-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 20px;
    margin-bottom: 20px;
}

.chart-container {
    position: relative;
    height: 250px;
    margin-bottom: 10px;
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 15px;
    margin-bottom: 20px;
}

.stat-box {
    text-align: center;
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 4px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

/* New Source Toggle Buttons */
.source-toggle {
    display: flex;
    margin-bottom: 15px;
    background-color: #f2f2f2;
    border-radius: 4px;
    padding: 2px;
}

.toggle-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 3px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
}

.toggle-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.toggle-btn:not(.active):hover {
    background-color: #e0e0e0;
}

/* Self-Play Controls */
.self-play-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group label {
    margin-bottom: 8px;
    font-weight: 500;
}

.control-group input[type="range"] {
    margin-bottom: 5px;
}

.control-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.action-button {
    padding: 8px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s;
}

.action-button:hover {
    background-color: #3a7bc8;
}

/* Board styling */
.board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.board,
.q-value-board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-gap: 2px;
    background-color: #333;
    width: fit-content;
}

.cell {
    width: 100px;
    height: 100px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    position: relative;
}

/* Position frequency board */
#positionFrequencyBoard .cell {
    font-size: 16px;
    color: #333;
}

#positionFrequencyBoard .cell-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

#positionFrequencyBoard .cell-value {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 5px;
}

#positionFrequencyBoard .cell-percent {
    font-size: 14px;
    color: #666;
}

/* Q-Value visualization */
#qValueContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.q-value-legend {
    display: flex;
    margin-bottom: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-right: 20px;
}

.legend-color {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    border-radius: 3px;
}

.legend-label {
    font-size: 14px;
}

.board-state-label {
    text-align: center;
    font-size: 16px;
    margin-top: 10px;
    color: #666;
}

.q-value-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.cell-value {
    font-size: 24px;
    font-weight: bold;
}

.cell-label {
    font-size: 12px;
    color: #666;
}

/* Cell visual states */
.cell.selected {
    border: 3px solid var(--primary-color);
}

.cell.occupied-x {
    background-color: #ffeeee;
}

.cell.occupied-o {
    background-color: #eeeeff;
}

/* Responsive adjustments */
@media screen and (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 600px) {
    .board,
    .q-value-board {
        grid-template-columns: repeat(3, 80px);
    }

    .cell {
        width: 80px;
        height: 80px;
        font-size: 20px;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .self-play-panel {
        flex-direction: column;
        gap: 15px;
    }

    .self-play-stats {
        width: 100%;
        flex-wrap: wrap;
    }
}
