/* ============================================================================
   BRIQUE 9 : DIAGNOSTICS NEXOO (TRM / TCS / TAC / TCF + SUIVI COMPÉTITIONS)
   Dark Mode mobile-first (100dvh, champs 16px, zéro dépendance Wix)
   ============================================================================ */

.diag-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  background: #080e1c;
  color: #f8fafc;
  overscroll-behavior: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.diag-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* --- En-tête fixe --- */
.diag-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(17, 26, 46, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.diag-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.diag-back-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #18243f;
  color: #f8fafc;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.diag-back-btn:hover {
  background: #1f2e4f;
  border-color: rgba(57, 255, 20, 0.4);
}

.diag-header-titles {
  min-width: 0;
}

.diag-header-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diag-header-sub {
  margin: 2px 0 0;
  font-size: 0.76rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Zone scrollable principale --- */
.diag-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px 40px;
}

.diag-container {
  max-width: 920px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Bandeau résumé --- */
.diag-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.diag-summary-card {
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 10px;
  text-align: center;
}

.diag-summary-val {
  font-size: 1.25rem;
  font-weight: 800;
  color: #39ff14;
  line-height: 1.2;
}

.diag-summary-val.is-amber {
  color: #f59e0b;
}

.diag-summary-lbl {
  margin-top: 4px;
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.25;
}

/* --- Sous-onglets segmentés (Tests / Compétitions) --- */
.diag-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 5px;
}

.diag-tab-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: #94a3b8;
  border-radius: 10px;
  padding: 10px 8px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.18s ease, color 0.18s ease;
}

.diag-tab-btn.is-active {
  background: #18243f;
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(57, 255, 20, 0.35);
}

.diag-tab-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.diag-section-intro {
  margin: 0;
  font-size: 0.84rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* --- Grille des cartes --- */
.diag-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .diag-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.diag-card {
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.diag-card--pending {
  border-color: rgba(245, 158, 11, 0.55);
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.16);
}

.diag-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.diag-code-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: rgba(34, 197, 94, 0.14);
  color: #39ff14;
  border: 1px solid rgba(57, 255, 20, 0.3);
}

.diag-code-badge--eval {
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
}

.diag-duration-badge {
  font-size: 0.74rem;
  color: #94a3b8;
  font-weight: 600;
}

.diag-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.3;
}

.diag-card-desc {
  margin: 0;
  font-size: 0.84rem;
  color: #94a3b8;
  line-height: 1.45;
}

/* --- Bloc statut / dernier résultat sur la carte --- */
.diag-status-box {
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.diag-status-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.diag-status-score {
  font-size: 0.94rem;
  font-weight: 800;
  color: #f8fafc;
}

.diag-status-sub {
  font-size: 0.76rem;
  color: #94a3b8;
}

.diag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.diag-pill--low {
  background: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.diag-pill--mid {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.diag-pill--high {
  background: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.diag-pill--pending {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
  animation: diagPulse 2s ease-in-out infinite;
}

.diag-pill--empty {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

@keyframes diagPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
  }
}

/* --- Bouton module recommandé (deep-link interne) --- */
.diag-reco-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.28);
  border-radius: 12px;
  padding: 10px 12px;
  color: #f8fafc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.diag-reco-btn:hover {
  background: rgba(34, 197, 94, 0.16);
  border-color: rgba(57, 255, 20, 0.55);
}

.diag-reco-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.diag-reco-kicker {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4ade80;
}

.diag-reco-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.diag-reco-arrow {
  flex-shrink: 0;
  font-size: 1rem;
  color: #39ff14;
  font-weight: 800;
}

/* --- Actions de carte --- */
.diag-card-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.diag-btn-primary {
  appearance: none;
  flex: 1;
  min-width: 160px;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(135deg, #22c55e, #39ff14);
  color: #05130a;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s ease;
}

.diag-btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.diag-btn-primary:active:not(:disabled) {
  transform: scale(0.985);
}

.diag-btn-primary--amber {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #1c1002;
}

.diag-btn-primary:disabled {
  background: #18243f;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: not-allowed;
}

.diag-btn-secondary {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #18243f;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.diag-btn-secondary:hover {
  background: #1f2e4f;
  border-color: rgba(255, 255, 255, 0.28);
}

.diag-btn-ai {
  appearance: none;
  width: 100%;
  border: 1px solid rgba(57, 255, 20, 0.35);
  background: rgba(17, 26, 46, 0.9);
  color: #f8fafc;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.diag-btn-ai:hover {
  background: rgba(34, 197, 94, 0.14);
  border-color: #39ff14;
}

.diag-btn-danger-ghost {
  appearance: none;
  border: 1px solid rgba(239, 68, 68, 0.32);
  background: rgba(239, 68, 68, 0.08);
  color: #fca5a5;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.diag-btn-danger-ghost:hover {
  background: rgba(239, 68, 68, 0.18);
}

/* ============================================================================
   PARCOURS INTERACTIF (TESTS FONDAMENTAUX & ÉVALUATIONS COMPÉTITIVES)
   ============================================================================ */
.diag-wizard {
  max-width: 660px;
  width: 100%;
  margin: 0 auto;
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.diag-wizard-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diag-wizard-step {
  font-size: 0.8rem;
  font-weight: 700;
  color: #39ff14;
}

.diag-progress-track {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  background: #18243f;
  overflow: hidden;
}

.diag-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #39ff14);
  transition: width 0.25s ease;
}

.diag-wizard-title {
  margin: 0;
  font-size: 1.18rem;
  font-weight: 800;
  color: #f8fafc;
  line-height: 1.3;
}

.diag-wizard-sub {
  margin: 0;
  font-size: 0.88rem;
  color: #94a3b8;
  line-height: 1.5;
}

.diag-question-text {
  margin: 4px 0 0;
  font-size: 1.12rem;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.4;
}

/* --- Choix radio (Jamais / Parfois / Souvent / Toujours) --- */
.diag-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diag-option-btn {
  appearance: none;
  width: 100%;
  text-align: left;
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 16px;
  color: #f8fafc;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.diag-option-btn:hover {
  background: #1e2d4d;
  border-color: rgba(57, 255, 20, 0.35);
}

.diag-option-btn.is-selected {
  background: rgba(34, 197, 94, 0.16);
  border-color: #39ff14;
  color: #ffffff;
}

.diag-option-radio {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #64748b;
  flex-shrink: 0;
  position: relative;
}

.diag-option-btn.is-selected .diag-option-radio {
  border-color: #39ff14;
}

.diag-option-btn.is-selected .diag-option-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #39ff14;
}

/* --- Champs Compétition (Nom optionnel + Pastilles 1–10 + 5 Interrupteurs) --- */
.diag-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diag-field-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e2e8f0;
}

.diag-input {
  width: 100%;
  box-sizing: border-box;
  background: #080e1c;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  padding: 12px 14px;
  color: #f8fafc;
  font-size: 16px; /* Anti-zoom iOS obligatoire */
  outline: none;
  transition: border-color 0.15s ease;
}

.diag-input:focus {
  border-color: #39ff14;
}

.diag-phase1-recap {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.84rem;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.diag-phase1-recap strong {
  color: #38bdf8;
}

/* --- Échelle 1 à 10 (10 pastilles tactiles au pouce) --- */
.diag-scale-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

@media (min-width: 560px) {
  .diag-scale-grid {
    grid-template-columns: repeat(10, 1fr);
  }
}

.diag-scale-btn {
  appearance: none;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #18243f;
  color: #e2e8f0;
  font-size: 0.96rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.1s ease;
}

.diag-scale-btn:hover {
  border-color: rgba(57, 255, 20, 0.45);
}

.diag-scale-btn.is-selected {
  background: linear-gradient(135deg, #22c55e, #39ff14);
  border-color: #39ff14;
  color: #05130a;
  transform: scale(1.04);
}

.diag-scale-anchors {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #94a3b8;
}

/* --- Interrupteurs des 5 facteurs --- */
.diag-factors-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diag-factor-row {
  appearance: none;
  width: 100%;
  text-align: left;
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  color: #e2e8f0;
  font-size: 0.86rem;
  line-height: 1.35;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.diag-factor-row.is-on {
  border-color: rgba(57, 255, 20, 0.45);
  background: rgba(34, 197, 94, 0.1);
  color: #ffffff;
}

.diag-switch {
  flex-shrink: 0;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #080e1c;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.diag-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #94a3b8;
  transition: transform 0.18s ease, background 0.18s ease;
}

.diag-factor-row.is-on .diag-switch {
  background: rgba(34, 197, 94, 0.3);
  border-color: #39ff14;
}

.diag-factor-row.is-on .diag-switch::after {
  transform: translateX(20px);
  background: #39ff14;
}

.diag-wizard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 6px;
}

/* ============================================================================
   ÉCRAN RÉSULTAT (TEST OU ANALYSE DES ÉCARTS)
   ============================================================================ */
.diag-result-hero {
  background: #18243f;
  border: 1px solid rgba(57, 255, 20, 0.28);
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.diag-result-big {
  font-size: 2.3rem;
  font-weight: 900;
  color: #39ff14;
  line-height: 1.1;
}

.diag-result-metrics {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.diag-metric-cell {
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
}

.diag-metric-lbl {
  font-size: 0.72rem;
  color: #94a3b8;
}

.diag-metric-val {
  margin-top: 4px;
  font-size: 1.2rem;
  font-weight: 800;
  color: #f8fafc;
}

.diag-metric-val.is-pos {
  color: #4ade80;
}

.diag-metric-val.is-neg {
  color: #f87171;
}

.diag-interp-box {
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #f8fafc;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.diag-interp-box.is-alert {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.35);
}

/* ============================================================================
   VUE HISTORIQUE & COURBE D'ÉVOLUTION SVG
   ============================================================================ */
.diag-chart-card {
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px;
}

.diag-chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.diag-chart-legend {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 0.76rem;
  color: #94a3b8;
}

.diag-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.diag-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.diag-history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diag-history-item {
  background: #18243f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.diag-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.diag-history-date {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 600;
}

.diag-history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diag-tag {
  font-size: 0.72rem;
  color: #cbd5e1;
  background: rgba(8, 14, 28, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 3px 8px;
}

/* --- États chargement / erreur / toast --- */
.diag-state-box {
  background: #111a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 28px 18px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.92rem;
}

.diag-inline-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.84rem;
}