/* ===== Tom Select =====
   Les champs à suggestions (région, produit) sont rendus par TomSelect, mais
   ils voisinent des <select> et des <input> classiques dans la même grille :
   leur contrôle doit donc être STRICTEMENT identique à .wizard-input — mêmes
   hauteur, police, fond, bordure et rayon. Toute évolution de .wizard-input
   doit être répercutée ici. */
.ts-control {
  width: 100%;
  background: #fff;
  color: var(--wz-text);
  padding: 0.85rem 1rem;
  border-radius: 0.65rem;
  border: 1.5px solid var(--wz-border);
  font-size: 0.95rem;
  line-height: 1.4;
  box-shadow: none;
  min-height: 0;
}
/* TomSelect recopie les classes du <select> d'origine sur son wrapper : celui-ci
   hérite donc de .wizard-input et dessinait un SECOND cadre autour du contrôle,
   rendant le champ nettement plus haut que ses voisins. Le wrapper ne doit être
   qu'un conteneur de positionnement. */
.ts-wrapper.wizard-input {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

/* TomSelect impose son padding droit via `max(...) !important` : on règle la
   variable qu'il utilise plutôt que de surenchérir en !important. 2.5rem, comme
   `select.wizard-input`, pour que le texte s'arrête avant le chevron. */
.ts-wrapper { --ts-pr-min: 2.5rem; }

/* Le texte saisi et l'option retenue héritent de la police du contrôle :
   sans cela TomSelect les rend en 13px là où le reste du formulaire est en
   0.95rem. */
.ts-control input,
.ts-control .item {
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}

/* Un libellé long ne doit pas faire grandir le champ : TomSelect met son
   contrôle en `flex-wrap: wrap`, si bien qu'un nom de produit un peu long
   passait à la ligne et le champ montait à ~72px face aux 50,5px de ses
   voisins. On garde une seule ligne et on coupe avec une ellipse.
   `min-width: 0` est indispensable : sans lui, un enfant flex refuse de
   rétrécir en dessous de la largeur de son contenu. */
.ts-control {
  flex-wrap: nowrap;
  overflow: hidden;
}
.ts-control > .item,
.ts-control > input {
  min-width: 0;
}
.ts-control > .item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ts-control input::placeholder { color: #9098A1; }

.ts-wrapper.focus .ts-control {
  border-color: var(--wz-blue);
  box-shadow: 0 0 0 3px rgba(43, 69, 216, .12);
}

.ts-dropdown {
  background: #fff;
  color: var(--wz-text);
  font-size: 0.95rem;
  border-radius: 0.65rem;
  margin-top: 0.4rem;
  box-shadow: 0 8px 24px rgba(16,24,40,.12);
  border: 1px solid #E7E9EC !important;
}
.ts-dropdown .option { padding: 0.5rem 1rem; cursor: pointer; }
.ts-dropdown .option:hover,
.ts-dropdown .option.active { background: #EEF1FF; }

/* ===== Design tokens ===== */
:root {
  --wz-navy: #0E3B63;
  --wz-blue: #2B45D8;
  --wz-blue-soft: #E9EFFF;
  --wz-bg: #F4F6F9;
  --wz-input-bg: #E6E8EB;
  --wz-text: #2B2E31;
  --wz-border: #E2E5EA;
  --wz-green: #1A9A57;
  --wz-green-soft: #E7F8EF;
  --wz-red: #CF193E;
  --wz-red-soft: #FCE9E9;
}

body.wizard-body { background: var(--wz-bg); margin: 0; }

/*
 * IMPORTANT : le style.css global de l'app (public/input.css) définit des règles
 * bas niveau sur les éléments nus (span{color:#C3C7CB}, etc.) chargées avant ce fichier.
 * Une règle directe sur un élément (même simple `span{}`) gagne toujours sur une
 * couleur seulement HÉRITÉE d'un parent, quelle que soit la spécificité — d'où les
 * `color: inherit` explicites ci-dessous pour les <span> "nus" de ce thème.
 */
.pf-option > span,
.chip-option > span,
.step-pill > span:not(.pill-circle),
.gps-box > span:not(.wizard-hint) { color: inherit; font-size: inherit; }

/* ===== Header ===== */
.wizard-header { background: var(--wz-navy); color: #fff; padding: 1rem 1.25rem; }
.wizard-header-inner { max-width: 980px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.wizard-logo { height: 3.5rem; background: #fff; border-radius: 0.6rem; padding: 0.3rem 0.6rem; display: block; object-fit: contain; }
.wizard-header-right { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.wizard-header-item { text-align: left; }
.wizard-header-label { display: block; font-size: 0.7rem; color: #B7C3D6; }
.wizard-header-value { display: block; font-weight: 700; font-size: 0.95rem; color: #fff; }
.wizard-avatar { width: 2.6rem; height: 2.6rem; border-radius: 9999px; background: var(--wz-blue-soft); color: var(--wz-blue); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.wizard-back-btn { width: 2.4rem; height: 2.4rem; border-radius: 9999px; background: var(--wz-red-soft); color: var(--wz-red); display: flex; align-items: center; justify-content: center; flex-shrink: 0; text-decoration: none; }
.wizard-menu-btn { display: none; width: 2.4rem; height: 2.4rem; border-radius: 0.6rem; background: #fff; color: var(--wz-navy); border: none; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }

/* ===== Barre de progression compacte (mobile uniquement, cf. media query plus bas) ===== */
.wizard-mobile-progress { display: none; margin-bottom: 1.5rem; }
.wizard-mobile-progress-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; font-weight: 700; color: var(--wz-text); font-size: 0.95rem; }

/* ===== Steps bar ===== */
.wizard-container { max-width: 980px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
.wizard-steps-bar { display: flex; gap: 0.5rem; overflow-x: auto; margin-bottom: 1.5rem; }
.step-pill { flex: 1; min-width: 128px; display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem 0.9rem; border-radius: 0.75rem; background: #EEF0F3; color: #9098A1; font-weight: 600; font-size: 0.8rem; white-space: nowrap; }
.step-pill .pill-circle { width: 1.6rem; height: 1.6rem; border-radius: 9999px; background: #D9DEE3; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; flex-shrink: 0; }
.step-pill.is-current { background: var(--wz-blue-soft); color: var(--wz-blue); }
.step-pill.is-current .pill-circle { background: var(--wz-blue); }
.step-pill.is-done { background: var(--wz-green-soft); color: var(--wz-green); cursor: pointer; }
.step-pill.is-done .pill-circle { background: var(--wz-green); }

/* ===== Step head ===== */
.wizard-step-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
/* Le h1,h2{font-family:'VisbyCF-DemiBold'} global de l'app utilise une police DEMO
   dont le glyphe "&" est volontairement cassé (watermark anti-piratage) : on force
   ici une police système normale pour ces titres. */
.wizard-step-head h2, .wizard-card > h2 { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 1.4rem; font-weight: 700; color: var(--wz-text); margin: 0; }
.wizard-step-head p { color: #6B7280; margin: 0.25rem 0 0; font-size: 0.875rem; }
.wizard-progress-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 0.35rem; min-width: 150px; }
.wizard-progress-pct { color: var(--wz-blue); font-weight: 700; font-size: 0.875rem; }
.wizard-progress-track { 
  /* width: 150px; */
  height: 0.4rem; background: #E4E7EB; border-radius: 9999px; overflow: hidden; }
.wizard-progress-fill { height: 100%; background: var(--wz-blue); transition: width .25s ease; }

/* ===== Card ===== */
.wizard-card { background: #fff; border: 1px solid #E7E9EC; border-radius: 1rem; padding: 1.75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.wizard-section-title { font-weight: 700; color: var(--wz-text); font-size: 1.05rem; margin: 0 0 0.25rem; }
.wizard-field { margin-bottom: 1.25rem; }
.wizard-field-label { display: block; font-weight: 600; color: var(--wz-text); margin-bottom: 0.5rem; font-size: 0.9rem; }
.wizard-hint { font-size: 0.8rem; font-weight: 400; color: #8A929B; }
.req-star { color: var(--wz-red); }
.wizard-input {
  width: 100%; background: #fff; color: var(--wz-text);
  padding: 0.85rem 1rem; border-radius: 0.65rem; border: 1.5px solid var(--wz-border);
  font-size: 0.95rem; line-height: 1.4; margin-top: 0; font-weight: 400;
}
.wizard-input::placeholder { color: #9098A1; }

/* Champ verrouillé : la valeur provient de l'annuaire des points de vente.
   Elle ne se corrige qu'en changeant de point de vente, ce qui libère la
   saisie. Les <select> sont désactivés, les champs texte en lecture seule et
   TomSelect verrouillé par son API — d'où ces trois sélecteurs. */
.wizard-input:disabled,
.wizard-input[readonly],
.ts-wrapper.locked .ts-control {
  background: var(--wz-bg);
  color: #6B7280;
  cursor: not-allowed;
}
.wizard-input:focus { outline: none; border-color: var(--wz-blue); box-shadow: 0 0 0 3px rgba(43, 69, 216, .12); }
select.wizard-input {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: none; padding-right: 2.5rem; cursor: pointer;
}
select.wizard-input::-ms-expand { display: none; }
.wizard-select-wrap { position: relative; }
/* z-index : le contrôle TomSelect est en `position: relative; z-index: 1` et
   recouvrirait le chevron. 2 suffit — la liste déroulante est bien au-dessus. */
.wizard-select-wrap .chevron { position: absolute; top: 0; right: 0; bottom: 0; display: flex; align-items: center; padding: 0 0.9rem; color: #6B7280; pointer-events: none; z-index: 2; }
#results { position: relative; z-index: 20; }
.autocomplete-item { padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.875rem; color: var(--wz-text); }
.autocomplete-item:hover { background: #F1F3F6; }
.wizard-grid-2 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 640px) { .wizard-grid-2 { grid-template-columns: 1fr 1fr; } }
.wizard-grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 768px) { .wizard-grid-3 { grid-template-columns: 1fr 1fr 1fr; } }
/* Un élément de grille vaut `min-width: auto` par défaut : il refuse de
   descendre sous la largeur de son contenu. Un nom de produit long élargissait
   donc sa colonne au détriment des autres. Avec `min-width: 0`, les colonnes
   restent égales et c'est le texte qui se tronque. */
.wizard-grid-2 > *,
.wizard-grid-3 > * { min-width: 0; }
.wizard-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2rem; }
.btn-secondary, .btn-primary { padding: 0.9rem 1.6rem; border-radius: 9999px; font-weight: 600; cursor: pointer; font-size: 0.95rem; }
.btn-secondary { background: #F3F4F6; color: #9098A1; border: 1.5px solid var(--wz-border); }
.btn-secondary:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--wz-blue); color: #fff; border: none; display: inline-flex; align-items: center; gap: 0.4rem; }
.btn-primary:disabled { opacity: .7; cursor: not-allowed; }
.btn-primary.btn-success { background: var(--wz-green); }
.btn-block { width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-label-short { display: none; }

/* ===== Chips (Type de PDV / raison Non) : pas de pastille radio, juste bordure + texte ===== */
.chip-check { position: absolute; opacity: 0; width: 0; height: 0; }
.chip-option {
  position: relative; display: inline-flex; align-items: center; padding: 0.65rem 1.2rem;
  border: 1.5px solid var(--wz-border); border-radius: 9999px; font-size: 0.875rem; font-weight: 600; color: var(--wz-text);
  background: #fff; cursor: pointer; user-select: none; transition: border-color .15s, color .15s, background .15s;
}
.chip-option:hover { border-color: var(--wz-blue); }
.chip-option:has(.chip-check:checked) { border-color: var(--wz-blue); color: var(--wz-blue); background: var(--wz-blue-soft); }
.chip-group { display: flex; flex-wrap: wrap; gap: 0.65rem; }

/* ===== Option rows (checkbox / radio blocks avec pastille visible) ===== */
.pf-option {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem; font-weight: 600;
  border: 1.5px solid var(--wz-border); border-radius: 0.65rem; background: #fff; color: var(--wz-text);
  cursor: pointer; user-select: none; transition: border-color .15s, box-shadow .15s, background .15s;
}
.pf-option:hover { border-color: var(--wz-blue); }
.pf-option:has(.pf-check:checked) { border-color: var(--wz-blue); box-shadow: 0 0 0 1px var(--wz-blue) inset; background: var(--wz-blue-soft); }
.pf-option--inline { display: inline-flex; width: auto; }
.pf-option--inline:has(.pf-check:checked) { color: var(--wz-blue); }
.pf-option--yesno:has(.pf-check:checked) { border-color: var(--wz-green); box-shadow: 0 0 0 1px var(--wz-green) inset; background: var(--wz-green-soft); }
.pf-option-sub { display: block; font-size: 0.75rem; font-weight: 400; color: #8A929B; margin-top: 0.15rem; }

.pf-check {
  appearance: none; -webkit-appearance: none; width: 1.25rem; height: 1.25rem; margin: 0;
  border: 2px solid #9CA3AF; border-radius: 0.375rem; background: #fff; cursor: pointer;
  position: relative; flex-shrink: 0; transition: background .15s, border-color .15s;
}
.pf-check[type="radio"] { border-radius: 9999px; }
.pf-check:checked { background: var(--wz-blue); border-color: var(--wz-blue); }
.pf-option--yesno .pf-check:checked { background: var(--wz-green); border-color: var(--wz-green); }
.pf-check[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.pf-check[type="radio"]:checked::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px;
  border-radius: 9999px; background: #fff; transform: translate(-50%, -50%);
}
.pf-check:focus-visible { outline: 2px solid var(--wz-blue); outline-offset: 2px; }

/* ===== Photo capture ===== */
.photo-box { border: 2px dashed var(--wz-border); border-radius: 1rem; padding: 1.5rem; text-align: center; background: #FAFBFC; }
.photo-box video { width: 100%; border-radius: 0.65rem; background: #000; margin-bottom: 0.75rem; }
.photo-camera-actions { display: flex; gap: 0.6rem; }
.photo-camera-actions .btn-primary, .photo-camera-actions .btn-secondary { flex: 1; }
.photo-box .photo-preview { position: relative; }
.photo-box .photo-preview img { width: 100%; height: 11rem; object-fit: cover; border-radius: 0.65rem; display: block; }
.photo-icon { width: 2.75rem; height: 2.75rem; border-radius: 0.75rem; background: var(--wz-blue-soft); color: var(--wz-blue); display: flex; align-items: center; justify-content: center; margin: 0 auto 0.75rem; }
.photo-remove-btn {
  position: absolute; top: 0.5rem; right: 0.5rem; width: 1.75rem; height: 1.75rem;
  border-radius: 9999px; background: #fff; color: var(--wz-red); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .25); line-height: 0;
}
.photo-remove-btn:hover { background: var(--wz-red-soft); }

/* ===== GPS ===== */
.gps-btn { display: inline-flex; align-items: center; gap: 0.4rem; background: var(--wz-blue-soft); color: var(--wz-blue); padding: 0.6rem 1.1rem; border-radius: 9999px; font-weight: 600; cursor: pointer; border: 1px solid #C7D2FE; }
.gps-box { background: #EEF0F3; border-radius: 0.85rem; padding: 1.75rem 1rem; text-align: center; color: var(--wz-text); margin-top: 1rem; min-height: 3rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; }

/* ===== Tables ===== */
.wizard-table { width: 100%; border-collapse: collapse; }
.wizard-table th, .wizard-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid #E7E9EC; font-size: 0.875rem; color: var(--wz-text); text-align: left; }
.wizard-table thead th { background: #F4F6F9; color: #6B7280; font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .03em; }
.icon-btn { border: none; background: transparent; cursor: pointer; padding: 0.3rem; border-radius: 0.4rem; line-height: 0; }
.icon-btn.edit { color: var(--wz-blue); }
.icon-btn.delete { color: var(--wz-red); }

/* ===== Pages simples (accueil / enregistrement agent) ===== */
.wizard-simple-container { max-width: 460px; margin: 0 auto; padding: 3rem 1rem; }
.wizard-simple-card { background: #fff; border: 1px solid #E7E9EC; border-radius: 1rem; padding: 2rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); text-align: center; }
.wizard-simple-card h2 { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 1.25rem; font-weight: 700; color: var(--wz-text); margin: 0 0 0.5rem; }
.wizard-simple-card .wizard-hint { margin-bottom: 1.5rem; }
.wizard-simple-card form { text-align: left; }

/* ===== Vue mobile ===== */
@media (max-width: 640px) {
  .wizard-header-inner { position: relative; }

  /* Le bandeau Date/Agent/Avatar/Retour passe dans un menu déroulant sous le hamburger */
  .wizard-menu-btn { display: flex; }
  .wizard-header-right {
    display: none;
    position: absolute; top: calc(100% + 0.6rem); right: 0; z-index: 40;
    background: #fff; border-radius: 0.85rem; padding: 1rem 1.25rem;
    box-shadow: 0 8px 24px rgba(16,24,40,.18);
    flex-direction: column; align-items: stretch; gap: 0.85rem; min-width: 220px;
  }
  .wizard-header-right.is-open { display: flex; }
  .wizard-header-right .wizard-header-item { text-align: left; }
  .wizard-header-right .wizard-header-label { color: #9098A1; }
  .wizard-header-right .wizard-header-value { color: var(--wz-text); }
  .wizard-header-right .wizard-avatar { align-self: flex-start; }
  .wizard-header-right .wizard-back-btn { align-self: flex-start; }

  /* La barre de pastilles d'étapes cède la place à un indicateur compact */
  .wizard-steps-bar { display: none; }
  .wizard-mobile-progress { display: block; }
  .wizard-step-head .wizard-progress-wrap { display: none; }

  /* Champs empilés sur une seule colonne (déjà le comportement par défaut de .wizard-grid-2/3) */
  .wizard-actions { gap: 0.6rem; }
  .btn-secondary, .btn-primary { padding: 0.9rem 1.1rem; }
  .btn-label-full { display: none; }
  .btn-label-short { display: inline; }
}

/* Relevé concurrence : une ligne (unité de stock, stock actuel) répétable.
   Le bouton de retrait se place à droite de la paire de champs, aligné sur
   leur base pour ne pas chevaucher les libellés. */
/* Sur mobile la paire de champs est empilée : le bouton de retrait prend sa
   propre ligne, calé à droite, plutôt que de rogner la largeur des champs. */
.wizard-stock-row { display: flex; flex-direction: column; align-items: flex-end; }
.wizard-stock-row > .wizard-grid-2 { width: 100%; min-width: 0; }
/* Cible tactile pleine, et non le seul tiret : le formulaire se remplit au
   doigt sur le terrain. */
.wizard-stock-row-remove {
  flex: none; width: 2.6rem; height: 2.6rem; margin-bottom: 0.9rem;
  display: flex; align-items: center; justify-content: center;
  border-radius: 9999px; background: var(--wz-red-soft);
}
.wizard-stock-row-remove:hover { background: #F8D7DD; }
/* À partir de deux colonnes, le bouton revient à droite de la paire. */
@media (min-width: 640px) {
  .wizard-stock-row { flex-direction: row; align-items: flex-end; gap: 0.6rem; }
  .wizard-stock-row > .wizard-grid-2 { flex: 1; width: auto; }
}

/* Champ date : saisie masquée JJ/MM/AAAA + calendrier maison. Le calendrier du
   navigateur est écarté pour la même raison que son champ date — son format et
   sa langue suivent les réglages de l'appareil, pas ceux de l'application. */
.wizard-date { position: relative; }
.wizard-date > .wizard-input { padding-right: 3rem; }
.wizard-date-trigger {
  position: absolute; top: 0; right: 0; height: 100%; width: 2.9rem;
  display: flex; align-items: center; justify-content: center;
  border: 0; background: none; color: var(--wz-blue); cursor: pointer;
  padding: 0; z-index: 2;
}
.wizard-date-error { font-size: 0.85rem; color: var(--wz-red); margin: 0.35rem 0 0; }

.wizard-calendar {
  position: absolute; top: calc(100% + 0.4rem); left: 0; z-index: 30;
  width: 17.5rem; max-width: calc(100vw - 2rem);
  background: #fff; border: 1.5px solid var(--wz-border); border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.14); padding: 0.75rem;
}
.wizard-calendar-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.wizard-calendar-month { font-weight: 600; font-size: 0.95rem; text-transform: capitalize; }
.wizard-calendar-nav {
  border: 0; background: none; cursor: pointer; color: var(--wz-blue);
  font-size: 1.35rem; line-height: 1; padding: 0 0.5rem; border-radius: 0.4rem;
}
.wizard-calendar-nav:hover { background: #F3F4F6; }
.wizard-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0.15rem; }
.wizard-calendar-dow {
  text-align: center; font-size: 0.75rem; font-weight: 600; color: #9098A1;
  padding-bottom: 0.25rem;
}
.wizard-calendar-day {
  border: 0; background: none; cursor: pointer; border-radius: 0.45rem;
  padding: 0.45rem 0; font-size: 0.88rem; color: var(--wz-text, #101828);
}
.wizard-calendar-day:hover:not(:disabled) { background: #F3F4F6; }
.wizard-calendar-day:disabled { color: #C9CDD3; cursor: not-allowed; }
.wizard-calendar-day.selected { background: var(--wz-blue); color: #fff; font-weight: 600; }
