/* =====================================================================
   ECNA — Arbre de décision v3.0.0
   Feuille de style

   SYSTÈME DE THÈMES
   Le thème est contrôlé par l'attribut data-theme sur les conteneurs.
   Les variables CSS sont définies sur .decision-tree et .dt-contact,
   ce qui évite toute fuite vers le reste du site.

   [data-theme="light"]  → thème clair forcé
   [data-theme="dark"]   → thème sombre forcé
   [data-theme="auto"]   → suit prefers-color-scheme (comportement par défaut)
===================================================================== */


/* =====================================================================
   VARIABLES — Thème clair (défaut)
===================================================================== */

.decision-tree,
.dt-contact {
  --dt-text-primary:   #1e245c;
  --dt-text-secondary: #5c6b82;
  --dt-surface:        #ffffff;
  --dt-surface-subtle: #f9faff;
  --dt-border:         rgba(30, 36, 92, 0.15);
  --dt-border-hover:   rgba(30, 36, 92, 0.30);
  --dt-border-light:   #e0e5ed;
  --dt-shadow-sm:      rgba(20, 30, 60, 0.06);
  --dt-shadow-base:    rgba(20, 30, 60, 0.08);
  --dt-shadow-md:      rgba(20, 30, 60, 0.12);
  --dt-shadow-lg:      rgba(20, 30, 60, 0.14);
  --dt-shadow-xl:      rgba(20, 30, 60, 0.25);
  --dt-accent:         #3da5f4;
  --dt-accent-bg:      rgba(61, 165, 244, 0.12);
  --dt-accent-border:  rgba(61, 165, 244, 0.20);
  --dt-question-color: #1e245c;
}


/* =====================================================================
   VARIABLES — Thème sombre forcé
===================================================================== */

.decision-tree[data-theme="dark"],
.dt-contact[data-theme="dark"] {
  --dt-text-primary:   #dde3f5;
  --dt-text-secondary: #8a97b4;
  --dt-surface:        #1e253a;
  --dt-surface-subtle: #161d30;
  --dt-border:         rgba(255, 255, 255, 0.10);
  --dt-border-hover:   rgba(255, 255, 255, 0.20);
  --dt-border-light:   #2a3550;
  --dt-shadow-sm:      rgba(0, 5, 20, 0.20);
  --dt-shadow-base:    rgba(0, 5, 20, 0.25);
  --dt-shadow-md:      rgba(0, 5, 20, 0.35);
  --dt-shadow-lg:      rgba(0, 5, 20, 0.40);
  --dt-shadow-xl:      rgba(0, 5, 20, 0.50);
  --dt-accent:         #5ab8ff;
  --dt-accent-bg:      rgba(90, 184, 255, 0.12);
  --dt-accent-border:  rgba(90, 184, 255, 0.25);
  --dt-question-color: #ffffff;
}


/* =====================================================================
   VARIABLES — Thème automatique (suit prefers-color-scheme)
===================================================================== */

@media (prefers-color-scheme: dark) {
  .decision-tree[data-theme="auto"],
  .dt-contact[data-theme="auto"] {
    --dt-text-primary:   #dde3f5;
    --dt-text-secondary: #8a97b4;
    --dt-surface:        #1e253a;
    --dt-surface-subtle: #161d30;
    --dt-border:         rgba(255, 255, 255, 0.10);
    --dt-border-hover:   rgba(255, 255, 255, 0.20);
    --dt-border-light:   #2a3550;
    --dt-shadow-sm:      rgba(0, 5, 20, 0.20);
    --dt-shadow-base:    rgba(0, 5, 20, 0.25);
    --dt-shadow-md:      rgba(0, 5, 20, 0.35);
    --dt-shadow-lg:      rgba(0, 5, 20, 0.40);
    --dt-shadow-xl:      rgba(0, 5, 20, 0.50);
    --dt-accent:         #5ab8ff;
    --dt-accent-bg:      rgba(90, 184, 255, 0.12);
    --dt-accent-border:  rgba(90, 184, 255, 0.25);
    --dt-question-color: #ffffff;
  }
}


/* =====================================================================
   ANIMATIONS
===================================================================== */

/* Entrée du widget au chargement d'une étape */
@keyframes fadeStep {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Entrée des éléments de l'historique */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Entrée du formulaire */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* =====================================================================
   CONTENEUR PRINCIPAL
===================================================================== */

#decision-tree {
  margin: 0 auto;
  padding: 20px;
  animation: fadeStep 0.5s ease both;
}


/* =====================================================================
   EN-TÊTE — QUESTION
===================================================================== */

.dt-header {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

#decision-tree .dt-question {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.25;
  color: var(--dt-question-color);
  text-align: center;
}


/* =====================================================================
   ZONE DE CONTENU (grille 2 colonnes)
===================================================================== */

#decision-tree .dt-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 1024px) {
  #decision-tree .dt-content {
    grid-template-columns: 1fr;
  }
}


/* =====================================================================
   BOUTONS — OPTIONS (questions intermédiaires)
===================================================================== */

#decision-tree .dt-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  padding: 26px 28px;
  min-height: 84px;

  background: linear-gradient(135deg, var(--dt-surface), var(--dt-surface-subtle));
  border-radius: 20px;
  border: 1px solid var(--dt-border);
  border-left-width: 4px; /* réservé aux variantes colorées */

  box-shadow:
    0 8px 20px var(--dt-shadow-sm),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);

  font-size: 20px;
  font-weight: 600;
  color: var(--dt-text-primary);
  text-align: center;
  cursor: pointer;
  line-height: 1.35;
  white-space: normal;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
}

#decision-tree .dt-btn:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 45px var(--dt-shadow-md);
}

/* Variantes colorées des boutons (la couleur est passée via la classe JS) */
#decision-tree .dt-btn.orange { border-left-color: #f6a623; }
#decision-tree .dt-btn.vert   { border-left-color: #2ecc71; }
#decision-tree .dt-btn.rose   { border-left-color: #e05c8a; }
#decision-tree .dt-btn.gris   { border-left-color: #8a97b0; }

/* Bouton sans variante : bord transparent pour conserver l'alignement */
#decision-tree .dt-btn:not(.orange):not(.vert):not(.rose):not(.gris) {
  border-left-color: transparent;
}


/* =====================================================================
   CARTES — RÉSULTATS FINAUX
===================================================================== */

#decision-tree .dt-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
}

#decision-tree .dt-card-item {
  display: flex;
  gap: 18px;
  padding: 28px 30px;
  border-radius: 22px;
  background: var(--dt-surface);
  border: 1px solid var(--dt-border);
  box-shadow: 0 10px 30px var(--dt-shadow-base);
  text-decoration: none;
  color: var(--dt-text-primary);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#decision-tree .dt-card-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 45px var(--dt-shadow-lg);
}

#decision-tree .dt-card-item h4 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 8px;
}

#decision-tree .dt-card-item p {
  font-size: 15px;
  line-height: 1.5;
  color: var(--dt-text-secondary);
  margin: 0;
}

/* Icône ronde */
#decision-tree .dt-card-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--dt-accent-bg);
  color: var(--dt-accent);
}

#decision-tree .dt-card-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Variantes colorées des cartes */
#decision-tree .dt-card-item.orange h4,
#decision-tree .dt-card-item.orange .dt-card-icon { color: #f6a623; }
#decision-tree .dt-card-item.orange .dt-card-icon  { background: rgba(246, 166, 35, 0.12); }

#decision-tree .dt-card-item.vert h4,
#decision-tree .dt-card-item.vert .dt-card-icon    { color: #2ecc71; }
#decision-tree .dt-card-item.vert .dt-card-icon    { background: rgba(46, 204, 113, 0.12); }

#decision-tree .dt-card-item.bleu h4,
#decision-tree .dt-card-item.bleu .dt-card-icon    { color: var(--dt-accent); }
#decision-tree .dt-card-item.bleu .dt-card-icon    { background: var(--dt-accent-bg); }

#decision-tree .dt-card-item.gris h4,
#decision-tree .dt-card-item.gris .dt-card-icon    { color: #8a97b0; }
#decision-tree .dt-card-item.gris .dt-card-icon    { background: rgba(138, 151, 176, 0.12); }


/* =====================================================================
   PIED — BOUTONS RETOUR & RÉINITIALISER
===================================================================== */

.dt-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.dt-back-btn,
.dt-reset-btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--dt-border);
  background: var(--dt-surface);
  color: var(--dt-text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.dt-back-btn:hover,
.dt-reset-btn:hover {
  background: var(--dt-surface-subtle);
  border-color: var(--dt-border-hover);
  color: var(--dt-text-primary);
}


/* =====================================================================
   HISTORIQUE DES CHOIX (affiché au-dessus de la question)
===================================================================== */

.dt-history-wrapper {
  width: 100%;
  margin-bottom: 24px;
}

.dt-choices-history {
  width: 100%;
  padding: 24px;
  background: linear-gradient(135deg, var(--dt-surface-subtle), var(--dt-surface));
  border-radius: 16px;
  border: 2px solid var(--dt-accent-border);
  box-shadow: 0 4px 12px var(--dt-shadow-sm);
}

.dt-choices-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--dt-text-primary);
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--dt-accent-border);
}

.dt-choices-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dt-choice-item {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: var(--dt-surface);
  border-radius: 12px;
  border: 1px solid var(--dt-border-light);
  animation: slideInRight 0.3s ease both;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.dt-choice-item:hover {
  border-color: var(--dt-accent);
  box-shadow: 0 4px 12px var(--dt-accent-bg);
  transform: translateX(4px);
}

/* Décalage d'animation pour chaque ligne */
.dt-choice-item:nth-child(1) { animation-delay: 0.00s; }
.dt-choice-item:nth-child(2) { animation-delay: 0.05s; }
.dt-choice-item:nth-child(3) { animation-delay: 0.10s; }
.dt-choice-item:nth-child(4) { animation-delay: 0.15s; }
.dt-choice-item:nth-child(5) { animation-delay: 0.20s; }
.dt-choice-item:nth-child(6) { animation-delay: 0.25s; }
.dt-choice-item:nth-child(7) { animation-delay: 0.30s; }

.dt-choice-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--dt-accent), #2e8dd6);
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.dt-choice-content {
  flex: 1;
}

.dt-choice-question {
  font-size: 14px;
  font-weight: 600;
  color: var(--dt-text-primary);
  margin-bottom: 4px;
  line-height: 1.4;
}

.dt-choice-answer {
  font-size: 13px;
  font-weight: 600;
  color: var(--dt-accent);
  line-height: 1.4;
}


/* =====================================================================
   FORMULAIRE DE CONTACT
===================================================================== */

.dt-contact {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px;
  background: var(--dt-surface);
  border-radius: 20px;
  box-shadow: 0 25px 60px var(--dt-shadow-xl);
  animation: fadeUp 0.4s ease;
}

.dt-contact.is-hidden {
  display: none;
}

.dt-contact-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--dt-text-primary);
  margin: 0 0 12px;
  text-align: center;
}

.dt-contact-subtitle {
  font-size: 16px;
  color: var(--dt-text-secondary);
  margin: 0 0 24px;
  text-align: center;
}

/* Historique des choix dans le formulaire */
.dt-form-history {
  margin-bottom: 24px;
}

.dt-form-history .dt-choices-history {
  background: var(--dt-accent-bg);
  border-color: var(--dt-accent-border);
}

/* Champ caché GF — toujours masqué */
#input_1_6[type="hidden"] {
  display: none !important;
}


/* =====================================================================
   RESPONSIVE
===================================================================== */

@media (max-width: 768px) {
  #decision-tree .dt-question {
    font-size: 24px;
  }

  #decision-tree .dt-btn {
    font-size: 17px;
    padding: 20px 20px;
    min-height: 70px;
  }

  .dt-choices-history {
    padding: 16px;
  }

  .dt-choices-title {
    font-size: 16px;
  }

  .dt-choice-item {
    padding: 10px 12px;
  }

  .dt-choice-question {
    font-size: 13px;
  }

  .dt-choice-answer {
    font-size: 12px;
  }

  .dt-choice-number {
    min-width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .dt-contact {
    padding: 24px 16px;
  }

  .dt-contact-title {
    font-size: 22px;
  }
}
