/* Q-learning Demo Specific Styles */

/* Override container max-width for three-column layout */
.container {
    max-width: 1400px;
}

.demo-wrapper {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Checkpoint Controls */
.checkpoint-controls {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.checkpoint-controls h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #2c3e50;
}

.checkpoint-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.checkpoint-btn {
    padding: 12px 8px;
    border: 2px solid #dee2e6;
    background: white;
    cursor: pointer;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.4;
}

.checkpoint-btn:hover {
    border-color: #adb5bd;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.checkpoint-btn.active {
    border-color: #007bff;
    background: #e7f3ff;
    font-weight: 600;
}

.teaching-callout {
    padding: 15px;
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
}

.teaching-callout strong {
    display: block;
    margin-bottom: 8px;
    color: #856404;
    font-size: 15px;
}

.teaching-callout p {
    margin: 0;
    color: #856404;
    font-size: 14px;
}

/* Three-Column Grid Layout */
.algorithms-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.algorithm-column {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.algo-header {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px 8px 0 0;
    color: white;
}

.algo-header h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.attempt-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    background: transparent;
    padding: 4px 10px;
    font-family: 'Courier New', monospace;
    z-index: 10;
}

.algo-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255,255,255,0.25);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Canvas Card */
.canvas-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.canvas-shell {
    position: relative;
    background: linear-gradient(to bottom, #f8fafc, #eef2ff);
    padding: 10px;
}

.canvas-shell canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.canvas-controls {
    display: flex;
    gap: 8px;
    padding: 10px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.canvas-controls button {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.play-btn {
    background: #28a745;
    color: white;
}

.play-btn:hover {
    background: #218838;
}

.step-btn {
    background: #17a2b8;
    color: white;
}

.step-btn:hover {
    background: #138496;
}

.reset-btn {
    background: #6c757d;
    color: white;
}

.reset-btn:hover {
    background: #5a6268;
}

/* Metrics Row */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* Metric labels: big value with small label in corner */
.algorithms-grid .metriclabel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    padding: 8px;
}

.algorithms-grid .metric-value {
    font-size: 24px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.algorithms-grid .metric-label {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 10px;
    font-weight: 500;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Chart Card */
.chart-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.chart-card h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #495057;
    text-align: center;
}

.chart-card canvas {
    max-height: 150px;
}

/* Q-Table Card */
.qtable-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.qtable-card h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #495057;
    text-align: center;
}

.qtable-card canvas {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

/* TD Error Panel */
.td-error-panel {
    background: white;
    border: 2px solid #17a2b8;
    border-radius: 8px;
    padding: 20px;
}

.td-error-panel h3 {
    margin: 0 0 8px 0;
    color: #17a2b8;
    font-size: 18px;
}

.td-subtitle {
    margin: 0 0 15px 0;
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
}

#td-breakdown {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.8;
}

.equation-row {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 6px;
    background: #f8f9fa;
    border-radius: 4px;
}

.equation-row span:first-child {
    font-weight: 600;
    color: #495057;
}

.equation-row span:last-child {
    font-family: 'Courier New', monospace;
    color: #212529;
}

.equation-row.highlight {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
}

.equation-row.positive {
    background: #d4edda;
    border-left: 4px solid #28a745;
}

.equation-row.negative {
    background: #f8d7da;
    border-left: 4px solid #dc3545;
}

/* Info Table */
.info-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 14px;
}

.info-table th {
    background: #f8f9fa;
    padding: 10px;
    text-align: left;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.info-table td {
    padding: 10px;
    border-bottom: 1px solid #e9ecef;
}

.info-table tr:last-child td {
    border-bottom: none;
}

/* Responsive Design */
@media (max-width: 1400px) {
    .algorithms-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .algo-header {
        border-radius: 8px 8px 0 0;
    }
}

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

    .metrics-row {
        grid-template-columns: 1fr;
    }
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay .loading-spinner {
    width: 60px;
    height: 60px;
    border-width: 6px;
}

/* Algorithm-specific header colors */
#mc-column .algo-header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

#sarsa-column .algo-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

#qlearning-column .algo-header {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}
