/* ==========================================================
   B'Expert SAV — Parcours diagnostic v2
   Design system dédié (chargé après style.css / touch.css).
   Préfixe : dg- pour les nouveaux blocs, overrides ciblés sinon.
   ========================================================== */

:root {
  --dg-orange: #fc5201;
  --dg-orange-dark: #d34401;
  --dg-orange-soft: rgba(252, 82, 1, .08);
  --dg-green: #1a9e4d;
  --dg-green-soft: rgba(26, 158, 77, .08);
  --dg-red: #d13c1f;
  --dg-red-soft: rgba(209, 60, 31, .07);
  --dg-ink: #141417;
  --dg-muted: #6b7280;
  --dg-line: #e6e8ec;
  --dg-card: #ffffff;
  --dg-wash: #f4f5f7;
  --dg-radius: 18px;
  --dg-shadow: 0 10px 30px rgba(16, 16, 20, .08);
  --dg-font: 'Inter', 'Segoe UI', Roboto, Arial, sans-serif;
}

.page-content main {
  font-family: var(--dg-font);
  max-width: 1020px;
}

/* ---------- Stepper ---------- */
.dg-stepper {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0 0 22px;
  padding: 16px 18px;
  background: var(--dg-card);
  border: 1px solid var(--dg-line);
  border-radius: var(--dg-radius);
  overflow-x: auto;
}

.dg-stepper li {
  flex: 1 1 0;
  min-width: 120px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 12px;
  color: var(--dg-muted);
}

.dg-step-dot {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--dg-wash);
  border: 1px solid var(--dg-line);
  color: var(--dg-muted);
}

.dg-step-label {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
}

.dg-stepper li.is-done .dg-step-dot {
  background: var(--dg-green);
  border-color: var(--dg-green);
  color: #fff;
}

.dg-stepper li.is-done .dg-step-label {
  color: var(--dg-ink);
}

.dg-stepper li.is-current {
  background: var(--dg-orange-soft);
}

.dg-stepper li.is-current .dg-step-dot {
  background: var(--dg-orange);
  border-color: var(--dg-orange);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(252, 82, 1, .15);
}

.dg-stepper li.is-current .dg-step-label {
  color: var(--dg-ink);
}

/* Ancien fil d'ariane : conservé pour le JS, masqué visuellement */
.breadcrumb {
  display: none;
}

/* ---------- En-têtes d'étape ---------- */
.dg-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--dg-orange);
  margin-bottom: 6px;
}

.dg-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  margin: 0 0 6px;
  color: var(--dg-ink);
}

.dg-sub {
  font-size: 14px;
  color: var(--dg-muted);
  margin: 0 0 20px;
  line-height: 1.55;
  max-width: 640px;
}

/* Les titres injectés par le JS héritent du nouveau style */
.panel-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.4px;
}

/* ---------- Catégories : segmented control ---------- */
.cat-tabs {
  background: var(--dg-card);
  border: 1px solid var(--dg-line);
  border-radius: 999px;
  padding: 5px;
  margin-bottom: 18px;
  max-width: 560px;
}

.cat-tab {
  border: none;
  background: transparent;
  border-radius: 999px;
  font-size: 14px;
  padding: 12px 10px;
}

.cat-tab.active {
  background: linear-gradient(135deg, #f37021 0%, #ff833e 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(243, 112, 33, .35);
}

/* ---------- Recherche ---------- */
.dg-search-wrap {
  position: relative;
  margin-bottom: 20px;
}

.dg-search-wrap::before {
  content: '🔍';
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  pointer-events: none;
}

.search-box {
  border-radius: 999px;
  padding: 16px 20px 16px 48px;
  font-size: 15.5px;
  border: 1.5px solid var(--dg-line);
  box-shadow: 0 2px 10px rgba(16, 16, 20, .04);
  margin-bottom: 0;
}

.search-box::placeholder {
  color: #9aa0ab;
}

/* ---------- Cartes familles / appareils ---------- */
.grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  border-radius: var(--dg-radius);
  border: 1.5px solid var(--dg-line);
  border-left: 1.5px solid var(--dg-line);
  padding: 18px;
  box-shadow: 0 2px 8px rgba(16, 16, 20, .04);
  animation: dg-rise .35s ease backwards;
}

.grid .card:nth-child(2) { animation-delay: .03s; }
.grid .card:nth-child(3) { animation-delay: .06s; }
.grid .card:nth-child(4) { animation-delay: .09s; }
.grid .card:nth-child(5) { animation-delay: .12s; }
.grid .card:nth-child(6) { animation-delay: .15s; }
.grid .card:nth-child(n+7) { animation-delay: .18s; }

@keyframes dg-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card:hover {
  border-color: var(--dg-orange);
  border-left-color: var(--dg-orange);
  transform: translateY(-3px);
  box-shadow: var(--dg-shadow);
}

.card-icon {
  width: 52px;
  height: 52px;
  font-size: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dg-orange-soft);
  border-radius: 15px;
}

.dg-card-body {
  flex: 1;
  min-width: 0;
}

.card h3 {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -.2px;
}

.dg-card-meta {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--dg-muted);
}

.dg-card-chevron {
  color: var(--dg-orange);
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

/* ---------- Symptômes ---------- */
.symptom-item {
  border-radius: 15px;
  border: 1.5px solid var(--dg-line);
  border-left: 1.5px solid var(--dg-line);
  padding: 16px 18px;
  gap: 14px;
  animation: dg-rise .3s ease backwards;
}

.symptom-item:hover {
  border-color: var(--dg-orange);
  border-left-color: var(--dg-orange);
  background: #fff;
  box-shadow: var(--dg-shadow);
  transform: translateX(3px);
}

.dg-sym-num {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 10px;
  background: var(--dg-orange-soft);
  color: var(--dg-orange-dark);
  font-size: 13.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.dark-mode .dg-sym-num {
  color: #ffb37e;
}

.symptom-item > span:nth-child(2) {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
}

/* ---------- Bloc IA : carte claire façon B'Desk ---------- */
.ai-box {
  background: var(--dg-card);
  border: 1.5px solid rgba(243, 112, 33, .35);
  border-radius: var(--dg-radius);
  padding: 20px 22px;
  margin-bottom: 22px;
  color: var(--dg-ink);
  box-shadow: var(--dg-shadow);
  position: relative;
  overflow: hidden;
}

.ai-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #f37021, #ff833e);
}

.ai-box-header {
  color: var(--dg-ink);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-box-header::before {
  content: '✨';
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--dg-orange-soft);
  font-size: 15px;
}

.ai-box-desc {
  color: var(--dg-muted);
  font-size: 13px;
  padding-left: 38px;
}

.ai-input-row {
  padding-left: 38px;
}

.ai-input-row input {
  border: 1.5px solid var(--dg-line);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
  background: var(--dg-wash);
  color: var(--dg-ink);
}

.ai-input-row input:focus {
  background: var(--dg-card);
}

#aiResult {
  padding-left: 38px;
}

.ai-input-row input {
  border: none;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 15px;
}

.ai-input-row .btn {
  border-radius: 12px;
  position: relative;
}

.ai-input-row .btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.ai-input-row .btn.is-loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: dg-spin .7s linear infinite;
}

@keyframes dg-spin {
  to { transform: rotate(360deg); }
}

#aiResult .ai-loading {
  color: var(--dg-muted);
}

#aiResult .ai-error {
  color: var(--dg-red);
  font-weight: 600;
}

#aiResult .ai-empty {
  color: var(--dg-muted);
}

/* ---------- Checklist : progression + sticky bar ---------- */
.dg-progress {
  background: var(--dg-card);
  border: 1px solid var(--dg-line);
  border-radius: 15px;
  padding: 14px 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.dg-progress-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--dg-wash);
  overflow: hidden;
}

.dg-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--dg-orange), #ff8a3d);
  transition: width .3s ease;
}

.dg-progress-fill.is-ready {
  background: linear-gradient(90deg, var(--dg-green), #3ddc74);
}

.dg-progress-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--dg-ink);
  white-space: nowrap;
}

.check-item {
  border-radius: 15px;
  border: 1.5px solid var(--dg-line);
}

.check-item .check-box {
  min-width: 30px;
  height: 30px;
  border-radius: 9px;
}

.check-label {
  font-size: 15px;
}

.dg-sticky-bar {
  position: sticky;
  bottom: 0;
  padding: 14px 0 8px;
  background: linear-gradient(transparent, var(--bg) 30%);
  z-index: 5;
}

.dg-sticky-bar .action-row {
  margin-top: 0;
  background: var(--dg-card);
  border: 1px solid var(--dg-line);
  border-radius: var(--dg-radius);
  padding: 12px;
  box-shadow: var(--dg-shadow);
}

.dg-sticky-bar .btn {
  border-radius: 12px;
  padding: 15px 22px;
  font-size: 15px;
}

/* ---------- Résultat ---------- */
.result-box {
  border-radius: 20px;
  padding: 28px;
  border: none;
  color: #fff;
  box-shadow: var(--dg-shadow);
}

.result-box.resolved {
  background: linear-gradient(135deg, #0d7a37, #1a9e4d 60%, #3ddc74);
}

.result-box.atelier {
  background: linear-gradient(135deg, #141417, #521f02 70%, var(--dg-orange));
}

.result-box.hors_garantie {
  background: linear-gradient(135deg, #141417, #4d0f02 70%, var(--dg-red));
}

.result-box h2 {
  color: #fff;
  font-size: 22px;
  letter-spacing: -.4px;
}

.result-box p {
  color: rgba(255, 255, 255, .85);
}

.result-box .cause {
  color: rgba(255, 255, 255, .75);
}

.result-badge {
  background: rgba(255, 255, 255, .2);
  backdrop-filter: blur(4px);
}

.result-badge.resolved,
.result-badge.atelier,
.result-badge.hors_garantie {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}

/* ---------- Skeletons ---------- */
.dg-skel {
  border-radius: var(--dg-radius);
  border: 1px solid var(--dg-line);
  background: var(--dg-card);
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
}

.dg-skel i {
  display: block;
  background: linear-gradient(90deg, #eceef1 25%, #f7f8fa 50%, #eceef1 75%);
  background-size: 200% 100%;
  animation: dg-shimmer 1.2s infinite;
  border-radius: 8px;
}

.dg-skel .sk-icon { width: 52px; height: 52px; border-radius: 15px; flex-shrink: 0; }
.dg-skel .sk-lines { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.dg-skel .sk-l1 { height: 14px; width: 70%; }
.dg-skel .sk-l2 { height: 11px; width: 45%; }

@keyframes dg-shimmer {
  to { background-position: -200% 0; }
}

/* ---------- Divers ---------- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--dg-card);
  border: 1px solid var(--dg-line);
  border-radius: 999px;
  padding: 10px 18px 10px 14px;
  color: var(--dg-ink);
  font-weight: 700;
}

.back-link:hover {
  text-decoration: none;
  border-color: var(--dg-orange);
  color: var(--dg-orange);
}

.empty-state {
  background: var(--dg-card);
  border: 1.5px dashed var(--dg-line);
  border-radius: var(--dg-radius);
  padding: 48px 24px;
  font-size: 14.5px;
}

.loading-state {
  font-size: 14px;
}

.step.active {
  animation: dg-step-in .3s ease;
}

@keyframes dg-step-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .dg-title { font-size: 22px; }
  .dg-stepper { padding: 10px 12px; }
  .dg-stepper li { min-width: 104px; }
  .dg-step-label { font-size: 11.5px; }
  .result-box { padding: 22px 18px; }
  .ai-box { padding: 18px 16px; }
}

/* ---------- Vérifications complémentaires IA (checklist) ---------- */
.ai-tests-box {
  background: var(--dg-card);
  border: 1.5px dashed rgba(243, 112, 33, .45);
  border-radius: var(--dg-radius);
  padding: 20px 22px;
  margin: 20px 0 6px;
}

.ai-tests-head {
  font-weight: 800;
  font-size: 15px;
  color: var(--dg-ink);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.ai-tests-spark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--dg-orange-soft);
  font-size: 15px;
}

.ai-tests-desc {
  font-size: 13px;
  color: var(--dg-muted);
  margin: 0 0 14px 38px;
}

.ai-tests-box .btn {
  margin-left: 38px;
  position: relative;
}

.ai-tests-box .btn.is-loading {
  color: transparent;
  pointer-events: none;
}

.ai-tests-box .btn.is-loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: calc(50% - 10px);
  left: calc(50% - 10px);
  border: 2.5px solid rgba(243, 112, 33, .3);
  border-top-color: var(--dg-orange);
  border-radius: 50%;
  animation: dg-spin .7s linear infinite;
}

#aiTestsResult {
  margin: 12px 0 0 38px;
}

#aiTestsResult p {
  font-size: 13px;
  margin: 0;
  padding: 4px 0;
}

.ai-tests-loading { color: var(--dg-muted); }
.ai-tests-ok { color: var(--dg-green); font-weight: 700; }
.ai-tests-error { color: var(--dg-red); font-weight: 600; }
.ai-tests-empty { color: var(--dg-muted); font-style: italic; }

.check-item.ai-test {
  border-style: dashed;
  border-color: rgba(243, 112, 33, .5);
  background: var(--dg-orange-soft);
}

.ai-test-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--dg-orange);
  color: #fff;
  vertical-align: middle;
  margin-left: 6px;
  white-space: nowrap;
}

/* Consigne d'étape suivante sous le compte rendu (page résultat) */
.dg-next-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 14px 0 0;
  padding: 14px 16px;
  background: var(--dg-orange-soft);
  border: 1px solid rgba(243, 112, 33, .3);
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--dg-ink);
}

.dg-next-step span {
  font-size: 16px;
  line-height: 1.4;
}
