/* ==========================================================================
   Widget · Entraînez votre propre IA
   LCA-Book · Design System
   ========================================================================== */

.ai-trainer-widget {
  --ait-accent: #4f46e5;
  --ait-train: #2563eb;
  --ait-test: #dc2626;
  --ait-success: #16a34a;
  --ait-success-bg: #f0fdf4;
  --ait-success-border: #bbf7d0;
  --ait-danger: #dc2626;
  --ait-danger-bg: #fef2f2;
  --ait-danger-border: #fecaca;
  --ait-warning: #d97706;
  --ait-warning-bg: #fffbeb;
  --ait-warning-border: #fde68a;
  --ait-card-bg: #ffffff;
  --ait-border: #e2e8f0;
  --ait-text-main: #0f172a;
  --ait-text-muted: #64748b;

  font-family: inherit;
  margin: 0.25rem 0 0 0;
  padding: 0;
  background: transparent;
  border: none;
  box-sizing: border-box;
  color: var(--ait-text-main);
}

.ai-trainer-intro {
  margin: 0 0 1rem 0;
  line-height: 1.5;
  color: #334155;
  font-size: 0.92rem;
}

/* 1. Barre d'action supérieure (Boutons scénarios) */
.ai-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ai-action-btn {
  background: var(--ait-card-bg);
  border: 1px solid var(--ait-border);
  border-radius: 6px;
  padding: 0.42rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.ai-action-btn:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: var(--ait-text-main);
}

.ai-action-btn.btn-mean {
  background: #f8fafc;
  color: #475569;
  border-color: #cbd5e1;
}

.ai-action-btn.btn-mean:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.ai-action-btn.btn-mean.active {
  background: #f1f5f9;
  border-color: #64748b;
  color: #0f172a;
  font-weight: 700;
}

.ai-action-btn.btn-auto {
  background: #4f46e5;
  color: #ffffff;
  border-color: #4338ca;
  font-weight: 700;
}

.ai-action-btn.btn-auto:hover {
  background: #4338ca;
}

.ai-action-btn.btn-overfit {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
  font-weight: 700;
}

.ai-action-btn.btn-overfit:hover {
  background: #ffe4e6;
}

.ai-action-btn.btn-overfit.active {
  background: #e11d48;
  color: #ffffff;
  border-color: #be123c;
}

.ai-action-btn.btn-test.active {
  background: #fee2e2;
  color: #991b1b;
  border-color: #f87171;
}

.ai-action-btn.btn-reset {
  margin-left: auto;
  color: var(--ait-text-muted);
  font-weight: 500;
}

/* 2. Cadre du Graphique SVG */
.ai-graph-card {
  background: var(--ait-card-bg);
  border: 1px solid var(--ait-border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.ai-trainer-svg {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
}

/* Légende sous le graphique */
.ai-graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.82rem;
}

.ai-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: #475569;
}

.ai-legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

.ai-legend-dot.train {
  background: var(--ait-train);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.ai-legend-dot.test {
  background: var(--ait-test);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25);
}

.ai-legend-line {
  width: 22px;
  height: 3px;
  border-radius: 2px;
  display: inline-block;
}

.ai-legend-line.model {
  background: var(--ait-accent);
}

/* 3. Ligne des Métriques (Zéro caps lock) */
.ai-metrics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}

@media (max-width: 640px) {
  .ai-metrics-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ai-metric-panel {
  background: var(--ait-card-bg);
  border: 1px solid var(--ait-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.ai-metric-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.ai-metric-value-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.ai-metric-num {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ait-text-main);
  white-space: nowrap;
}

.ai-metric-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 100%;
}

.ai-badge-good {
  background: #dcfce7;
  color: #15803d;
}

.ai-badge-warning {
  background: #fef3c7;
  color: #b45309;
}

.ai-badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.ai-badge-neutral {
  background: #f1f5f9;
  color: #64748b;
}

.ai-metric-subtext {
  font-size: 0.76rem;
  color: var(--ait-text-muted);
  line-height: 1.3;
}

/* 4. Grille des 3 Curseurs manuels avec paramètres discrets (faded) */
.ai-sliders-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

@media (max-width: 780px) {
  .ai-sliders-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ai-slider-card {
  background: var(--ait-card-bg);
  border: 1px solid var(--ait-border);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.35rem;
}

.ai-slider-header-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.ai-slider-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1e293b;
}

.ai-slider-sub {
  font-size: 0.74rem;
  color: var(--ait-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.ai-faded-val {
  color: #94a3b8;
  font-size: 0.73rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.ai-slider-input {
  width: 100%;
  accent-color: var(--ait-accent);
  cursor: pointer;
  margin: 0.35rem 0 0.15rem 0;
}

/* 5. Bannière d'alerte explicative dynamique */
.ai-status-banner {
  background: #ffffff;
  border-left: 4px solid #3b82f6;
  border-top: 1px solid var(--ait-border);
  border-right: 1px solid var(--ait-border);
  border-bottom: 1px solid var(--ait-border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  margin-bottom: 1rem;
}

.ai-status-icon {
  font-size: 1.35rem;
  flex-shrink: 0;
}

.ai-status-text {
  color: #334155;
}

/* 6. Section des 3 Leçons clés (Takeaways) */
.ai-takeaways-box {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ait-border);
}

.ai-takeaways-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 0.75rem 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ai-takeaways-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (max-width: 780px) {
  .ai-takeaways-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.ai-takeaway-card {
  background: var(--ait-card-bg);
  border: 1px solid var(--ait-border);
  border-radius: 8px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.ai-takeaway-header {
  font-size: 0.82rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.ai-takeaway-text {
  font-size: 0.78rem;
  color: var(--ait-text-muted);
  line-height: 1.4;
  margin: 0;
}
