/* Composants réutilisables. */

/* Marque */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.125rem; letter-spacing: -.01em; color: var(--text); }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand-lg { flex-direction: column; gap: 14px; font-size: 2.125rem; line-height: 1.1; }
.brand-lg .brand-mark { width: 72px; height: 72px; filter: drop-shadow(0 10px 22px rgba(79, 70, 229, .30)); }

/* Boutons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  user-select: none;
  transition: transform var(--dur-1) var(--ease), background-color var(--dur-1), opacity var(--dur-1);
}
.btn:active { transform: scale(.97); }
.btn .icon { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--accent-soft); color: var(--accent-text); }
.btn-secondary:hover { background: var(--accent-soft-2); }
.btn-ghost { color: var(--accent-text); padding-inline: 12px; }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-lg { min-height: 54px; padding-inline: 24px; font-size: 1.0625rem; }
.btn-sm { padding: 8px 14px; font-size: .9375rem; }
.btn-block { display: flex; width: 100%; }
.btn-grow { flex: 1; min-width: 0; }
.btn[aria-disabled="true"], .btn:disabled { opacity: .45; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  flex: none;
  border-radius: 50%;
  color: var(--accent-text);
  transition: background-color var(--dur-1), transform var(--dur-1) var(--ease);
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn:active { transform: scale(.92); }

/* Pastille de solde */
.balance-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: .9375rem;
  font-weight: 700;
  transition: background-color var(--dur-1);
}
.balance-pill:hover { background: var(--accent-soft-2); }
.balance-pill .icon { width: 18px; height: 18px; }
.topbar .balance-pill { margin-block: 4px; }

/* Cartes */
.card {
  padding: 16px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
}
.card-title { display: flex; align-items: center; gap: 8px; font-size: 1.0625rem; font-weight: 700; line-height: 1.3; }
.card-title .icon { width: 20px; height: 20px; color: var(--accent-text); }
.card-flush { padding: 0; overflow: hidden; }

/* Champs */
.field > label, .field-label { display: block; margin-block-end: 6px; font-size: .9375rem; font-weight: 600; }
.field input[type="text"], .field input[type="email"], .field textarea {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 1.0625rem;
  line-height: 1.4;
  transition: border-color var(--dur-1), background-color var(--dur-1);
}
.field textarea { resize: vertical; min-height: 120px; }
.field select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1.5px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 1.0625rem;
}
.field select:focus-visible { outline: none; border-color: var(--focus); }
/* Choix d'une voix avec son extrait à écouter */
.voice-pick { display: flex; align-items: center; gap: 8px; }
.voice-pick select { flex: 1; min-width: 0; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); opacity: 1; }
.field input:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--focus); background: var(--surface); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field .hint { margin-block-start: 6px; }
.field-err { margin-block-start: 6px; font-size: .875rem; font-weight: 600; color: var(--danger); }
.field-err:empty { display: none; }
.input-code, html:lang(ar) .input-code { text-align: center; font-size: 1.75rem !important; font-weight: 700; letter-spacing: .4em !important; font-variant-numeric: tabular-nums; }

/* Pastilles de choix */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  transition: background-color var(--dur-1), color var(--dur-1), transform var(--dur-1) var(--ease);
}
button.chip:active, a.chip:active { transform: scale(.96); }
.chip.is-on { background: var(--accent); color: var(--on-accent); }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip-static { min-height: 34px; font-weight: 500; }

/* Étiquettes */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  font-size: .75rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-2);
  white-space: nowrap;
}
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-bad { background: var(--danger-soft); color: var(--danger); }
.badge-run { background: var(--accent-soft); color: var(--accent-text); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-dark { background: rgba(0, 0, 0, .55); color: #FFFFFF; }
.badge-run::before {
  content: "";
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-block-start-color: transparent;
  border-radius: 50%;
  animation: spin .9s linear infinite;
}

/* Sélecteur segmenté (boutons radio) */
.seg-group > legend { margin-block-end: 8px; font-size: .9375rem; font-weight: 600; }
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px;
  padding: 3px;
  border-radius: 14px;
  background: var(--surface-2);
}
.seg-opt { position: relative; display: block; }
.seg-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg-opt > span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 40px;
  padding: 6px 4px;
  border-radius: 11px;
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  color: var(--text-2);
  transition: background-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1);
}
.seg-opt small { font-size: .6875rem; font-weight: 600; opacity: .85; }
.seg-opt input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }

/* Interrupteur */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: var(--r-pill);
  background: var(--sep-strong);
  cursor: pointer;
  transition: background-color var(--dur-1);
}
.switch::before {
  content: "";
  position: absolute;
  inset-block-start: 3px;
  inset-inline-start: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: inset-inline-start var(--dur-1) var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::before { inset-inline-start: 23px; }

/* Lignes à interrupteur ou à case */
.opt-row { display: flex; align-items: center; gap: 14px; min-height: var(--tap); cursor: pointer; }
.opt-row .opt-main { flex: 1; min-width: 0; }
.opt-t { display: block; font-weight: 600; }
.opt-s { display: block; font-size: .875rem; color: var(--text-2); }
.checkbox {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin: 0;
  border: 2px solid var(--sep-strong);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition: background-color var(--dur-1), border-color var(--dur-1);
}
.checkbox::before {
  content: "";
  width: 12px;
  height: 7px;
  margin-block-start: -3px;
  border-inline-start: 2.5px solid #FFFFFF;
  border-block-end: 2.5px solid #FFFFFF;
  transform: rotate(-45deg) scale(0);
  transition: transform var(--dur-1) var(--ease);
}
[dir="rtl"] .checkbox::before { transform: rotate(45deg) scale(0); }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::before { transform: rotate(-45deg) scale(1); }
[dir="rtl"] .checkbox:checked::before { transform: rotate(45deg) scale(1); }

/* Pastille radio dessinée */
.radio-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid var(--sep-strong);
  border-radius: 50%;
  color: transparent;
  transition: background-color var(--dur-1), border-color var(--dur-1);
}
.radio-mark .icon { width: 16px; height: 16px; stroke-width: 2.6; }
input:checked ~ .radio-mark, .is-on > .radio-mark { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Conseil de l'assistant et notes */
.tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  font-size: .9375rem;
  line-height: 1.45;
}
html:lang(ar) .tip { line-height: 1.65; }
.tip .icon { width: 20px; height: 20px; margin-block-start: 1px; color: var(--accent-text); }
.note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: .9375rem;
}
.note .icon { margin-block-start: 1px; }
.note-t { font-weight: 700; }
.note-ok { background: var(--success-soft); }
.note-ok .icon { color: var(--success); }
.note-warn { background: var(--warning-soft); }
.note-warn .icon { color: var(--warning); }
.note-bad { background: var(--danger-soft); }
.note-bad .icon { color: var(--danger); }
.note .btn { margin-block-start: 10px; }

/* Indicateur d'étapes (téléphone et tablette) */
.stepper ol { display: flex; align-items: center; }
.stepper li { position: relative; flex: 1; display: flex; justify-content: center; }
.stepper li + li::before {
  content: "";
  position: absolute;
  inset-block-start: 50%;
  inset-inline-end: calc(50% + 16px);
  width: calc(100% - 32px);
  height: 2px;
  margin-block-start: -1px;
  border-radius: 2px;
  background: var(--sep-strong);
}
.stepper li.is-done + li::before, .stepper li.is-reached::before { background: var(--accent); }
.step-item { display: grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: 50%; }
.step-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: .8125rem;
  font-weight: 700;
  color: var(--text-2);
  transition: background-color var(--dur-1), color var(--dur-1), transform var(--dur-1) var(--ease);
}
.step-dot .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.is-done .step-dot { background: var(--accent-soft-2); color: var(--accent-text); }
.is-open .step-dot { background: var(--accent-soft); color: var(--accent-text); }
.is-current .step-dot { background: var(--accent); color: var(--on-accent); transform: scale(1.15); }
.stepper-now { margin-block-start: 2px; text-align: center; font-size: .8125rem; font-weight: 600; color: var(--text-2); }

/* En-tête de page */
.page-head > * + * { margin-block-start: 12px; }

/* Zone de photo */
.photo { display: flex; flex-direction: column; gap: 14px; }
.photo-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  max-height: min(36vh, 320px);
  border: 2px dashed var(--sep-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  overflow: hidden;
  text-align: center;
}
.photo.has-img .photo-frame { border-style: solid; border-color: transparent; }
.photo-frame img { width: 100%; height: 100%; max-height: min(36vh, 320px); object-fit: contain; }
.photo-empty { padding: 24px 20px; color: var(--text-2); }
.photo-empty .icon { width: 40px; height: 40px; margin: 0 auto 10px; color: var(--accent-text); }
.photo-pick-area { cursor: pointer; }
.photo-pick-area .photo-empty > span { display: block; font-size: .9375rem; }
.photo-pick-area:hover, .photo:has(input:focus-visible) .photo-pick-area { border-color: var(--accent-text); background: var(--accent-soft); }
.photo-empty .hint { margin-block-start: 6px; }
.photo-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-actions .btn { flex: 1; min-width: 150px; }
.file-btn { position: relative; cursor: pointer; }
.file-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Barre de progression native */
progress.bar {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
  color: var(--accent);
}
progress.bar::-webkit-progress-bar { background: var(--surface-2); border-radius: var(--r-pill); }
progress.bar::-webkit-progress-value { background: var(--accent); border-radius: var(--r-pill); transition: width .9s linear; }
progress.bar::-moz-progress-bar { background: var(--accent); border-radius: var(--r-pill); }

/* Détails repliables */
.details > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-size: .9375rem;
  font-weight: 600;
  color: var(--accent-text);
  cursor: pointer;
  list-style: none;
}
.details > summary::-webkit-details-marker { display: none; }
.details > summary .icon { width: 18px; height: 18px; transition: transform var(--dur-1) var(--ease); }
.details[open] > summary .icon { transform: rotate(90deg); }
[dir="rtl"] .details:not([open]) > summary .icon { transform: scaleX(-1); }
.prompt {
  max-height: 280px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: .8125rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-align: start;
  unicode-bidi: plaintext;
}

/* Tableau clé / valeur */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; font-size: .9375rem; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; font-weight: 600; text-align: end; }

/* Feuille depuis le bas (téléphone), boîte centrée (grand écran) */
dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 100%;
  max-height: min(90dvh, 760px);
  margin: 0;
  padding: 0;
  border: 0;
  border-start-start-radius: var(--r-lg);
  border-start-end-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in var(--dur-3) var(--ease); }
dialog.sheet.closing { animation: sheet-out var(--dur-1) ease-in forwards; }
dialog.sheet::backdrop { background: var(--overlay); animation: fade-in var(--dur-2) ease; }
dialog.sheet.closing::backdrop { opacity: 0; transition: opacity var(--dur-1); }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { to { transform: translateY(100%); } }
.sheet-grabber { flex: none; width: 40px; height: 5px; margin: 8px auto 0; border-radius: var(--r-pill); background: var(--sep-strong); }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 20px; padding-inline: 20px 8px; }
.sheet-title { flex: 1; min-width: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.25; }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 20px 20px; }
.sheet-body > * + * { margin-block-start: 16px; }
.sheet-foot {
  flex: none;
  display: flex;
  gap: 10px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
  border-block-start: 1px solid var(--sep);
}
.sheet-foot:empty { display: none; }

@media (min-width: 640px) {
  dialog.sheet {
    inset: 0;
    width: min(520px, calc(100% - 48px));
    height: fit-content;
    max-height: min(84dvh, 760px);
    margin: auto;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-2);
  }
  dialog.sheet[open] { animation: pop-in var(--dur-2) var(--ease); }
  dialog.sheet.closing { animation: pop-out var(--dur-1) ease-in forwards; }
  .sheet-grabber { display: none; }
  .sheet-head { padding-block-start: 14px; }
  .sheet-foot { padding-block-end: 16px; }
}
@keyframes pop-in { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop-out { to { opacity: 0; transform: scale(.97); } }

/* Notifications brèves */
.toasts {
  position: fixed;
  z-index: 100;
  inset-inline: 0;
  inset-block-start: calc(env(safe-area-inset-top, 0px) + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-inline: 16px;
  pointer-events: none;
}
.toast {
  max-width: 440px;
  padding: 12px 18px;
  border-radius: var(--r-md);
  background: var(--text);
  color: var(--bg);
  font-size: .9375rem;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  box-shadow: var(--shadow-2);
  animation: toast-in var(--dur-2) var(--ease);
  transition: opacity var(--dur-1), transform var(--dur-1);
}
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* État vide */
.empty { padding: 28px 20px; text-align: center; }
.empty .icon { width: 44px; height: 44px; margin: 0 auto 12px; color: var(--accent-text); }
.empty h2 { font-size: 1.1875rem; font-weight: 700; }
.empty p { margin-block-start: 6px; color: var(--text-2); font-size: .9375rem; }
.empty .btn { margin-block-start: 16px; }

/* Pastille de chargement */
.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  flex: none;
  border: 3px solid var(--accent-soft-2);
  border-block-start-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner-lg { width: 40px; height: 40px; border-width: 4px; }

/* Formats d'image */
.ar-9x16 { aspect-ratio: 9 / 16; }
.ar-1x1 { aspect-ratio: 1 / 1; }
.ar-16x9 { aspect-ratio: 16 / 9; }

/* Client visé par la pub (étape Produit) et conseil du catalogue (étape Personnage) */
.persona-card { min-inline-size: 0; }
.persona-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.persona-new { flex: none; color: var(--accent-text); }
.persona-new .icon { inline-size: 16px; block-size: 16px; }
.persona-hint { margin-block: 2px 12px; }
.persona-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.persona-item {
  display: flex; align-items: center; gap: 4px;
  border: 1.5px solid var(--sep); border-radius: var(--r-md); background: var(--surface);
}
.persona-item.is-on { border-color: var(--accent-text); background: var(--accent-soft); }
.persona-pick {
  display: flex; align-items: flex-start; gap: 12px; flex: 1; min-inline-size: 0;
  min-block-size: var(--tap); padding: 12px; text-align: start; border-radius: inherit;
}
.persona-mark {
  display: grid; place-items: center; flex: none; inline-size: 22px; block-size: 22px; margin-block-start: 1px;
  border: 1.5px solid var(--sep-strong); border-radius: 50%;
}
.persona-item.is-on .persona-mark { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.persona-mark .icon { inline-size: 14px; block-size: 14px; stroke-width: 2.5; }
.persona-copy { display: grid; gap: 2px; min-inline-size: 0; }
.persona-copy strong { font-weight: 650; }
.persona-copy > span { font-size: .86rem; line-height: 1.45; color: var(--text-2); }
.persona-copy > .persona-need { color: var(--text); }
.persona-edit { flex: none; margin-inline-end: 4px; }
.persona-ask { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-block-start: 10px; }
.persona-wait { display: grid; gap: 8px; }
.persona-card > .note { margin-block-start: 10px; }
.cast-advice { margin-block: 4px 14px; }
.cast-advice .btn { margin-block-start: 8px; }
