/* ==========================================================
   13 - Wizard de creation d'operation (refonte 2026-09-29)
   Tout est scope sur #editPanel.wizard-mode : le formulaire
   d'edition d'une operation existante n'est pas touche.
   Retour a l'ancien design : supprimer ce fichier
   (sauvegarde dans backup_20260929_wizard_creation/).
   ========================================================== */

/* --- Modale : un peu plus large, en-tete blanc avec sous-titre --- */
#editModal:has(#editPanel.wizard-mode) .modal-panel { width: 760px; }

#editModal:has(#editPanel.wizard-mode) .modal-topbar {
  background: var(--surface);
  border-bottom: none;
  padding: 24px 28px 4px;
  align-items: flex-start;
}
#editModal:has(#editPanel.wizard-mode) .modal-topbar-title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
#editModal:has(#editPanel.wizard-mode) .modal-topbar-title::after {
  content: 'Planifiez une nouvelle opération commerciale en trois étapes.';
  display: block;
  margin-top: 4px;
  font-family: var(--sf);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--t3);
}

/* --- Stepper : trois etapes + barre de progression continue --- */
#editPanel.wizard-mode .wizard-indicator {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px 28px 20px;
  border-bottom: 1px solid var(--border);
}
#editPanel.wizard-mode .wizard-indicator::before,
#editPanel.wizard-mode .wizard-indicator::after {
  content: '';
  position: absolute;
  left: 28px;
  bottom: -1px;
  height: 3px;
  border-radius: 3px;
}
#editPanel.wizard-mode .wizard-indicator::before { right: 28px; background: var(--surface-3); }
#editPanel.wizard-mode .wizard-indicator::after {
  width: calc((100% - 56px) / 3);
  background: var(--blue);
  transition: width 0.45s var(--ease-out);
}
#editPanel.wizard-mode[data-step="2"] .wizard-indicator::after { width: calc((100% - 56px) * 2 / 3); }
#editPanel.wizard-mode[data-step="3"] .wizard-indicator::after { width: calc(100% - 56px); }

#editPanel.wizard-mode .wizard-connector { display: none; }

#editPanel.wizard-mode .wizard-step-dot {
  flex-direction: row;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
#editPanel.wizard-mode .wdot {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border: none;
  background: var(--surface-3);
  color: var(--t3);
  font-size: 12.5px;
  position: relative;
}
#editPanel.wizard-mode .wizard-step-dot.active .wdot {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 0 0 4px var(--blue-soft), 0 4px 10px -3px rgba(43,82,224,0.5);
}
#editPanel.wizard-mode .wizard-step-dot.done .wdot {
  background: var(--green-soft);
  color: transparent;
}
#editPanel.wizard-mode .wizard-step-dot.done .wdot::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--green);
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 16px no-repeat;
}
#editPanel.wizard-mode .wtext { min-width: 0; }
#editPanel.wizard-mode .wlabel {
  font-family: var(--display);
  font-size: 13.5px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: -0.015em;
  color: var(--t3);
}
#editPanel.wizard-mode .wsub {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--t4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#editPanel.wizard-mode .wizard-step-dot.active .wlabel { color: var(--t1); }
#editPanel.wizard-mode .wizard-step-dot.done .wlabel   { color: var(--t2); }

/* --- Contenu : entree en fondu a chaque changement d'etape --- */
#editPanel.wizard-mode .edit-form { padding: 26px 28px 30px; scroll-behavior: smooth; }
#editPanel.wizard-mode .wizard-pane.active { animation: wizPaneIn 0.32s var(--ease-out); }
@keyframes wizPaneIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Titres de section : sobres, sans filet ni capitales */
#editPanel.wizard-mode .form-section-title {
  font-size: 15px;
  font-weight: 650;
  text-transform: none;
  letter-spacing: -0.02em;
  color: var(--t1);
  margin: 30px 0 12px;
}
#editPanel.wizard-mode .form-section-title::after { display: none; }
#editPanel.wizard-mode .wizard-pane > .form-section-title:first-child { margin-top: 0; }

/* --- Champs --- */
#editPanel.wizard-mode .form-grid { gap: 16px 18px; }
#editPanel.wizard-mode .form-field { gap: 7px; }
#editPanel.wizard-mode .form-field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--t2);
}
#editPanel.wizard-mode .form-field input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
#editPanel.wizard-mode .form-field select,
#editPanel.wizard-mode .form-field textarea {
  min-height: 46px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(28,25,20,0.04);
}
#editPanel.wizard-mode .form-field input:hover,
#editPanel.wizard-mode .form-field select:hover,
#editPanel.wizard-mode .form-field textarea:hover { border-color: var(--border-3); }
#editPanel.wizard-mode .form-field input:focus,
#editPanel.wizard-mode .form-field select:focus,
#editPanel.wizard-mode .form-field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}
#editPanel.wizard-mode .form-field input::placeholder,
#editPanel.wizard-mode .form-field textarea::placeholder { color: var(--t4); }
#editPanel.wizard-mode .form-field textarea { min-height: 96px; }

/* Nom de l'operation : champ principal, plus grand */
#editPanel.wizard-mode #wizNameInput {
  min-height: 52px;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
/* Erreur : bordure rouge + message avec icone */
#editPanel.wizard-mode .form-field:has(#wizNameError[style*="block"]) #wizNameInput {
  border-color: var(--red);
  box-shadow: 0 0 0 4px var(--red-soft);
}
#editPanel.wizard-mode #wizNameError {
  display: flex;
  align-items: center;
  gap: 6px;
  animation: wizShake 0.36s ease;
}
#editPanel.wizard-mode #wizNameError::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}
@keyframes wizShake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* --- Enseignes : tuiles avec logo --- */
#editPanel.wizard-mode .form-enseignes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
#editPanel.wizard-mode .enseigne-check {
  position: relative;
  gap: 12px;
  padding: 12px 44px 12px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 14px;
  color: var(--t1);
  box-shadow: 0 1px 2px rgba(28,25,20,0.04);
  transition: border-color .18s, box-shadow .18s, transform .12s;
}
#editPanel.wizard-mode .enseigne-check:hover { border-color: var(--border-3); background: var(--surface); }
#editPanel.wizard-mode .enseigne-check:active { transform: scale(0.985); }
/* case a cocher ronde, a droite */
#editPanel.wizard-mode .enseigne-check::before {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border-radius: 50%;
}
#editPanel.wizard-mode .enseigne-check.checked {
  border-color: var(--blue);
  background: var(--surface);
  color: var(--t1);
  box-shadow: 0 0 0 3px var(--blue-soft);
}
#editPanel.wizard-mode .enseigne-check.checked::before { background-size: 11px 9px; }

#editPanel.wizard-mode .ens-logo {
  width: 72px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--ens-bg) var(--ens-img) center / 80% auto no-repeat;
}
#editPanel.wizard-mode .ens-logo-moto_axxe { --ens-bg: #ff4500; --ens-img: url('../../images/logo-moto-axxe-blanc.png'); }
#editPanel.wizard-mode .ens-logo-maxxess   { --ens-bg: #ffed00; --ens-img: url('../../images/logo-maxxess-noir.png'); }

/* --- Statut : controle segmente --- */
#editPanel.wizard-mode .form-statut {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-3);
  border-radius: var(--r-full);
}
#editPanel.wizard-mode .statut-check {
  justify-content: center;
  padding: 9px 20px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--t3);
  transition: background .2s, color .2s, box-shadow .2s;
}
#editPanel.wizard-mode .statut-check:hover { background: rgba(255,255,255,0.55); color: var(--t1); }
#editPanel.wizard-mode .statut-check.statut-active {
  background: var(--surface);
  color: var(--orange);
  box-shadow: 0 1px 2px rgba(28,25,20,0.08), 0 4px 12px -4px rgba(28,25,20,0.18);
}
#editPanel.wizard-mode .statut-check.statut-active:has(input[value="validee"]) { color: var(--green); }

/* --- Editeur riche : un seul bloc arrondi --- */
#editPanel.wizard-mode .rich-toolbar {
  background: var(--surface-2);
  border-color: var(--border-2);
  border-radius: 12px 12px 0 0;
  padding: 6px 8px;
}
#editPanel.wizard-mode .rich-editor {
  min-height: 120px;
  padding: 12px 14px;
  font-size: 14px;
  border-color: var(--border-2);
  border-radius: 0 0 12px 12px;
}
#editPanel.wizard-mode .rich-editor:focus { box-shadow: 0 0 0 4px var(--blue-soft); }

/* --- Upload : zone de depot --- */
#editPanel.wizard-mode .form-file-input {
  padding: 22px 16px;
  text-align: center;
  border: 1.5px dashed var(--border-3);
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 13px;
}
#editPanel.wizard-mode .form-file-input::file-selector-button {
  margin-right: 12px;
  padding: 8px 16px;
  border: 1px solid var(--border-2);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--t1);
  font: 600 12.5px var(--sf);
  cursor: pointer;
  transition: border-color .18s, background .18s;
}
#editPanel.wizard-mode .form-file-input:hover::file-selector-button { border-color: var(--blue); color: var(--blue); }
#editPanel.wizard-mode .form-image-preview { border-radius: 14px; }

/* --- Barre de navigation --- */
#editPanel.wizard-mode .wizard-nav {
  padding: 14px 28px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
#editPanel.wizard-mode .wiz-counter {
  font-size: 12.5px;
  color: var(--t3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#editPanel.wizard-mode .wiz-counter b { color: var(--t1); font-weight: 700; }
#editPanel.wizard-mode .wizard-nav .btn {
  min-height: 44px;
  border-radius: 12px;
  font-size: 13.5px;
}
#editPanel.wizard-mode .wiz-nav-btn { min-width: 150px; }
#editPanel.wizard-mode #wizNext,
#editPanel.wizard-mode #wizSave { padding: 0 24px; }

/* ==========================================================
   Mobile
   ========================================================== */
@media (max-width: 639px) {
  #editModal:has(#editPanel.wizard-mode) .modal-topbar { padding: 18px 16px 2px; }
  #editModal:has(#editPanel.wizard-mode) .modal-topbar-title { font-size: 18px; }
  #editModal:has(#editPanel.wizard-mode) .modal-topbar-title::after { font-size: 12.5px; }

  #editPanel.wizard-mode .wizard-indicator { padding: 14px 16px 16px; gap: 6px; }
  #editPanel.wizard-mode .wizard-indicator::before { left: 16px; right: 16px; }
  #editPanel.wizard-mode .wizard-indicator::after { left: 16px; width: calc((100% - 32px) / 3); }
  #editPanel.wizard-mode[data-step="2"] .wizard-indicator::after { width: calc((100% - 32px) * 2 / 3); }
  #editPanel.wizard-mode[data-step="3"] .wizard-indicator::after { width: calc(100% - 32px); }
  #editPanel.wizard-mode .wizard-step-dot { gap: 7px; }
  #editPanel.wizard-mode .wdot { width: 26px; height: 26px; font-size: 11.5px; }
  #editPanel.wizard-mode .wlabel { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #editPanel.wizard-mode .wsub { display: none; }

  #editPanel.wizard-mode .edit-form { padding: 20px 16px 24px; }
  #editPanel.wizard-mode .form-enseignes { grid-template-columns: 1fr; }
  #editPanel.wizard-mode .form-statut { display: grid; }
  #editPanel.wizard-mode .form-field input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
  #editPanel.wizard-mode .form-field select,
  #editPanel.wizard-mode .form-field textarea { font-size: 16px; }

  #editPanel.wizard-mode .wizard-nav { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  #editPanel.wizard-mode .wiz-counter { display: none; }
  #editPanel.wizard-mode .wiz-nav-btn { min-width: 0; flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #editPanel.wizard-mode .wizard-pane.active,
  #editPanel.wizard-mode #wizNameError { animation: none; }
}
