:root {
    --primary-color: #2563eb;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-yellow: #fbbf24;
    --accent-red: #ef4444;
    
    /* Couleurs des phases */
    --phase-admission: #60a5fa;
    --phase-compression: #f59e0b;
    --phase-combustion-iso: #ef4444;
    --phase-combustion-iso-bar: #dc2626;
    --phase-detente: #10b981;
    --phase-echappement: #6366f1;
}

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

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

header {
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    padding: 1.5rem 2rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.container {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    padding: 1.5rem;
    max-width: 1800px;
    margin: 0 auto;
}

/* Panneau de contrôle */
.control-panel {
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 1.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 3rem);
}

.control-panel h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.section:last-of-type {
    border-bottom: none;
}

.section h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.input-group input[type="number"],
.input-group input[type="range"],
.input-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
    background: white;
}

.input-group input[type="number"]:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-group.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-group.checkbox input {
    width: auto;
}

.input-group input[type="range"] {
    padding: 0;
}

#pourcCombVolValue {
    display: inline-block;
    margin-left: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
}

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

.btn-primary:hover {
    background: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

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

.btn-secondary:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* Zone principale */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.chart-section,
.results-section {
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-section h2,
.results-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#chartPV {
    display: block;
    margin: 0 auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}

.phase-indicator {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 4px;
}

.phase-indicator span {
    font-weight: 600;
    font-size: 1rem;
}

#phaseText {
    color: var(--primary-color);
}

#pointText {
    color: var(--secondary-color);
}

/* Onglets */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary-color);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
}

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

/* Tableau résultats */
#resultsTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

#resultsTable thead {
    background: var(--background);
}

#resultsTable th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

#resultsTable td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

#resultsTable tbody tr:hover {
    background: var(--background);
}

.phase-color {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
}

/* Calculs détaillés */
#calculationsDetail,
#energyBalance {
    font-size: 0.95rem;
    line-height: 1.8;
}

.formula-block {
    background: var(--background);
    padding: 1rem;
    border-radius: 4px;
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
}

.formula-block h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.formula {
    font-family: 'Courier New', monospace;
    background: white;
    padding: 0.5rem;
    border-radius: 4px;
    margin: 0.5rem 0;
    display: block;
}

.result-highlight {
    background: var(--accent-yellow);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    font-weight: 600;
}

/* Animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.animating {
    animation: pulse 1s ease-in-out infinite;
}

/* ============================================
   TRAVAUX DIRIGÉS - STYLES
   ============================================ */

.td-start-screen {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.td-header {
    text-align: center;
    margin-bottom: 2rem;
}

.td-header h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.td-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.td-intro-box {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
}

.td-intro-box h3 {
    color: var(--text-primary);
    margin: 1.5rem 0 1rem 0;
    font-size: 1.2rem;
}

.td-intro-box h3:first-child {
    margin-top: 0;
}

.td-intro-list {
    list-style: none;
    padding-left: 0;
}

.td-intro-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.td-intro-list li:last-child {
    border-bottom: none;
}

.td-sections-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.td-section-card {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.section-badge {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.section-badge.decouverte {
    background: #d1fae5;
    color: #065f46;
}

.section-badge.analyse {
    background: #fef3c7;
    color: #92400e;
}

.section-badge.synthese {
    background: #fee2e2;
    color: #991b1b;
}

.td-section-card p {
    font-weight: 600;
    margin: 0.5rem 0;
}

.td-section-card small {
    color: var(--text-secondary);
}

.td-mode-info {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: 4px;
}

.td-mode-info ul {
    margin-top: 0.5rem;
    padding-left: 1.5rem;
}

.td-actions {
    text-align: center;
    margin-top: 2rem;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.td-note {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Interface principale TD */
.td-main-interface {
    padding: 1rem;
}

.td-progress-header {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.td-progress-info h3 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
}

.td-progress-info p {
    margin: 0;
    color: var(--text-secondary);
}

.td-timer {
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 0.5rem;
}

.td-timer-timeout {
    color: var(--accent-red);
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.td-progress-bar {
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    margin: 1rem 0;
    overflow: hidden;
}

.td-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
}

.td-actions-header {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.td-sections-nav {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.td-section-btn {
    flex: 1;
    padding: 1rem;
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.td-section-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.td-section-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.section-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.section-progress {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Questions */
.td-questions-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.td-question-card {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.td-question-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.td-question-card.answered {
    border-color: var(--secondary-color);
}

.td-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    cursor: pointer;
}

.td-question-number {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.q-badge {
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-weight: 600;
}

.q-type {
    padding: 0.3rem 0.6rem;
    background: #e2e8f0;
    border-radius: 4px;
    font-size: 0.85rem;
}

.q-points {
    padding: 0.3rem 0.6rem;
    background: #fef3c7;
    color: #92400e;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

.td-expand-btn {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.td-expand-btn:hover {
    background: #1e40af;
}

.td-question-body {
    padding: 1.5rem;
}

.td-question-text {
    font-size: 1.05rem;
    line-height: 1.7;
    margin-bottom: 1rem;
    white-space: pre-line;
}

.td-instruction {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    padding: 0.75rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.td-unlock-notice {
    background: #fef3c7;
    border-left: 4px solid var(--accent-yellow);
    padding: 0.75rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.td-locked-notice {
    background: #fee2e2;
    border-left: 4px solid var(--accent-red);
    padding: 0.75rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.td-timeout-notice {
    background: #fee2e2;
    border: 2px solid var(--accent-red);
    border-radius: 8px;
    padding: 2rem;
    margin: 1.5rem 0;
    text-align: center;
}

.td-timeout-notice h3 {
    color: var(--accent-red);
    margin-top: 0;
}

.td-question-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

/* QCM */
.td-qcm-choices {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

.td-choice-label {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: #f8fafc;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.td-choice-label:hover {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.td-choice-label.selected {
    background: #dbeafe;
    border-color: var(--primary-color);
}

.td-choice-label input[type="radio"] {
    margin-right: 1rem;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.choice-text {
    flex: 1;
}

/* Calcul */
.td-calcul-section {
    margin: 1rem 0;
}

.td-data-table {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.td-data-table h4 {
    margin: 0 0 0.5rem 0;
}

.td-data-table table {
    width: 100%;
    border-collapse: collapse;
}

.td-data-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.td-data-table td:last-child {
    text-align: right;
}

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

.td-formula-box {
    background: #fffbeb;
    border-left: 4px solid var(--accent-yellow);
    padding: 0.75rem;
    margin: 1rem 0;
    border-radius: 4px;
}

.td-formula-box code {
    font-family: 'Courier New', monospace;
    font-size: 1.05rem;
}

.td-answer-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 1rem 0;
}

.td-answer-input label {
    font-weight: 600;
}

.td-answer-input input {
    flex: 1;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.td-unit {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Feedback */
.td-answer-feedback {
    margin-top: 1.5rem;
}

.td-feedback {
    border-radius: 8px;
    padding: 1rem;
}

.td-feedback.correct {
    background: #d1fae5;
    border-left: 4px solid var(--secondary-color);
}

.td-feedback.incorrect {
    background: #fee2e2;
    border-left: 4px solid var(--accent-red);
}

.feedback-header {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.feedback-explanation {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0,0,0,0.1);
}

.feedback-explanation code {
    display: block;
    background: rgba(0,0,0,0.05);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    white-space: pre-line;
}

/* Indice */
.td-hint-section {
    margin: 1rem 0;
}

.td-hint-box {
    background: #fef3c7;
    border-left: 4px solid var(--accent-yellow);
    padding: 0.75rem;
    margin: 1rem 0;
    border-radius: 4px;
}

/* Évaluation finale */
.td-evaluation {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

.eval-header {
    text-align: center;
    margin-bottom: 2rem;
}

.eval-score-big {
    margin: 1rem 0;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
}

.score-max {
    font-size: 2rem;
    color: var(--text-secondary);
}

.eval-appreciation {
    font-size: 1.3rem;
    font-weight: 600;
    margin-top: 1rem;
}

.eval-appreciation.excellent {
    color: #065f46;
}

.eval-appreciation.tres-bien {
    color: #047857;
}

.eval-appreciation.bien {
    color: #1d4ed8;
}

.eval-appreciation.passable {
    color: #d97706;
}

.eval-appreciation.insuffisant {
    color: #dc2626;
}

.eval-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.eval-stat {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

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

.eval-sections {
    background: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
}

.eval-sections h3 {
    margin-top: 0;
}

.eval-section-detail {
    display: grid;
    grid-template-columns: 150px 1fr 80px;
    gap: 1rem;
    align-items: center;
    margin: 1rem 0;
}

.section-name-eval {
    font-weight: 600;
}

.section-score-bar {
    height: 20px;
    background: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
}

.section-score-text {
    text-align: right;
    font-weight: 600;
}

.eval-feedback {
    background: #eff6ff;
    border-left: 4px solid var(--primary-color);
    padding: 1.5rem;
    border-radius: 8px;
    margin: 2rem 0;
}

.eval-feedback h3 {
    margin-top: 0;
}

.feedback-list {
    list-style: none;
    padding-left: 0;
}

.feedback-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

.feedback-list li:last-child {
    border-bottom: none;
}

.feedback-good {
    color: #065f46;
}

.feedback-ok {
    color: #d97706;
}

.feedback-weak {
    color: #dc2626;
}

.eval-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Tabs verrouillés */
.tab-btn.td-locked {
    opacity: 0.5;
    cursor: not-allowed;
    position: relative;
}

.tab-btn.td-locked::after {
    content: '🔒';
    margin-left: 0.5rem;
}

/* Responsive */
@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.1rem;
    }
    
    .container {
        padding: 1rem;
        gap: 1rem;
    }
    
    #chartPV,
    #cylinderCanvas {
        width: 100%;
        height: auto;
    }
    
    .td-sections-preview {
        grid-template-columns: 1fr;
    }
    
    .eval-stats {
        grid-template-columns: 1fr;
    }
    
    .eval-section-detail {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .section-score-text {
        text-align: left;
    }
}
