/* Variables CSS */
:root {
    --primary-color: #667eea;
    --secondary-color: #764ba2;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --danger-color: #f44336;
    --info-color: #2196f3;
    --bg-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --card-bg: white;
    --text-primary: #333;
    --text-secondary: #666;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* En-tête */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.back-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.header-title {
    text-align: center;
    flex: 1;
    min-width: 300px;
}

.header-title h1 {
    color: white;
    font-size: 2.2em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1em;
    font-weight: 300;
}

/* Panneau de contrôle */
.control-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.panel-section {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.panel-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.4em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.config-item label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.config-item small {
    font-size: 0.75em;
    color: var(--gray);
    margin-top: -5px;
}

.config-item input[type="number"],
.config-item input[type="range"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.config-item input[type="number"]:focus,
.config-item input[type="range"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.value-display {
    text-align: right;
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1em;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #45a049;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #f57c00;
}

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

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

/* Statistiques */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    border-left: 4px solid var(--primary-color);
}

.stat-label {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin-bottom: 5px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-value small {
    font-size: 0.7em;
    color: var(--text-secondary);
}

.info-content {
    line-height: 1.7;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.info-content p {
    margin-bottom: 10px;
}

.info-content strong {
    color: var(--primary-color);
}

/* Zone de simulation */
.simulation-area {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    margin-bottom: 20px;
}

.canvas-container {
    position: relative;
    background: #1a1a2e;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

#simulationCanvas {
    display: block;
    background: #0a0a1a;
    border: 2px solid #333;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.color-box {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.best-car { background: linear-gradient(45deg, #ff00ff, #00ffff); box-shadow: 0 0 10px #00ffff; }
.elite-car { background: linear-gradient(45deg, #764ba2, #f093fb); box-shadow: 0 0 8px #f093fb; }
.normal-car { background: linear-gradient(45deg, #667eea, #764ba2); }
.crashed-car { background: linear-gradient(45deg, #f44336, #ff9800); opacity: 0.5; }
.checkpoint { background: linear-gradient(45deg, #4caf50, #8bc34a); box-shadow: 0 0 8px #8bc34a; }

/* Contrôles de simulation */
.simulation-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

.speed-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 8px;
}

.speed-control label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.speed-control input[type="range"] {
    width: 100%;
    margin: 0;
}

#speedValue {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1em;
}

/* Graphiques */
.charts-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    height: 300px;
}

/* Pied de page */
.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    padding: 20px;
    font-size: 0.9em;
}

.footer a {
    color: white;
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .canvas-container {
        overflow-x: auto;
    }
    
    .header-title h1 {
        font-size: 1.6em;
    }
    
    .charts-area {
        grid-template-columns: 1fr;
    }
    
    .simulation-controls {
        grid-template-columns: 1fr;
    }
}