/* ==========================================================================
   Composants réutilisables (site public, espace cliente et back-office)
   ========================================================================== */

/* — Boutons — */
.btn {
  --btn-bg: var(--c-brown);
  --btn-fg: var(--c-ivory);
  --btn-bd: var(--c-brown);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 48px;
  padding: .7rem 1.5rem;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-pill);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: .95rem;
  font-weight: 560;
  letter-spacing: .005em;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  isolation: isolate;
  transition: color var(--dur) var(--ease-out), border-color var(--dur) var(--ease-out), transform var(--dur-fast);
}
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--c-accent-ink);
  border-radius: inherit;
  transform: translateY(101%);
  transition: transform var(--dur) var(--ease-out);
}
.btn:hover::before { transform: none; }
.btn:hover { border-color: var(--c-accent-ink); }
.btn:active { transform: scale(.98); }
.btn .icon { width: 18px; height: 18px; flex: none; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

.btn--ghost { --btn-bg: transparent; --btn-fg: var(--c-brown); --btn-bd: var(--c-line-strong); }
.btn--ghost::before { background: var(--c-brown); }
.btn--ghost:hover { color: var(--c-ivory); border-color: var(--c-brown); }
.btn--light { --btn-bg: var(--c-white); --btn-fg: var(--c-brown); --btn-bd: var(--c-white); }
.btn--light::before { background: var(--c-powder); }
.btn--danger { --btn-bg: var(--c-danger); --btn-bd: var(--c-danger); --btn-fg: var(--c-white); }
.btn--danger::before { background: #8E2A3A; }
.btn--danger-ghost { --btn-bg: transparent; --btn-fg: var(--c-danger); --btn-bd: rgb(155 27 48 / .35); }
.btn--danger-ghost::before { background: var(--c-danger); }
.btn--danger-ghost:hover { color: var(--c-white); }
.btn--sm { min-height: 38px; padding: .45rem 1rem; font-size: .87rem; }
.btn--xs { min-height: 32px; padding: .3rem .8rem; font-size: .8rem; }
.btn--block { width: 100%; }
.btn.is-loading { pointer-events: none; color: transparent; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px; height: 38px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.icon-btn:hover { background: var(--c-white); border-color: var(--c-line-strong); }
.icon-btn .icon { width: 18px; height: 18px; }
.icon-btn--danger { color: var(--c-danger); }

.link {
  color: var(--c-accent-ink);
  font-weight: 560;
  text-decoration: underline;
  text-decoration-color: rgb(142 75 87 / .35);
  transition: text-decoration-color var(--dur-fast);
}
.link:hover { text-decoration-color: currentColor; }
.link-plain { text-decoration: none; }
.link-plain:hover { text-decoration: underline; }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }

.icon { display: inline-block; vertical-align: -0.18em; width: 1.1em; height: 1.1em; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* — Logo typographique (site, espaces et back-office) — */
.wordmark {
  display: inline-flex;
  flex-direction: column;
  line-height: .9;
  text-decoration: none;
  font-family: var(--f-serif);
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.wordmark__small { font-style: italic; font-size: .62em; letter-spacing: .02em; color: var(--c-accent-ink); }

/* — Formulaires — */
.form { display: grid; gap: var(--s-5); }
.form-row { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }
.field { display: grid; gap: .45rem; align-content: start; }
.field > label, .field__label {
  font-size: .9rem;
  font-weight: 600;
}
.field__label .optional, .field > label .optional { font-weight: 400; color: var(--c-muted-strong); }
.field__help { font-size: var(--t-small); color: var(--c-muted-strong); margin: 0; }
.input, .field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="tel"],
.field input[type="number"], .field input[type="url"], .field input[type="date"], .field input[type="time"],
.field input[type="datetime-local"], .field input[type="search"], .field select, .field textarea, .input-select {
  width: 100%;
  min-height: 48px;
  padding: .7rem .95rem;
  border: 1px solid rgb(58 35 41 / .55); /* contour des champs ≥ 3:1 (WCAG 1.4.11) */
  border-radius: var(--radius-m);
  background: var(--c-white);
  color: var(--c-brown);
  font-size: 1rem;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.field textarea { min-height: 8rem; resize: vertical; line-height: 1.55; }
.field select, .input-select {
  appearance: none;
  padding-right: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2359433D' stroke-width='1.6'%3E%3Cpath d='m1 1.5 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--c-muted); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .input:focus-visible, .input-select:focus-visible {
  border-color: var(--c-accent-ink);
  box-shadow: 0 0 0 3px rgb(183 110 121 / .22);
  border-radius: var(--radius-m);
}
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--c-danger); }
.field__errors { margin: 0; padding: 0; list-style: none; color: var(--c-danger); font-size: var(--t-small); font-weight: 560; }
.field__errors li { display: flex; gap: .35rem; align-items: flex-start; }
.field__errors .icon { margin-top: .2em; }
.form-errors {
  padding: var(--s-4) var(--s-5);
  border-radius: var(--radius-m);
  background: var(--c-danger-bg);
  color: var(--c-danger);
  font-weight: 560;
}
.form-errors ul { margin: 0; padding-left: 1.2rem; }

.check { display: flex; gap: .7rem; align-items: flex-start; cursor: pointer; line-height: 1.45; }
.check input[type="checkbox"], .check input[type="radio"] {
  flex: none;
  width: 20px; height: 20px;
  margin: .1rem 0 0;
  accent-color: var(--c-accent-ink);
}
.check__text small { display: block; color: var(--c-muted-strong); font-size: var(--t-small); }

.input-group { position: relative; }
.input-group .icon-btn { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.input-group input { padding-right: 3rem; }

.password-meter { height: 4px; border-radius: 2px; background: var(--c-line); overflow: hidden; }
.password-meter span { display: block; height: 100%; width: 0; background: var(--c-danger); transition: width var(--dur), background var(--dur); }

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: var(--s-2);
  padding: var(--s-7) var(--s-5);
  border: 1.5px dashed var(--c-line-strong);
  border-radius: var(--radius-l);
  background: var(--c-white);
  text-align: center;
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.dropzone.is-over { border-color: var(--c-accent-ink); background: var(--c-info-bg); }
.dropzone .icon { width: 28px; height: 28px; color: var(--c-accent-ink); }
.dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* — Badges de statut — */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .65rem;
  border-radius: var(--radius-pill);
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
  background: var(--c-beige);
  color: var(--c-brown);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--plain::before { display: none; }
.badge--pending { background: var(--c-warning-bg); color: var(--c-warning); }
.badge--confirmed { background: var(--c-success-bg); color: var(--c-success); }
.badge--completed { background: #ECE7F0; color: #5A4A6B; }
.badge--cancelled, .badge--refused { background: var(--c-danger-bg); color: var(--c-danger); }
.badge--draft { background: var(--c-beige); color: var(--c-muted-strong); }
.badge--published { background: var(--c-success-bg); color: var(--c-success); }
.badge--accent { background: var(--c-info-bg); color: var(--c-accent-ink); }

/* — Notes et alertes — */
.note {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--radius-m);
  background: var(--c-info-bg);
  font-size: .95rem;
}
.note > .icon { margin-top: .2em; width: 20px; height: 20px; color: var(--c-accent-ink); }
.note--warning { background: var(--c-warning-bg); }
.note--warning > .icon { color: var(--c-warning); }
.note--danger { background: var(--c-danger-bg); color: var(--c-danger); }
.note--danger > .icon { color: var(--c-danger); }
.note--success { background: var(--c-success-bg); }
.note--success > .icon { color: var(--c-success); }
.note strong { font-weight: 650; }
.note p { margin: 0; }

/* — Toasts — */
.toasts {
  position: fixed;
  z-index: 300;
  right: calc(var(--frame-gap) + 1rem);
  bottom: calc(var(--frame-gap) + 1rem);
  display: grid;
  gap: var(--s-2);
  width: min(26rem, calc(100vw - 2rem));
  pointer-events: none;
}
.toast {
  display: flex;
  gap: var(--s-3);
  align-items: flex-start;
  padding: var(--s-4) var(--s-4) var(--s-4) var(--s-5);
  border-radius: var(--radius-m);
  background: var(--c-brown);
  color: var(--c-ivory);
  box-shadow: var(--shadow-float);
  pointer-events: auto;
  animation: toast-in .45s var(--ease-out) both;
}
.toast.is-leaving { animation: toast-out .3s var(--ease-in-out) both; }
.toast > .icon { width: 20px; height: 20px; margin-top: .15em; color: var(--c-powder); }
.toast--error { background: var(--c-danger); }
.toast--error > .icon { color: var(--c-white); }
.toast p { margin: 0; flex: 1; font-size: .95rem; }
.toast .icon-btn { width: 30px; height: 30px; margin: -.2rem -.2rem 0 0; color: inherit; }
.toast .icon-btn:hover { background: rgb(255 255 255 / .12); border-color: transparent; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* — Boîte de dialogue de confirmation — */
.dialog {
  width: min(28rem, calc(100vw - 2rem));
  padding: 0;
  border: 0;
  border-radius: var(--radius-l);
  background: var(--c-ivory);
  color: var(--c-brown);
  box-shadow: var(--shadow-float);
}
.dialog::backdrop { background: rgb(58 35 41 / .4); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.dialog[open] { animation: toast-in .3s var(--ease-out); }
.dialog__body { padding: var(--s-6) var(--s-6) var(--s-5); }
.dialog__title { font-size: 1.6rem; margin-bottom: .4em; }
.dialog__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); padding: 0 var(--s-6) var(--s-6); }

/* — Panneaux & listes — */
.panel {
  background: var(--c-white);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-l);
  padding: clamp(1.25rem, 3vw, 2rem);
}
.panel--soft { background: rgb(255 255 255 / .55); }
.panel__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-5); }
.panel__head h2, .panel__head h3 { margin: 0; font-size: 1.45rem; }

.empty {
  display: grid;
  justify-items: start;
  gap: var(--s-3);
  padding: var(--s-7) var(--s-6);
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--radius-l);
}
.empty--center { justify-items: center; text-align: center; }
.empty__title { font-family: var(--f-serif); font-size: 1.5rem; margin: 0; }
.empty p { margin: 0; color: var(--c-muted-strong); max-width: 32rem; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-l); border: 1px solid var(--c-line); background: var(--c-white); }
.table th, .table td { padding: .85rem 1rem; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-line); }
.table th { font-size: .8rem; font-weight: 650; color: var(--c-muted-strong); background: rgb(248 225 226 / .5); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast); }
.table tbody tr:hover { background: rgb(250 248 245 / .9); }
.table td.actions { text-align: right; white-space: nowrap; }
.table .row-link { text-decoration: none; font-weight: 600; }
.table .row-link:hover { text-decoration: underline; }

.pagination { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin-top: var(--s-5); font-size: var(--t-small); }
.pagination a, .pagination span {
  display: inline-grid; place-items: center;
  min-width: 38px; height: 38px; padding: 0 .7rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--c-line);
  text-decoration: none;
}
.pagination [aria-current="page"] { background: var(--c-brown); color: var(--c-ivory); border-color: var(--c-brown); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  min-height: 38px;
  padding: .4rem 1rem;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: .9rem;
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.chip:hover { border-color: var(--c-brown); }
.chip[aria-pressed="true"], .chip[aria-current="page"], .chip.is-active { background: var(--c-brown); border-color: var(--c-brown); color: var(--c-ivory); }
.chip__count { font-size: .75rem; opacity: .7; }

.dl { display: grid; grid-template-columns: minmax(8rem, auto) 1fr; gap: .55rem var(--s-5); margin: 0; }
.dl dt { color: var(--c-muted-strong); font-size: .92rem; }
.dl dd { margin: 0; font-weight: 520; overflow-wrap: anywhere; }
@media (max-width: 520px) { .dl { grid-template-columns: minmax(0, 1fr); gap: .1rem; } .dl dd { margin-bottom: .6rem; } }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); }
.timeline li { position: relative; padding-left: 1.5rem; font-size: .92rem; }
.timeline li::before { content: ""; position: absolute; left: 0; top: .45em; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--c-rosegold); background: var(--c-ivory); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 4px; top: 1.2em; bottom: calc(-1 * var(--s-4)); width: 1px; background: var(--c-line-strong); }
.timeline time { display: block; font-size: .8rem; color: var(--c-muted-strong); }

.avatar {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border-radius: 50%;
  background: var(--c-powder);
  color: var(--c-brown);
  font-size: .85rem; font-weight: 700;
}
.avatar--staff { background: var(--c-brown); color: var(--c-ivory); font-family: var(--f-serif); font-style: italic; }

.spinner { width: 22px; height: 22px; border: 2px solid var(--c-line-strong); border-top-color: var(--c-accent-ink); border-radius: 50%; animation: spin .8s linear infinite; }

/* — Apparition au scroll (activée seulement si le JS est chargé) — */
.js [data-reveal] { opacity: 0; transform: translateY(18px); transition: opacity .9s var(--ease-out), transform .9s var(--ease-out); }
.js [data-reveal].is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js [data-reveal] { opacity: 1; transform: none; } }

/* Conditions du mot de passe, cochées en direct */
.pw-rules { display: grid; gap: .2rem; margin: .5rem 0 0; padding: 0; list-style: none; font-size: var(--t-small); color: var(--c-muted-strong); }
.pw-rules li { display: flex; align-items: center; gap: .45rem; }
.pw-rules li::before { content: ""; flex: none; width: .95rem; height: .95rem; border: 1.5px solid currentColor; border-radius: 50%; }
.pw-rules li.is-ok { color: #2E7D4F; }
.pw-rules li.is-ok::before { border-color: #2E7D4F; background: #2E7D4F url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='white' stroke-width='2'/%3E%3C/svg%3E") center / 80% no-repeat; }
@media (prefers-reduced-motion: no-preference) { .pw-rules li { transition: color .2s; } }
