/* ==========================================================================
   L’Exposant — composants réutilisables
   ========================================================================== */

/* ---------- Cartes ---------- */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 18px;
}

.card-flat {
  background: var(--surface-2);
  border-radius: var(--r);
  padding: 14px;
}

/* ---------- Pastilles de statut ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .9;
}
.pill.no-dot::before { display: none; }
.pill svg.i { width: 13px; height: 13px; margin-left: -2px; }

.pill[data-status="potential"] { background: var(--st-potential-soft); color: var(--st-potential-ink); }
.pill[data-status="sent"] { background: var(--st-sent-soft); color: var(--st-sent-ink); }
.pill[data-status="validated"] { background: var(--st-validated-soft); color: var(--st-validated-ink); }
.pill[data-status="refused"] { background: var(--st-refused-soft); color: var(--st-refused-ink); }
.pill[data-status="toclose"] { background: var(--apricot); color: #FFFFFF; }
.pill[data-status="archived"] { background: var(--surface-3); color: var(--ink-2); }
.pill.on-dark { background: rgba(255, 255, 255, .14); color: var(--cream); }

/* ---------- Ticket de marché (carte signature) ---------- */

.ticket {
  position: relative;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) auto;
  align-items: stretch;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-1);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
.ticket:hover { box-shadow: var(--shadow-2); }
.ticket:active { transform: scale(.985); }

.ticket + .ticket { margin-top: 10px; }

.ticket-stub {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 4px;
  border-radius: 18px 0 0 18px;
  background: var(--surface-2);
  border-right: 1.5px dashed var(--line-2);
  line-height: 1;
}

/* encoches du ticket */
.ticket-stub::before,
.ticket-stub::after {
  content: "";
  position: absolute;
  right: -8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--notch-bg);
}
.ticket-stub::before { top: -7px; }
.ticket-stub::after { bottom: -7px; }

.stub-wd { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.stub-day { margin: 5px 0 4px; font-size: 24px; font-weight: 800; letter-spacing: -.03em; color: var(--ink); }
.stub-mo { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.stub-range { margin-top: 5px; font-size: 10px; font-weight: 700; color: var(--ink-3); }

.ticket[data-status="validated"] .ticket-stub { background: var(--st-validated-soft); }
.ticket[data-status="validated"] .stub-day { color: var(--st-validated-ink); }
.ticket[data-status="sent"] .ticket-stub { background: var(--st-sent-soft); }
.ticket[data-status="sent"] .stub-day { color: var(--st-sent-ink); }
.ticket[data-status="potential"] .ticket-stub { background: var(--st-potential-soft); }
.ticket[data-status="potential"] .stub-day { color: var(--st-potential-ink); }
.ticket[data-status="toclose"] .ticket-stub { background: var(--apricot-soft); }
.ticket[data-status="toclose"] .stub-day { color: var(--apricot-strong); }
.ticket[data-status="refused"] { opacity: .72; }

.ticket-body {
  min-width: 0;
  padding: 13px 8px 13px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
}

.ticket-name {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.ticket-meta span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.ticket-meta svg.i { width: 14px; height: 14px; color: var(--ink-3); }
.ticket-meta .stars-static svg.i { width: 13px; height: 13px; color: var(--apricot); }
.ticket-meta .stars-static svg.i.off { color: var(--line-2); }

.ticket-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 3px; }

.ticket-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  padding: 12px 14px 12px 4px;
  color: var(--ink-3);
}
.ticket-side .amount { font-size: 16px; font-weight: 800; color: var(--ink); }
.ticket-side .amount-sub { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }

/* Variante avec boutons d'action : toute la carte reste cliquable */
article.ticket { cursor: pointer; }
article.ticket .ticket-stub { grid-row: 1 / span 2; }
article.ticket > .ticket-stub,
article.ticket > .ticket-body,
article.ticket > .ticket-side { pointer-events: none; }
.ticket-hit { position: absolute; inset: 0; z-index: 1; border-radius: 18px; }

.ticket-actions {
  position: relative;
  z-index: 2;
  grid-column: 2 / -1;
  display: flex;
  gap: 8px;
  padding: 0 12px 12px 16px;
}
.ticket-actions .btn { flex: 1; }

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .2s, transform .15s var(--ease), box-shadow .2s, color .2s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn svg.i { width: 18px; height: 18px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn-primary { background: var(--forest); color: var(--cream); }
.btn-primary:hover { background: var(--forest-2); }
.btn-accept { background: var(--forest-3); color: #fff; }
.btn-accept:hover { background: var(--forest); }
.btn-soft { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn-soft:hover { background: var(--surface-3); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { color: var(--st-refused-ink); background: var(--st-refused-soft); }
.btn-apricot { background: var(--apricot); color: #FFFFFF; }
.btn-apricot:hover { background: #8F3A49; }
.btn-on-dark { background: var(--surface); color: var(--forest); box-shadow: inset 0 0 0 1px var(--line); }
.btn-on-dark:hover { background: var(--surface-2); }
.btn-light { background: var(--surface); color: var(--forest); box-shadow: inset 0 0 0 1px var(--line); }
.btn-light:hover { background: var(--surface-2); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn.bordered { box-shadow: inset 0 0 0 1px var(--line); background: var(--surface); }

/* ---------- Contrôle segmenté ---------- */

.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 16px;
  background: var(--surface-3);
  overflow-x: auto;
  scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }

.seg button {
  flex: 1 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background .2s, color .2s, box-shadow .2s;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(40, 32, 20, .12);
}
.seg .count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(40, 32, 20, .07);
}

.seg-dark { background: var(--surface-3); }
.seg-dark button { color: var(--ink-2); }
.seg-dark button[aria-pressed="true"] { background: var(--surface); color: var(--forest); }

/* ---------- Puces de filtre ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .2s, color .2s, box-shadow .2s;
}
.chip[aria-pressed="true"] { background: var(--forest); color: var(--cream); box-shadow: none; }
.chip svg.i { width: 15px; height: 15px; }

/* ---------- Tuiles de statistiques ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 14px 14px 16px;
  text-align: left;
  transition: transform .2s var(--ease), box-shadow .2s;
}
button.stat:hover { box-shadow: var(--shadow-2); }
button.stat:active { transform: scale(.98); }

.stat-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }

.stat-icon {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--surface-2);
  color: var(--ink-2);
}
.stat-icon svg.i { width: 16px; height: 16px; }
.stat-icon[data-tone="validated"] { background: var(--st-validated-soft); color: var(--st-validated-ink); }
.stat-icon[data-tone="sent"] { background: var(--st-sent-soft); color: var(--st-sent-ink); }
.stat-icon[data-tone="potential"] { background: var(--st-potential-soft); color: var(--st-potential-ink); }
.stat-icon[data-tone="apricot"] { background: var(--apricot-soft); color: var(--apricot-strong); }

.stat-value { margin-top: 14px; font-size: 28px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-value small { font-size: 15px; font-weight: 700; letter-spacing: 0; color: var(--ink-2); margin-left: 2px; }
.stat-sub { margin-top: 6px; font-size: 12px; color: var(--ink-3); font-weight: 500; }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
}

/* ---------- États vides ---------- */

.empty {
  text-align: center;
  padding: 30px 20px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--line);
  border: 0;
}
.empty-art { width: 84px; height: 64px; margin: 0 auto 12px; display: block; }
.empty h3 { font-size: 15.5px; font-weight: 700; }
.empty p { margin: 6px auto 0; max-width: 300px; font-size: 13.5px; color: var(--ink-2); }
.empty .btn { margin-top: 16px; }

/* ---------- Formulaires ---------- */

.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.three { grid-template-columns: repeat(3, 1fr); }

.field { display: grid; gap: 7px; min-width: 0; }
.field > span, .field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.field .hint { font-size: 12px; color: var(--ink-3); font-weight: 500; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 16px;
  color: var(--ink);
  transition: border-color .2s, box-shadow .2s, background .2s;
  -webkit-appearance: none;
  appearance: none;
}
.input::placeholder { color: var(--ink-3); }
.input:focus {
  outline: none;
  border-color: var(--forest);
  background: var(--surface);
  box-shadow: 0 0 0 4px rgba(31, 77, 58, .1);
}
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
input[type="date"].input, input[type="time"].input { min-width: 0; }

.input-affix { position: relative; }
.input-affix .input { padding-right: 38px; }
.input-affix .affix {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 15px; font-weight: 700; color: var(--ink-3); pointer-events: none;
}

.form-group {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: var(--r);
  background: var(--surface-2);
}
.form-group .input { background: var(--surface); }
.form-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.form-group-title svg.i { width: 16px; height: 16px; color: var(--ink-3); }

.disclosure {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--forest-3);
}
.disclosure svg.i { transition: transform .25s var(--ease); }
.disclosure[aria-expanded="true"] svg.i { transform: rotate(180deg); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14.5px;
  font-weight: 600;
}

.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-2);
  transition: background .2s;
  pointer-events: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .25s var(--ease-spring);
}
.switch input:checked + span { background: var(--forest); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--forest) 40%, transparent); outline-offset: 2px; }

/* Choix à pastilles (statut, type d'emplacement…) */
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .2s, color .2s, box-shadow .2s;
}
.choice svg.i { width: 16px; height: 16px; }
.choice[aria-pressed="true"] { background: var(--forest); color: var(--cream); box-shadow: none; }
.choice .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Météo */
.weather-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.weather-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 2px 10px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  transition: background .2s, box-shadow .2s, color .2s;
}
.weather-opt svg.i { width: 24px; height: 24px; }
.weather-opt[aria-pressed="true"] { background: var(--brand-soft); color: var(--forest); box-shadow: inset 0 0 0 2px var(--forest); }

/* Étoiles */
.stars { display: flex; gap: 4px; }
.star-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--line-2);
  transition: color .15s, transform .2s var(--ease-spring);
}
.star-btn svg.i { width: 30px; height: 30px; }
.star-btn.on { color: var(--apricot); }
.star-btn.on svg.i { fill: currentColor; }
.star-btn:active { transform: scale(.85); }

.stars-static { display: inline-flex; gap: 1px; color: var(--apricot); }
.stars-static svg.i { width: 13px; height: 13px; fill: currentColor; }
.stars-static svg.i.off { color: var(--line-2); }

/* ---------- Feuilles (bottom sheets) ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(26, 29, 27, .44);
  opacity: 0;
  transition: opacity .3s var(--ease);
}
.sheet-backdrop.open { opacity: 1; }

.sheet {
  position: fixed;
  z-index: 61;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  max-height: 94dvh;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  transform: translateY(100%);
  transition: transform .42s var(--ease);
  --notch-bg: var(--surface-2);
}
.sheet.open { transform: translateY(0); }
.sheet.dragging { transition: none; }

/* Feuille du haut (saisie d'une vente) : elle reste visible au-dessus du clavier */
@media (max-width: 719px) {
  .sheet.top {
    top: 0;
    bottom: auto;
    max-height: 70dvh;
    padding-top: var(--safe-t);
    border-radius: 0 0 var(--r-xl) var(--r-xl);
    transform: translateY(-100%);
  }
  .sheet.top.open { transform: translateY(0); }
  .sheet.top .sheet-grab { order: 10; }
  .sheet.top .sheet-head { padding-top: 14px; }
  .sheet.top .sheet-foot { padding-bottom: 12px; }
}

.sheet-grab {
  flex: none;
  display: grid;
  place-items: center;
  height: 22px;
  touch-action: none;
  cursor: grab;
}
.sheet-grab::before {
  content: "";
  width: 40px;
  height: 5px;
  border-radius: 999px;
  background: var(--line-2);
}

.sheet-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 20px 12px;
  touch-action: none;
}
.sheet-title { font-size: 21px; font-weight: 800; line-height: 1.2; }
.sheet-sub { margin-top: 4px; font-size: 13.5px; color: var(--ink-2); }

.sheet-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 20px 20px;
}

.sheet-foot {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 12px 20px calc(14px + var(--safe-b));
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.sheet-foot .btn { flex: 1; min-height: 50px; }
.sheet-foot .btn.icon-only { flex: none; width: 50px; padding: 0; }

@media (min-width: 720px) {
  .sheet {
    left: 50%;
    right: auto;
    bottom: auto;
    top: 50%;
    width: min(580px, calc(100vw - 48px));
    max-height: min(88dvh, 860px);
    border-radius: var(--r-xl);
    transform: translate(-50%, -46%) scale(.97);
    opacity: 0;
    transition: transform .32s var(--ease), opacity .24s var(--ease);
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-grab { height: 14px; }
  .sheet-grab::before { display: none; }
  .sheet-foot { border-radius: 0 0 var(--r-xl) var(--r-xl); padding-bottom: 16px; }
}

/* ---------- Notifications ---------- */

.toasts {
  position: fixed;
  z-index: 80;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--safe-b) + 14px);
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(460px, 100%);
  width: max-content;
  padding: 11px 12px 11px 16px;
  border-radius: 16px;
  background: var(--forest-2);
  color: var(--cream);
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(23, 61, 46, .3);
  pointer-events: auto;
  animation: toast-in .35s var(--ease-spring) both;
}
.toast.out { animation: toast-out .25s var(--ease) both; }
.toast svg.i { width: 18px; height: 18px; color: var(--sage); }
.toast.error svg.i { color: #FFB4AE; }
.toast button {
  margin-left: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--forest);
  background: var(--cream);
}

@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px) scale(.97); } }

@media (min-width: 1024px) {
  .toasts { bottom: 28px; left: 280px; }
}
