/* ==========================================
   ADVANCED SIMULATORS - Styles
   ========================================== */

.sim-page {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.sim-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.sim-header h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: var(--secondary);
}

.sim-content {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

/* Placement Test */
.placement-intro {
    text-align: center;
    padding: 40px 20px;
}

.placement-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.placement-intro h3 {
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.placement-intro p {
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.6;
}

/* Quiz Progress */
.quiz-progress-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}

.quiz-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.quiz-counter {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.question-card {
    padding: 24px;
}

.question-card h3 {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.option-btn:hover {
    border-color: var(--primary);
    background: rgba(245, 158, 11, 0.05);
}

.option-btn.selected {
    border-color: var(--primary);
    background: rgba(245, 158, 11, 0.1);
}

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--border-light);
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Results */
.results-card {
    text-align: center;
    padding: 30px 20px;
}

.score-big {
    font-size: 3rem;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--primary);
    margin: 16px 0;
}

.level-badge {
    display: inline-block;
    padding: 6px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 16px;
}

.level-badge.level-1 { background: #fecaca; color: #991b1b; }
.level-badge.level-2 { background: #fed7aa; color: #9a3412; }
.level-badge.level-3 { background: #bbf7d0; color: #166534; }
.level-badge.level-4 { background: #dbeafe; color: #1e40af; }

.result-message {
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Domain Bars */
.domain-bars {
    text-align: left;
    margin: 20px 0;
}

.domain-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.domain-label {
    width: 140px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    flex-shrink: 0;
}

.domain-bar-bg {
    flex: 1;
    height: 24px;
    background: var(--border-light);
    border-radius: 12px;
    overflow: hidden;
}

.domain-bar-fill {
    height: 100%;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    transition: width 0.5s ease;
    min-width: 30px;
}

.domain-bar-fill.mastery-acquis { background: #22c55e; }
.domain-bar-fill.mastery-en\ cours { background: #f59e0b; }
.domain-bar-fill.mastery-lacune { background: #ef4444; }

.ci-range {
    font-size: 0.7rem;
    color: var(--text-dim);
    width: 80px;
}

.anomalies-box {
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin: 16px 0;
}

/* Scenario Cards */
.scenario-cards, .scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.scenario-card {
    padding: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
}

.scenario-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.scenario-card h4 {
    font-size: 1rem;
    margin-bottom: 8px;
}

.scenario-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.scenario-meta {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* OCPP */
.ocpp-step {
    padding: 20px;
}

.step-progress {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.code-textarea {
    width: 100%;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #1e1e2e;
    color: #cdd6f4;
    resize: vertical;
}

.code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 14px;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 0.82rem;
    overflow-x: auto;
}

.fields-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 10px 0;
}

.ocpp-feedback, .fault-feedback {
    padding: 16px;
    border-radius: 10px;
    margin: 16px 0;
}

.feedback-success {
    background: rgba(34, 197, 94, 0.08);
    border-left: 4px solid #22c55e;
}

.feedback-error {
    background: rgba(239, 68, 68, 0.08);
    border-left: 4px solid #ef4444;
}

.score-info {
    font-weight: 600;
    color: var(--secondary);
    margin-top: 10px;
}

.final-score-card {
    text-align: center;
    padding: 30px;
    margin-top: 20px;
}

/* Smart Charging */
.sim-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.form-card {
    padding: 20px 0;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-grid input, .form-grid select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
}

.charger-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--border-light);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.result-card {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-cream);
    border-radius: var(--radius);
}

.allocation-bars {
    margin: 14px 0;
}

.alloc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.alloc-id {
    width: 40px;
    font-weight: 600;
    font-size: 0.85rem;
}

.alloc-bar-bg {
    flex: 1;
    height: 28px;
    background: var(--border-light);
    border-radius: 14px;
    overflow: hidden;
}

.alloc-bar-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a2400;
    font-weight: 600;
    font-size: 0.8rem;
    transition: width 0.5s ease;
}

.alloc-info {
    font-size: 0.75rem;
    color: var(--text-dim);
    width: 120px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table td:first-child {
    color: var(--text-muted);
}

.text-danger { color: #dc2626; font-weight: 600; }
.text-success { color: #16a34a; font-weight: 600; }
.warning-text { color: #dc2626; font-weight: 600; margin: 10px 0; }
.success-text { color: #16a34a; font-weight: 600; margin: 10px 0; }

.steps-box {
    margin-top: 16px;
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 14px;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 0.78rem;
    max-height: 300px;
    overflow-y: auto;
}

.steps-box pre {
    white-space: pre-wrap;
    margin: 0;
}

/* TIC Linky gauge */
.delestage-gauge {
    margin: 16px 0;
}

.gauge-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.gauge-bar-bg {
    height: 36px;
    background: var(--border-light);
    border-radius: 18px;
    overflow: hidden;
}

.gauge-bar-fill {
    height: 100%;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: white;
    transition: width 0.5s ease;
}

.gauge-bar-fill.level-aucun { background: #22c55e; }
.gauge-bar-fill.level-partiel { background: #f59e0b; color: #4a2400; }
.gauge-bar-fill.level-fort { background: #ef4444; }
.gauge-bar-fill.level-total { background: #7f1d1d; }

/* Fault Diagnosis */
.fault-scenario {
    padding: 10px;
}

.scenario-context {
    padding: 16px;
    background: rgba(59, 130, 246, 0.06);
    border-radius: 10px;
    margin-bottom: 20px;
}

.symptom-text, .context-text {
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 6px 0;
}

.fault-step {
    padding: 20px 0;
}

.step-counter {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.fault-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.fault-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.fault-option-btn:hover:not(:disabled) {
    border-color: var(--primary);
}

.fault-option-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.root-cause-box {
    background: rgba(245, 158, 11, 0.08);
    padding: 16px;
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    margin: 20px 0;
    text-align: left;
}

.fault-summary {
    text-align: center;
    padding: 30px 20px;
}

/* Schema Builder */
.schema-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    padding: 10px;
    background: var(--border-light);
    border-radius: 10px;
}

.tool-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.82rem;
    transition: all 0.2s;
}

.tool-btn:hover { border-color: var(--primary); }
.tool-btn.active { background: var(--primary); color: #4a2400; border-color: var(--primary); font-weight: 600; }
.tool-btn.danger { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }

.schema-workspace {
    border: 2px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

#schema-canvas {
    display: block;
    cursor: crosshair;
}

.validation-panel {
    margin-top: 16px;
}

.validation-error {
    padding: 10px 14px;
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid #ef4444;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.validation-warning {
    padding: 10px 14px;
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.validation-success {
    padding: 10px 14px;
    background: rgba(34, 197, 94, 0.08);
    border-left: 3px solid #22c55e;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* Loading */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.error-box {
    padding: 16px;
    background: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    border-radius: 10px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .scenario-cards, .scenario-grid { grid-template-columns: 1fr; }
    .domain-label { width: 100px; font-size: 0.7rem; }
    .charger-row { flex-wrap: wrap; }
    .schema-toolbar { justify-content: center; }
    #schema-canvas { width: 100%; height: 350px; }
}
