/* ==========================================================================
   Bambo Booking — components.css   (requires tokens.css)
   Rules: no fixed widths on text containers (FR is ~20% longer), wrapping is
   allowed everywhere, min 44px targets, visible focus, no color-only meaning.
   Class prefix-free BEM-lite. Total budget: keep < 20KB unminified-gzip ~5KB.
   ========================================================================== */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--fw-regular) var(--fs-base)/var(--lh-base) var(--font-sans);
  overflow-wrap: anywhere; /* long words/emails never break layout */
}
h1,h2,h3,h4 { line-height: var(--lh-tight); margin: 0 0 var(--space-3); font-weight: var(--fw-bold); text-wrap: balance; }
h1 { font-size: var(--fs-2xl); } h2 { font-size: var(--fs-xl); } h3 { font-size: var(--fs-lg); } h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--space-4); max-width: var(--measure); }
a { color: var(--brand-text); text-underline-offset: 0.2em; }   /* always underlined in text */
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; height: auto; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.container { width: min(100% - 2rem, var(--container)); margin-inline: auto; }
.container--narrow { width: min(100% - 2rem, var(--container-narrow)); margin-inline: auto; }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.grid-auto { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- Focus (one rule for everything) ---------- */
:focus-visible {
  outline: var(--focus-width) solid var(--focus-color);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}
/* Double ring so it also works on dark/brand fills */
.btn:focus-visible, .slot__input:focus-visible + .slot__label, .choice__input:focus-visible + .choice__body {
  outline: var(--focus-width) solid var(--focus-color); outline-offset: var(--focus-offset);
  box-shadow: 0 0 0 calc(var(--focus-offset) + 1px) #fff;
}

/* ---------- Skip link ---------- */
.skip-link { position: absolute; left: var(--space-3); top: -4rem; background: var(--surface); color: var(--text);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); box-shadow: var(--shadow-3); z-index: 100; }
.skip-link:focus { top: var(--space-3); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap-min); min-width: var(--tap-min); padding: var(--space-2) var(--space-5);
  font: var(--fw-medium) var(--fs-base)/1.25 var(--font-sans); text-align: center; text-decoration: none;
  border: 2px solid transparent; border-radius: var(--radius-md); cursor: pointer;
  transition: background-color var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  /* no fixed width: text wraps, button grows */
}
.btn--primary   { background: var(--brand-500); color: var(--on-brand); border-color: var(--brand-edge); box-shadow: var(--shadow-1); }
.btn--primary:hover  { background: var(--brand-hover); }
.btn--primary:active { background: var(--brand-active); transform: translateY(1px); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-muted); }
.btn--ghost     { background: transparent; color: var(--brand-text); }
.btn--ghost:hover { background: var(--brand-tint); }
.btn--danger    { background: var(--danger-600); color: #fff; }
.btn--danger:hover { background: #8f1e18; }
.btn--block { display: flex; width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { background: var(--surface-muted); color: var(--text-muted); border-color: var(--border); box-shadow: none; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"]::after { content: ""; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.btn-row--end { justify-content: flex-end; }

/* ---------- Forms ---------- */
.field { display: grid; gap: var(--space-2); margin-bottom: var(--space-5); }
.field__label { font-weight: var(--fw-medium); }
.field__label .req { color: var(--danger-600); }            /* + text "(obligatoire)" in the label, not color only */
.field__hint { font-size: var(--fs-sm); color: var(--text-muted); }
.field__error { display: none; font-size: var(--fs-sm); color: var(--danger-600); font-weight: var(--fw-medium); }
.field__error::before { content: "⚠ "; }
.field--invalid .field__error { display: block; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap-min); padding: var(--space-2) var(--space-3);
  font: inherit; color: var(--text); background: var(--surface);
  border: var(--border-width) solid var(--border-strong); border-radius: var(--radius-md);
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.textarea { min-height: 6rem; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--n-600); }
.field--invalid .input, .field--invalid .select, .field--invalid .textarea, [aria-invalid="true"] {
  border-color: var(--danger-600); border-width: 2px; background: var(--danger-tint);
}
.input[disabled], .select[disabled] { background: var(--surface-muted); color: var(--text-muted); cursor: not-allowed; }
.select { appearance: none; padding-right: 2.5rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--n-600) 50%), linear-gradient(135deg, var(--n-600) 50%, transparent 50%);
  background-position: calc(100% - 1.25rem) 55%, calc(100% - 0.9rem) 55%; background-size: 0.4rem 0.4rem; background-repeat: no-repeat; }
.input--color { padding: var(--space-1); width: 5rem; cursor: pointer; }
fieldset.field { border: 0; padding: 0; margin: 0 0 var(--space-5); min-width: 0; }
fieldset.field legend { padding: 0; font-weight: var(--fw-medium); margin-bottom: var(--space-2); }

/* Checkbox / radio: native control enlarged inside a 44px row */
.check { display: flex; align-items: flex-start; gap: var(--space-3); min-height: var(--tap-min); padding: var(--space-2) 0; cursor: pointer; }
.check input { flex: none; width: 1.5rem; height: 1.5rem; margin: 0.1rem 0 0; accent-color: var(--brand-text); cursor: pointer; }
.check span { padding-top: 0.15rem; }

/* ---------- Card, choice cards (service / staff / plan) ---------- */
.card { background: var(--surface); border: var(--border-width) solid var(--border); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-1); }
.card__title { margin-bottom: var(--space-2); }

/* Selectable card = radio input + body. Selection = check mark + border + tint (not color only). */
.choice { position: relative; display: block; }
.choice__input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.choice__body { display: flex; gap: var(--space-4); align-items: flex-start; min-height: var(--tap-min); background: var(--surface);
  border: 2px solid var(--border-strong); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-1);
  transition: background-color var(--dur-base), border-color var(--dur-base), box-shadow var(--dur-base); }
.choice__input:hover + .choice__body { box-shadow: var(--shadow-2); }
.choice__input:checked + .choice__body { background: var(--brand-tint); border-color: var(--brand-edge); }
.choice__input:checked + .choice__body::after { content: "✓"; margin-left: auto; flex: none; width: 1.5rem; height: 1.5rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--brand-500); color: var(--on-brand); font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.choice__main { flex: 1 1 auto; min-width: 0; }
.choice__title { font-weight: var(--fw-medium); display: block; }
.choice__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); font-size: var(--fs-sm); color: var(--text-muted); }
.choice__price { font-weight: var(--fw-bold); color: var(--text); white-space: nowrap; }

.avatar { flex: none; width: 3rem; height: 3rem; border-radius: 50%; background: var(--brand-tint-strong); color: var(--text);
  display: grid; place-items: center; font-weight: var(--fw-bold); overflow: hidden; object-fit: cover; }

/* ---------- Badges (always text; icon optional) ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: 0.125rem var(--space-3); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.5; background: var(--surface-muted); color: var(--text); border: 1px solid var(--border-strong); white-space: normal; }
.badge--success { background: var(--success-tint); color: var(--success-600); border-color: var(--success-600); }
.badge--warning { background: var(--warning-tint); color: var(--warning-600); border-color: var(--warning-600); }
.badge--danger  { background: var(--danger-tint);  color: var(--danger-600);  border-color: var(--danger-600); }
.badge--info    { background: var(--info-tint);    color: var(--info-600);    border-color: var(--info-600); }
.badge--brand   { background: var(--brand-tint);   color: var(--text);        border-color: var(--brand-edge); }

/* ---------- Alerts & toasts (role="status"/"alert" set in markup) ---------- */
.alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); border-radius: var(--radius-md);
  border: 1px solid; border-left-width: 6px; background: var(--info-tint); color: var(--text); border-color: var(--info-600); }
.alert__icon { flex: none; font-weight: var(--fw-bold); color: var(--info-600); }
.alert__title { font-weight: var(--fw-bold); display: block; }
.alert--success { background: var(--success-tint); border-color: var(--success-600); } .alert--success .alert__icon { color: var(--success-600); }
.alert--warning { background: var(--warning-tint); border-color: var(--warning-600); } .alert--warning .alert__icon { color: var(--warning-600); }
.alert--danger  { background: var(--danger-tint);  border-color: var(--danger-600); }  .alert--danger  .alert__icon { color: var(--danger-600); }
.toast-region { position: fixed; z-index: 90; inset: auto var(--space-4) var(--space-4) var(--space-4); display: grid; gap: var(--space-3); justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; width: min(100%, 28rem); box-shadow: var(--shadow-3); background: var(--surface); animation: toast-in var(--dur-base) var(--ease-out); }
.toast.alert { border-color: var(--border-strong); }
@keyframes toast-in { from { opacity: 0; transform: translateY(0.5rem); } }
/* Toasts must NOT auto-dismiss faster than 8s for errors, and always have a close button (2.2.1). */

/* ---------- Stepper (booking) — ol with aria-current="step" ---------- */
.stepper { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-4); list-style: none; padding: 0; margin: 0 0 var(--space-5); counter-reset: step; }
.stepper__item { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); counter-increment: step; }
.stepper__item::before { content: counter(step); flex: none; width: 1.75rem; height: 1.75rem; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--border-strong); background: var(--surface); font-weight: var(--fw-bold); color: var(--text); }
.stepper__item[aria-current="step"] { color: var(--text); font-weight: var(--fw-bold); }
.stepper__item[aria-current="step"]::before { background: var(--brand-500); color: var(--on-brand); border-color: var(--brand-edge); }
.stepper__item--done::before { content: "✓"; background: var(--brand-tint); border-color: var(--brand-edge); }
/* Mobile: show only "Étape 2 sur 5 — Équipe" text + progress bar; markup provides .stepper-compact */
.stepper-compact { display: none; }
@media (max-width: 40rem) {
  .stepper { display: none; } .stepper-compact { display: block; margin-bottom: var(--space-5); }
}

/* ---------- Progress (booking progress + loyalty) — native <progress>/role=progressbar ---------- */
.progress { display: block; width: 100%; height: 0.875rem; border-radius: var(--radius-pill); background: var(--surface-muted);
  border: 1px solid var(--border-strong); overflow: hidden; }
.progress__bar { display: block; height: 100%; background: var(--brand-500); border-right: 2px solid var(--brand-edge); border-radius: var(--radius-pill);
  transition: width var(--dur-slow) var(--ease-out); }
.loyalty { display: grid; gap: var(--space-3); }
.loyalty__points { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1; }
.loyalty__legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-2); font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Date picker (month grid of buttons) ---------- */
.cal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); box-shadow: var(--shadow-1); }
.cal__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.cal__title { margin: 0; font-size: var(--fs-md); text-transform: capitalize; }
.cal__grid { width: 100%; border-collapse: separate; border-spacing: 2px; table-layout: fixed; }
.cal__grid th { font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-muted); padding: var(--space-1) 0; text-align: center; }
.cal__day { width: 100%; min-height: var(--tap-min); border: 2px solid transparent; border-radius: var(--radius-md); background: transparent; color: var(--text);
  font: inherit; cursor: pointer; display: grid; place-items: center; line-height: 1.1; padding: 0; }
.cal__day:hover { background: var(--surface-muted); }
.cal__day[aria-pressed="true"] { background: var(--brand-500); color: var(--on-brand); border-color: var(--brand-edge); font-weight: var(--fw-bold); }
.cal__day[aria-disabled="true"] { color: var(--text-muted); text-decoration: line-through; cursor: not-allowed; background: transparent; }
.cal__day[aria-disabled="true"]:hover { background: transparent; }
.cal__day--today { border-color: var(--border-strong); }
.cal__day--avail::after { content: ""; width: 0.3rem; height: 0.3rem; border-radius: 50%; background: currentColor; margin-top: 2px; }  /* dot = has slots */

/* ---------- Time-slot grid (radio group of native inputs) ---------- */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: var(--space-2); border: 0; padding: 0; margin: 0; }
.slot { position: relative; }
.slot__input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.slot__label { display: grid; place-items: center; min-height: var(--tap-min); padding: var(--space-2); text-align: center; background: var(--surface);
  border: 2px solid var(--border-strong); border-radius: var(--radius-md); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-fast), border-color var(--dur-fast); }
.slot__input:hover + .slot__label { background: var(--brand-tint); }
.slot__input:checked + .slot__label { background: var(--brand-500); color: var(--on-brand); border-color: var(--brand-edge); }
.slot__input:checked + .slot__label::before { content: "✓ "; }
.slot__input:disabled { cursor: not-allowed; }
.slot__input:disabled + .slot__label { background: var(--surface-muted); color: var(--text-muted); border-style: dashed; text-decoration: line-through; }
.slot-group__title { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-muted); margin: var(--space-4) 0 var(--space-2); }

/* ---------- Language switcher — real links with lang/hreflang ---------- */
.lang { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-pill); overflow: hidden; background: var(--surface); }
.lang a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap-min); min-width: var(--tap-min); padding: 0 var(--space-3);
  color: var(--text); text-decoration: none; font-weight: var(--fw-medium); border-radius: 0; }
.lang a:hover { background: var(--surface-muted); }
.lang a[aria-current="true"] { background: var(--n-900); color: #fff; }   /* neutral, not brand: works on every tenant */

/* ---------- Nav & header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3) var(--space-5); padding-block: var(--space-3); }
.brand-logo { display: inline-flex; align-items: center; gap: var(--space-3); font-weight: var(--fw-bold); color: var(--text); text-decoration: none; min-height: var(--tap-min); }
.brand-logo img { max-height: 2.5rem; max-width: 10rem; object-fit: contain; }
.nav { display: flex; flex-wrap: wrap; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.nav a { display: inline-flex; align-items: center; min-height: var(--tap-min); padding: 0 var(--space-4); color: var(--text); text-decoration: none; border-radius: var(--radius-md); border-bottom: 3px solid transparent; }
.nav a:hover { background: var(--surface-muted); }
.nav a[aria-current="page"] { font-weight: var(--fw-bold); background: var(--brand-tint); border-bottom-color: var(--brand-edge); }
/* Admin/staff sidebar: same .nav, stacked */
.nav--stacked { flex-direction: column; flex-wrap: nowrap; }

/* ---------- Table (scrolls horizontally on mobile, never clips) ---------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table-wrap:focus-visible { outline-offset: 0; }   /* wrapper gets tabindex=0 + role=region + aria-label */
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table caption { text-align: left; padding: var(--space-3) var(--space-4); font-weight: var(--fw-bold); font-size: var(--fs-base); }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: middle; border-top: 1px solid var(--border); }
.table thead th { background: var(--surface-muted); font-weight: var(--fw-bold); border-top: 0; white-space: nowrap; }
.table tbody tr:hover { background: var(--n-50); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Modal (native <dialog>; showModal() gives focus trap + Esc + inert bg) ---------- */
.modal { border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-3); width: min(100% - 2rem, 32rem); color: var(--text); background: var(--surface); }
.modal::backdrop { background: rgb(28 39 43 / 0.55); }
.modal[open] { animation: toast-in var(--dur-base) var(--ease-out); }
.modal__body { padding: var(--space-5); }
.modal__footer { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: flex-end; padding: var(--space-4) var(--space-5); background: var(--surface-muted); border-top: 1px solid var(--border); }

/* ---------- Summary list (booking confirm) ---------- */
.summary { display: grid; grid-template-columns: minmax(6rem, max-content) 1fr; gap: var(--space-2) var(--space-4); margin: 0; }
.summary dt { color: var(--text-muted); } .summary dd { margin: 0; font-weight: var(--fw-medium); }
@media (max-width: 30rem) { .summary { grid-template-columns: 1fr; gap: 0; } .summary dd { margin-bottom: var(--space-3); } }

/* ---------- Print/forced-colors niceties ---------- */
@media (forced-colors: active) {
  .choice__input:checked + .choice__body, .slot__input:checked + .slot__label, .cal__day[aria-pressed="true"] { border-color: Highlight; outline: 2px solid Highlight; }
}
