/* ============================================================
   TUNNEL FORMULAIRE DATE
   ============================================================ */

/* Modal en mode tunnel : hauteur fixe, layout flex colonne */
.modal-tunnel {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* En-tête avec barre de progression */
.tunnel-header {
  padding: 20px 28px 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.tunnel-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.tunnel-title-row h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tunnel-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* Barre de progression */
.fw-steps {
  display: flex;
  align-items: center;
  gap: 0;
  padding-bottom: 20px;
}
.fw-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: default;
  user-select: none;
}
.fw-step-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.fw-step-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  transition: color 0.2s;
  font-family: var(--font-mono);
}
.fw-step-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text3);
  white-space: nowrap;
  transition: color 0.2s;
}

/* Connecteur entre étapes */
.fw-step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  margin-bottom: 18px; /* aligner avec le centre des cercles */
  transition: background 0.25s;
}
.fw-step-connector.done { background: var(--primary); }
.fw-step-connector--opt { background: repeating-linear-gradient(90deg, var(--border) 0, var(--border) 4px, transparent 4px, transparent 8px); }

/* Étapes optionnelles (création uniquement) */
.fw-step--opt .fw-step-circle { border-style: dashed; opacity: 0.7; }
.fw-step--opt .fw-step-label  { opacity: 0.7; }
.fw-step--opt.active .fw-step-circle { opacity: 1; }
.fw-step--opt.active .fw-step-label  { opacity: 1; }
.fw-step--opt.done   .fw-step-circle { opacity: 1; }
.fw-step--opt.done   .fw-step-label  { opacity: 1; }
.fw-step-opt { font-size: 9px; color: var(--text3); font-weight: 400; letter-spacing: 0.02em; }

/* États des étapes */
.fw-step.active .fw-step-circle {
  background: var(--primary);
  border-color: var(--primary);
}
.fw-step.active .fw-step-num { color: #fff; }
.fw-step.active .fw-step-label { color: var(--primary); font-weight: 600; }

.fw-step.done .fw-step-circle {
  background: var(--primary);
  border-color: var(--primary);
}
.fw-step.done .fw-step-num { color: #fff; }
.fw-step.done .fw-step-num::before { content: '✓'; }
.fw-step.done .fw-step-num { font-size: 0; } /* masque le chiffre */
.fw-step.done .fw-step-num::before { font-size: 13px; }
.fw-step.done .fw-step-label { color: var(--primary); }

/* Corps du tunnel : scrollable, hauteur fixe */
.tunnel-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 16px;
  min-height: 0;
}

/* Intro de chaque étape */
.tunnel-step-intro {
  margin-bottom: 24px;
}
.tunnel-step-heading {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.tunnel-step-sub {
  font-size: 13px;
  color: var(--text3);
}

/* Récap compact */
.tunnel-recap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 4px;
  padding: 10px 28px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
  flex-shrink: 0;
}
.recap-sep {
  color: var(--border2);
  font-size: 11px;
  margin: 0 2px;
}
.recap-client {
  font-weight: 600;
  color: var(--text);
}
.recap-tarif {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text);
}
.recap-badge {
  font-size: 10px;
  padding: 2px 8px;
}
.recap-modif {
  font-size: 11px;
  color: var(--text3);
  font-style: italic;
  margin-left: auto;
}

/* Étapes cliquables en mode édition */
.modal-tunnel--edit .fw-step {
  cursor: pointer;
}
.modal-tunnel--edit .fw-step:hover .fw-step-circle {
  border-color: var(--primary);
}
.modal-tunnel--edit .fw-step:hover .fw-step-label {
  color: var(--text2);
}

/* Pied de page navigation */
.tunnel-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: var(--bg);
}
.tunnel-nav-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.tunnel-nav-actions .btn-ghost,
.tunnel-nav-actions .btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Pages du formulaire */
.fw-page { display: none; }
.fw-page.fw-page-active { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* Éléments qui doivent toujours occuper toute la largeur */
.fw-page.fw-page-active > .fw2-split,
.fw-page.fw-page-active > .tunnel-step-intro,
.fw-page.fw-page-active > [id$="-body"],
.fw-page.fw-page-active > .fw-full-row,
.fw-page.fw-page-active > .fw4-financier-row,
.fw-page.fw-page-active > .fw4-tarif-calc { grid-column: 1 / -1; }


/* ============================================================
   FICHE DÉTAIL — modal taille fixe + navigation tunnel
   ============================================================ */

/* Modal à hauteur fixe : ne change pas selon l'onglet */
.modal-fiche-fixed {
  height: min(88vh, 900px);
}
.modal-fiche-fixed .modal-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Footer de navigation entre onglets */
.fiche-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}
.fiche-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 7px 14px;
  min-width: 120px;
}
#fiche-btn-prev { justify-content: flex-start; }
#fiche-btn-next { justify-content: flex-end; }

/* Points de navigation (dots) */
.fiche-tab-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}
.fiche-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border2);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.fiche-dot:hover { background: var(--text3); transform: scale(1.2); }
.fiche-dot.active { background: var(--primary); transform: scale(1.25); }

/* Onglets de navigation (tabs) */
.fiche-tabs-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  gap: 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
  padding: 0 2px;
}


/* ============================================================
   IMPORT IA — Wizard
   ============================================================ */

.ia-wizard { display: flex; flex-direction: column; gap: 0; }

.ia-step-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 24px;
}

.ia-step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ia-step-title { font-size: 16px; font-weight: 600; color: var(--text1); }
.ia-step-desc  { font-size: 13px; color: var(--text3); margin-top: 2px; }

/* Upload zone */
.ia-upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.ia-upload-zone:hover,
.ia-upload-zone.ia-drag-over { border-color: var(--accent); background: var(--bg2); }
.ia-upload-zone.ia-has-file  { border-color: var(--green); border-style: solid; }

.ia-upload-icon { font-size: 36px; margin-bottom: 8px; }
.ia-upload-text { font-size: 14px; font-weight: 500; color: var(--text2); }
.ia-upload-hint { font-size: 12px; color: var(--text3); margin-top: 4px; }
.ia-file-name   { font-size: 13px; color: var(--accent); margin-top: 10px; font-weight: 500; }

/* Loading */
.ia-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  gap: 16px;
}

.ia-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ia-spin .8s linear infinite;
}

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

.ia-loading-title { font-size: 15px; font-weight: 600; color: var(--text1); }
.ia-loading-hint  { font-size: 13px; color: var(--text3); }

/* Questions */
.ia-questions { display: flex; flex-direction: column; gap: 16px; }

.ia-question-item {
  padding: 14px 16px;
  background: var(--bg2);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.ia-question-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text1);
  margin-bottom: 8px;
}
.ia-answer-field {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg0);
  color: var(--text1);
  resize: vertical;
}

/* Summary banner */
.ia-summary {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg2);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text2);
}
.ia-summary-icon { font-size: 18px; flex-shrink: 0; }

/* Preview rows */
.ia-row-off { opacity: .4; }
.ia-preview-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Mode tabs (dates / docs) */
.ia-mode-tabs { display: flex; gap: 6px; margin-top: 8px; }
.ia-mode-btn {
  padding: 5px 14px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  transition: all .15s;
}
.ia-mode-btn:hover { border-color: var(--accent); color: var(--accent); }
.ia-mode-btn.ia-mode-active { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }

/* Table docs mode pleine largeur */
.ia-docs-table-full { width: 100%; }
.ia-docs-matched td { background: color-mix(in srgb, var(--green) 5%, transparent); }

/* Done */
.ia-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
}
.ia-done-icon  { font-size: 48px; }
.ia-done-title { font-size: 20px; font-weight: 700; color: var(--text1); }
.ia-done-stats { font-size: 14px; color: var(--text2); display: flex; flex-direction: column; gap: 4px; }



/* ================================
   ÉDITEUR DE MODÈLE DE QUESTIONNAIRE
   ================================ */

/* --- WYSIWYG questionnaire editor --- */
.qwy-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  margin-bottom: 12px;
  overflow: hidden;
}
.qwy-section.qwy-dragging { opacity: .4; }
.qwy-section-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px 10px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
}
.qwy-section-head-text { flex: 1; min-width: 0; }
.qwy-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  outline: none;
  min-height: 1em;
  border-radius: 3px;
  padding: 1px 3px;
}
.qwy-section-title:empty::before { content: attr(data-ph); color: var(--text3); }
.qwy-section-title:focus { background: rgba(232,49,42,.08); }
.qwy-section-intro {
  font-size: 12px;
  color: var(--text3);
  outline: none;
  min-height: 1em;
  margin-top: 3px;
  border-radius: 3px;
  padding: 1px 3px;
}
.qwy-section-intro:empty::before { content: attr(data-ph); color: var(--border); font-style: italic; }
.qwy-section-intro:focus { background: var(--bg2); }
.qwy-del-section {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.qwy-del-section:hover { color: var(--accent); background: var(--accent-bg); }

.qwy-fields { padding: 8px 14px; display: flex; flex-direction: column; gap: 0; }

.qwy-field {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.qwy-field:last-child { border-bottom: none; }
.qwy-field.qwy-dragging { opacity: .4; }

.qwy-field-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.qwy-drag-handle {
  cursor: grab;
  color: var(--text3);
  font-size: 14px;
  flex-shrink: 0;
  padding: 2px;
  user-select: none;
}
.qwy-drag-handle:hover { color: var(--text2); }

.qwy-type-sel {
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text2);
  padding: 2px 5px;
  cursor: pointer;
}
.qwy-type-tag {
  font-size: 11px;
  background: rgba(124,58,237,.15);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,.3);
  border-radius: 4px;
  padding: 2px 7px;
}
.qwy-req-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  white-space: nowrap;
}
.qwy-req-toggle input { cursor: pointer; }
.qwy-del-field {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text3);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
}
.qwy-del-field:hover { color: var(--accent); background: var(--accent-bg); }

.qwy-label-edit {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  outline: none;
  min-height: 1em;
  margin-bottom: 5px;
  border-radius: 3px;
  padding: 1px 3px;
  cursor: text;
}
.qwy-label-edit:empty::before { content: attr(data-ph); color: var(--text3); font-style: italic; font-weight: 400; }
.qwy-label-edit:focus { background: var(--bg3); }

.qwy-input-preview {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text3);
  font-size: 13px;
  padding: 8px 10px;
  cursor: default;
  font-family: inherit;
}
textarea.qwy-input-preview { min-height: 60px; resize: none; }

.qwy-contact-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.qwy-contact-preview input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text3);
  font-size: 12px;
  padding: 6px 8px;
  width: 100%;
  cursor: default;
  font-family: inherit;
}

.qwy-ph-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}
.qwy-ph-lbl { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.qwy-ph-input {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 1px dashed var(--border);
  color: var(--text3);
  font-size: 12px;
  padding: 2px 4px;
  outline: none;
  font-family: inherit;
}
.qwy-ph-input:focus { border-bottom-color: var(--accent); color: var(--text1); }

.qwy-hint-edit {
  font-size: 11px;
  color: var(--text3);
  outline: none;
  min-height: 1em;
  margin-top: 4px;
  border-radius: 3px;
  padding: 1px 3px;
}
.qwy-hint-edit:empty::before { content: attr(data-ph); color: var(--border); font-style: italic; }
.qwy-hint-edit:focus { background: var(--bg3); }

.qwy-section-footer {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  flex-wrap: wrap;
}
.qwy-add-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text2);
  cursor: pointer;
}
.qwy-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.qwy-add-contact { color: #a78bfa; border-color: rgba(124,58,237,.3); }
.qwy-add-contact:hover { border-color: #a78bfa; color: #a78bfa; }

/* ─── Section bouton global "Ajouter une section" ─── */
#qwy-add-section-btn {
  width: 100%;
  padding: 10px;
  background: none;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text3);
  cursor: pointer;
  font-size: 12px;
  margin-top: 6px;
}
#qwy-add-section-btn:hover { border-color: var(--accent); color: var(--accent); }
/* ── fin WYSIWYG ── */

.qmodele-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.qmodele-card:hover { border-color: var(--accent); }
.qmodele-card.modele-card-over { box-shadow: 0 0 0 2px var(--accent); }
.qmodele-card--section {
  border-left: 3px solid var(--accent);
}

.qmodele-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  user-select: none;
}
.qmodele-card-header:active { cursor: grabbing; }
.qmodele-drag-handle {
  color: var(--text3);
  font-size: 13px;
  flex-shrink: 0;
}
.qmodele-drag-handle:hover { color: var(--text2); }

.qmodele-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qmodele-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.qmodele-badge-section {
  display: inline-block;
  background: rgba(232,49,42,0.15);
  color: var(--accent);
  border: 1px solid rgba(232,49,42,0.3);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  flex-shrink: 0;
}
.qmodele-card--contact { border-left: 3px solid var(--purple); }
.qmodele-badge-contact {
  display: inline-block;
  background: rgba(124,58,237,0.15);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  flex-shrink: 0;
}

.qmodele-field {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text1);
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.qmodele-field:focus { border-color: var(--accent); }
.qmodele-title  { font-weight: 600; }

.qmodele-type-sel {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text1);
  font-size: 13px;
  padding: 6px 8px;
  outline: none;
  flex-shrink: 0;
  cursor: pointer;
}
.qmodele-type-sel:focus { border-color: var(--accent); }

.qmodele-required-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.qmodele-required-cb { cursor: pointer; width: 14px; height: 14px; }

.qmodele-footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg3);
  flex-wrap: wrap;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .tunnel-header { padding: 14px 16px 0; }
  .tunnel-title-row { margin-bottom: 14px; gap: 8px; }
  .tunnel-title-row h2 { font-size: 15px; white-space: normal; }
  .tunnel-body { padding: 16px 16px 12px; }
  .tunnel-step-intro { margin-bottom: 16px; }
  .tunnel-step-heading { font-size: 16px; }

  /* Étapes : masquer les connecteurs, compacter */
  .fw-step-connector { display: none; }
  .fw-steps { gap: 2px; justify-content: center; }
  .fw-step { padding: 6px 8px 8px; }
  .fw-step-circle { width: 26px; height: 26px; }
  .fw-step-num { font-size: 12px; }
  .fw-step-label { font-size: 11px; }

  /* Recap bas */
  .tunnel-recap { padding: 10px 16px; font-size: 12px; }
  .tunnel-footer { padding: 12px 16px; gap: 8px; }
}
