/* Styles généraux */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    margin: 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Navigation tabs */
.tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: #e2e8f0;
}

.tab-button.active {
    background: white;
    border-bottom-color: #4f46e5;
    color: #4f46e5;
}

/* Content tabs */
.tab-content {
    display: none;
    padding: 30px;
}

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

/* Simulation layout */
.controls {
    background: #f8fafc;
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 25px;
    border: 1px solid #e2e8f0;
}

.control-group {
    margin-bottom: 25px;
}

.control-group h3 {
    color: #1e293b;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

.control-group select,
.control-group input {
    margin-left: 10px;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
}

.control-group input[type="range"] {
    width: 100px;
}

/* Strategy controls */
.strategy-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.strategy {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.strategy label {
    margin: 0;
    flex: 1;
}

.strategy input {
    width: 80px;
    margin: 0;
}

/* Color indicators */
.color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid #334155;
}

.color-indicator.tft {
    background-color: #3b82f6; /* Bleu */
}

.color-indicator.always-cooperate {
    background-color: #10b981; /* Vert */
}

.color-indicator.always-defect {
    background-color: #ef4444; /* Rouge */
}

.color-indicator.random {
    background-color: #f59e0b; /* Orange */
}

.color-indicator.grudger {
    background-color: #8b5cf6; /* Violet */
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 10px;
}

.btn-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(79, 70, 229, 0.4);
}

.btn-secondary {
    background: #64748b;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-primary:disabled, .btn-secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Simulation area */
.simulation-area {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 25px;
    align-items: start;
}

.grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8fafc;
    border-radius: 10px;
    padding: 20px;
    border: 2px solid #e2e8f0;
}

#gameGrid {
    border: 2px solid #334155;
    border-radius: 8px;
    background: white;
}

/* Statistics */
.stats {
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.stats h3 {
    color: #1e293b;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.generation {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    text-align: center;
}

.population-stats {
    margin-bottom: 20px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 8px;
    background: white;
    border-radius: 6px;
    font-weight: 500;
}

/* Payoff matrix */
.payoff-matrix {
    background: white;
    padding: 15px;
    border-radius: 8px;
}

.payoff-matrix h4 {
    margin-bottom: 10px;
    color: #1e293b;
}

.payoff-matrix table {
    width: 100%;
    border-collapse: collapse;
}

.payoff-matrix th,
.payoff-matrix td {
    border: 1px solid #e2e8f0;
    padding: 8px;
    text-align: center;
}

.payoff-matrix th {
    background: #f1f5f9;
    font-weight: 600;
}

/* Theory and Help sections */
.theory-section,
.help-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 10px;
    border-left: 4px solid #4f46e5;
}

.theory-section h3,
.help-section h3 {
    color: #1e293b;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.theory-section p,
.help-section p,
.theory-section li,
.help-section li {
    line-height: 1.6;
    margin-bottom: 10px;
}

.strategy-list {
    display: grid;
    gap: 15px;
}

.strategy-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.strategy-item h4 {
    margin-bottom: 5px;
    color: #1e293b;
}

.strategy-item p {
    margin: 0;
    color: #64748b;
}

/* Responsive design */
@media (max-width: 1024px) {
    .simulation-area {
        grid-template-columns: 1fr;
    }

    .strategy-controls {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        margin: 10px;
    }

    header {
        padding: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .tab-content {
        padding: 20px;
    }

    .controls {
        padding: 20px;
    }

    #gameGrid {
        width: 100%;
        height: 400px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.tab-content.active {
    animation: fadeIn 0.3s ease;
}

/* Tooltips */
[title] {
    position: relative;
    cursor: help;
}

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

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