/* ============================================================
   components.css — Boutons, champs, cartes, badges, listes…
   ============================================================ */

/* ---- Boutons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: background var(--tr), border-color var(--tr),
              color var(--tr), transform var(--tr);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
  background: var(--green);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--green-700); }

.btn--ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }

.btn--danger {
  background: var(--surface);
  border-color: var(--line);
  color: var(--neg);
}
.btn--danger:hover { background: var(--neg-bg); border-color: var(--neg); }

.btn--sm { padding: 7px 12px; font-size: var(--fs-xs); }
.btn--block { width: 100%; }

/* ---- Cartes ---------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.card--pad-lg { padding: var(--sp-6); }

/* ---- Carte KPI ------------------------------------------- */
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
  transition: transform var(--tr), box-shadow var(--tr), border-color var(--tr);
}
.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--line-strong);
}
.kpi__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kpi__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-mute);
}
.kpi__icon {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  background: var(--green-tint);
  color: var(--green);
}
.kpi__icon svg { width: 18px; height: 18px; }
.kpi__value {
  font-size: var(--fs-3xl);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.03em;
  margin-top: var(--sp-4);
}
.kpi__hint { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 6px; }

/* ---- Barre de progression -------------------------------- */
.progress-card { margin-top: var(--sp-4); }
.progress-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.progress-card__title { font-size: var(--fs-md); font-weight: 600; }
.progress-card__pct {
  font-size: var(--fs-xl);
  font-weight: 600;
  letter-spacing: -.02em;
  color: var(--green);
}
.progress-card__sub { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 2px; }

.progress {
  height: 8px;
  margin-top: var(--sp-3);
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: 0;
  border-radius: var(--r-pill);
  background: var(--green);
  transition: width .9s var(--ease);
}

/* ---- Champs de formulaire -------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
}
.field__label .req { color: var(--neg); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--ink);
  transition: border-color var(--tr), box-shadow var(--tr);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-mute); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: var(--ring);
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

.input:disabled, .select:disabled {
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: not-allowed;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%23989c93' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 5l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field--error .input,
.field--error .select,
.field--error .textarea { border-color: var(--neg); }
.field__error { font-size: var(--fs-xs); color: var(--neg); font-weight: 500; }

.form-hint {
  font-size: var(--fs-xs);
  color: var(--ink-mute);
  margin-top: var(--sp-2);
}

/* ---- Badges ---------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.badge--ok      { background: var(--pos-bg);  color: var(--pos); }
.badge--warn    { background: var(--warn-bg); color: var(--warn); }
.badge--danger  { background: var(--neg-bg);  color: var(--neg); }
.badge--info    { background: var(--cool-bg); color: var(--cool); }
.badge--neutral { background: var(--mute-bg); color: var(--mute); }
.badge--soft {
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.badge--soft::before { display: none; }

/* ---- Filtres --------------------------------------------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.filters .search-field { flex: 2 1 220px; }
.filters .select { flex: 1 1 150px; }
.search-field { position: relative; }
.search-field svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--ink-mute);
  pointer-events: none;
}
.search-field .input { padding-left: 36px; }
@media (max-width: 620px) {
  .filters .search-field,
  .filters .select { flex: 1 1 100%; }
}

/* ---- Fiche prospect (suivi) ------------------------------ */
.prospect {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--tr), box-shadow var(--tr);
  animation: rise .32s var(--ease) both;
}
.prospect:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}
.prospect__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.prospect__title { font-size: var(--fs-md); font-weight: 600; }
.prospect__struct { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 2px; }
.prospect__struct b { color: var(--ink); font-weight: 600; }
.prospect__badges { display: flex; gap: 6px; flex-wrap: wrap; }

.prospect__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3) var(--sp-5);
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
.prospect__cell { font-size: var(--fs-sm); }
.prospect__cell .k {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-mute);
  font-weight: 600;
}
.prospect__cell .v { color: var(--ink); }

.prospect__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
.prospect__meta { font-size: var(--fs-xs); color: var(--ink-mute); }
.prospect__actions { display: flex; gap: var(--sp-2); align-items: center; }
.prospect__actions .select { width: auto; padding: 7px 30px 7px 12px; }
@media (max-width: 620px) { .prospect__grid { grid-template-columns: 1fr; } }

/* ---- Demandes (back-office) ------------------------------ */
.demande__produits {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--sp-4);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
.demande__produit { display: flex; gap: var(--sp-3); font-size: var(--fs-sm); }
.demande__qty {
  flex: none;
  font-weight: 600;
  color: var(--green);
  min-width: 30px;
}
.demande__message {
  margin-top: var(--sp-3);
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--ink-soft);
}

/* ---- Ligne agent ----------------------------------------- */
.agent {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.agent:last-child { margin-bottom: 0; }
.agent__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}
.agent__name { display: flex; align-items: center; gap: var(--sp-3); }
.agent__avatar {
  flex: none;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--green-tint);
  color: var(--green);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.agent__fullname { font-weight: 600; }
.agent__zone { font-size: var(--fs-xs); color: var(--ink-mute); }
.agent__score {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--green);
}
.agent__bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
}
.agent__bar-row .progress { flex: 1; margin-top: 0; }

/* ---- Guide ----------------------------------------------- */
.guidebox {
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  border: 1px solid var(--line);
}
.guidebox--green { background: var(--green-tint); border-color: transparent; }
.guidebox--plain { background: var(--surface-2); }
.guidebox h3 {
  font-size: var(--fs-md);
  margin-bottom: var(--sp-3);
}
.guidebox ul { list-style: none; display: flex; flex-direction: column; gap: var(--sp-2); }
.guidebox li {
  position: relative;
  padding-left: 20px;
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}
.guidebox li::before {
  content: "";
  position: absolute;
  left: 2px; top: 8px;
  width: 6px; height: 6px;
  border-radius: 2px;
  background: var(--green);
}

/* ---- État vide ------------------------------------------- */
.empty {
  text-align: center;
  padding: var(--sp-7) var(--sp-5);
  color: var(--ink-mute);
}
.empty svg { width: 42px; height: 42px; margin: 0 auto var(--sp-3); opacity: .5; }
.empty h3 { font-size: var(--fs-md); color: var(--ink-soft); }
.empty p { font-size: var(--fs-sm); margin-top: 4px; }

/* ---- Module de gestion en préparation -------------------- */
.gc-soon { text-align: center; padding: var(--sp-7) var(--sp-5); }
.gc-soon__icon {
  width: 66px; height: 66px;
  margin: 0 auto var(--sp-4);
  display: grid; place-items: center;
  background: var(--green-tint);
  color: var(--green);
  border-radius: 50%;
}
.gc-soon__icon svg { width: 30px; height: 30px; }
.gc-soon h3 { font-size: var(--fs-md); }
.gc-soon p {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin: 6px auto var(--sp-4);
  max-width: 48ch;
  line-height: 1.6;
}

/* ---- Tableau de bord ------------------------------------- */
.dash-card__title { font-size: var(--fs-md); font-weight: 600; margin-bottom: var(--sp-4); }

.dash-line { margin-bottom: var(--sp-3); }
.dash-line:last-child { margin-bottom: 0; }
.dash-line__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: 5px;
  font-size: var(--fs-sm);
}
.dash-line__label { font-weight: 500; }
.dash-line__val {
  font-weight: 600;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.dash-demandes { display: flex; flex-direction: column; }
.dash-demande {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--line-soft);
}
.dash-demande:last-child { border-bottom: none; }
.dash-demande__nom { font-weight: 600; font-size: var(--fs-sm); }
.dash-demande__meta { font-size: var(--fs-xs); color: var(--ink-soft); margin-top: 1px; }

/* ---- Toasts ---------------------------------------------- */
.toast-host {
  position: fixed;
  z-index: 60;
  right: 18px; bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  max-width: min(340px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  animation: toast-in .3s var(--ease) both;
}
.toast.is-out { animation: toast-out .26s var(--ease) forwards; }
.toast__dot {
  flex: none;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: #4caf7e;
}
.toast--error .toast__dot { background: #e0796a; }
.toast--info  .toast__dot { background: #9aa39c; }

/* ---- Modale de confirmation ------------------------------ */
.modal-host {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: var(--sp-4);
  background: rgba(24, 32, 27, .42);
}
.modal-host.is-open { display: grid; animation: fade .18s var(--ease); }
.modal {
  width: min(420px, 100%);
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-lg);
  animation: rise .22s var(--ease);
}
.modal h3 { font-size: var(--fs-lg); }
.modal p { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: var(--sp-2); }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

/* Modale de formulaire (en-tête + corps défilant) */
.modal--form { width: min(580px, 100%); padding: 0; }
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.modal__head h3 { font-size: var(--fs-lg); }
.modal__close {
  flex: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  transition: background var(--tr), color var(--tr);
}
.modal__close:hover { background: var(--surface-3); color: var(--ink); }
.modal__close svg { width: 16px; height: 16px; }
.modal__body { padding: var(--sp-5); max-height: 72vh; overflow-y: auto; }

/* ---- Barre d'outils + tableau de données (gestion) ------- */
.gc-toolbar {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.gc-toolbar .search-field { flex: 1; min-width: 200px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.data-table th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-mute);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--tr); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table__actions { display: flex; gap: 6px; justify-content: flex-end; }

.row-act {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-sm);
  color: var(--ink-soft);
  transition: border-color var(--tr), color var(--tr), background var(--tr);
}
.row-act:hover { border-color: var(--green); color: var(--green); }
.row-act--danger:hover { border-color: var(--neg); color: var(--neg); background: var(--neg-bg); }
.row-act svg { width: 15px; height: 15px; }

/* ---- Écran de chargement --------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .4s var(--ease);
}
.loader.is-hidden { opacity: 0; pointer-events: none; }
.loader__inner { text-align: center; }
.loader__mark {
  width: 60px; height: 60px;
  margin: 0 auto var(--sp-4);
  display: grid; place-items: center;
  color: #fff;
  background: var(--green);
  border-radius: 16px;
  animation: pulse 1.5s var(--ease) infinite;
}
.loader__mark svg { width: 34px; height: 34px; }
.loader__text { font-size: var(--fs-sm); color: var(--ink-soft); }

/* ---- Écran d'accueil (choix d'espace) -------------------- */
.role-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--sp-5);
  background: var(--bg);
  overflow-y: auto;
}
.role-gate__panel {
  width: 100%;
  max-width: 540px;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: clamp(24px, 5vw, 44px);
  box-shadow: var(--shadow-md);
  animation: rise .3s var(--ease) both;
}
.role-gate__brand { display: flex; align-items: center; gap: var(--sp-3); }
.role-gate__name { font-weight: 600; font-size: var(--fs-md); }
.role-gate__tag  { font-size: var(--fs-xs); color: var(--ink-soft); }
.role-gate__title { font-size: var(--fs-xl); }
.role-gate__sub {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  margin-top: calc(-1 * var(--sp-2));
}
.role-choices { display: grid; gap: var(--sp-3); }

.role-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon title" "icon desc" "icon go";
  column-gap: var(--sp-4);
  row-gap: 2px;
  text-align: left;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: border-color var(--tr), box-shadow var(--tr), transform var(--tr);
}
.role-card:hover {
  border-color: var(--green);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.role-card__icon {
  grid-area: icon;
  align-self: center;
  width: 48px; height: 48px;
  display: grid; place-items: center;
  background: var(--green-tint);
  color: var(--green);
  border-radius: var(--r-md);
}
.role-card__icon svg { width: 24px; height: 24px; }
.role-card__title { grid-area: title; font-weight: 600; font-size: var(--fs-md); }
.role-card__desc  { grid-area: desc; font-size: var(--fs-sm); color: var(--ink-soft); }
.role-card__go    { grid-area: go; font-size: var(--fs-xs); font-weight: 600; color: var(--green); margin-top: 4px; }

/* ---- Transmission / Réception ---------------------------- */
.lead {
  font-size: var(--fs-md);
  color: var(--ink-soft);
  line-height: 1.6;
}
.reception-log { display: flex; flex-direction: column; gap: var(--sp-2); }
.reception-log__line {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}
.reception-log__line svg { width: 16px; height: 16px; color: var(--green); flex: none; }

/* ---- Animations ------------------------------------------ */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.07); }
}

/* Révélation en cascade au chargement d'une vue */
.stagger > * { animation: rise .42s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .03s; }
.stagger > *:nth-child(2) { animation-delay: .09s; }
.stagger > *:nth-child(3) { animation-delay: .15s; }
.stagger > *:nth-child(4) { animation-delay: .21s; }
.stagger > *:nth-child(5) { animation-delay: .27s; }
