/* ==========================================================================
   VTD BOT — Composants réutilisables
   ========================================================================== */

/* ------------------------------ Boutons --------------------------------- */
.btn {
  --bg: var(--ink); --fg: var(--canvas); --bd: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-body); font-weight: 700; font-size: .95rem; line-height: 1;
  padding: 13px 20px; border-radius: var(--r-pill);
  background: var(--bg); color: var(--fg); border: 1.5px solid var(--bd);
  transition: transform .18s var(--ease-spring), box-shadow .25s var(--ease), background .2s, color .2s, border-color .2s;
  white-space: nowrap; user-select: none;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.98); }

/* `background-image` en longhand : la shorthand `background: var(--bg)` de `.btn`
   remet l'image à `none`, mais elle est DÉCLARÉE PLUS HAUT, donc cette ligne gagne.
   Le survol ne change que `--bg` (la couleur de repli), jamais le dégradé. */
.btn-primary { --bg: var(--blue-500); --fg: #fff; background-image: var(--grad-brand);
  box-shadow: var(--sh-blue), var(--edge-light); }
.btn-primary:hover { --bg: var(--blue-600); box-shadow: 0 18px 40px -12px rgba(46,143,255,.7), var(--edge-light); }
.btn-dark { --bg: var(--ink); --fg: var(--canvas); box-shadow: var(--sh-md); }
.btn-dark:hover { --bg: #fff; }
.btn-ghost { --bg: transparent; --fg: var(--ink); --bd: var(--border-2); }
.btn-ghost:hover { --bg: var(--slate-50); --bd: var(--slate-300); }
.btn-soft { --bg: var(--blue-50); --fg: var(--blue-400); }
.btn-soft:hover { --bg: var(--blue-100); }
.btn-white { --bg: #fff; --fg: #121517; box-shadow: var(--sh-md); }
.btn-success { --bg: var(--green-500); --fg: #fff; }
.btn-danger-soft { --bg: var(--red-50); --fg: var(--red-500); }
.btn-danger-soft:hover { --bg: #3A1B18; }
.btn-lg { padding: 16px 28px; font-size: 1.02rem; }
.btn-sm { padding: 9px 14px; font-size: .85rem; gap: 6px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-icon { padding: 10px; border-radius: var(--r-sm); }
.btn-icon.btn-sm { padding: 7px; }
.btn-block { width: 100%; }
.btn:disabled, .btn[disabled] { opacity: .5; pointer-events: none; }

/* ------------------------------ Cartes ---------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 22px; }
.card-hover { transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s; }
/* Survol réservé aux appareils à souris (évite le « hover collant » au tap sur mobile). */
@media (hover: hover) { .card-hover:hover { transform: translateY(-4px); box-shadow: var(--sh-lg); border-color: var(--border-2); } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 1.08rem; }
.panel-body { padding: 22px; }

/* ------------------------------ Badges / chips -------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .76rem; font-weight: 700; line-height: 1;
  padding: 5px 10px; border-radius: var(--r-pill);
  background: var(--slate-100); color: var(--slate-600);
}
.badge svg { width: 13px; height: 13px; }
.badge-green  { background: var(--green-50); color: #3EDC92; }
.badge-red    { background: var(--red-50); color: #FF8078; }
.badge-amber  { background: var(--amber-50); color: #FFC14D; }
.badge-brand  { background: var(--blue-50); color: var(--blue-400); }
.badge-blue   { background: var(--info-50); color: var(--info-500); }
.badge-violet { background: var(--violet-50); color: #B9A5FF; }
.badge-teal   { background: #0A2A2C; color: #17C3CE; }   /* catégorie « Comparatif » (elle n'avait aucune couleur : elle retombait sur orange, comme « Guide ») */
.badge-ink    { background: var(--ink); color: var(--canvas); }
.badge-dot::before { content:""; width:6px; height:6px; border-radius:50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--surface); border: 1.5px solid var(--border-2);
  font-size: .85rem; font-weight: 600; color: var(--slate-600);
  transition: all .18s var(--ease); cursor: pointer;
}
.chip:hover { border-color: var(--slate-300); color: var(--ink); }
.chip.active { background: var(--grad-brand); border-color: var(--blue-600); color: #fff; box-shadow: var(--glow-xs), var(--edge-light); }
.chip svg { width: 15px; height: 15px; }

/* Pastille de score */
.score {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 14px;
  font-weight: 800; font-size: 1.05rem; font-family: var(--font-display);
  background: var(--green-50); color: #3EDC92;
}
.score.mid { background: var(--amber-50); color: #FFC14D; }
.score.low { background: var(--red-50); color: #FF8078; }

/* ------------------------------ Formulaires ----------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.label { font-size: .82rem; font-weight: 700; color: var(--slate-700); }
.input, .select, .textarea {
  width: 100%; min-width: 0; padding: 12px 14px;
  background: var(--surface); border: 1.5px solid var(--border-2);
  /* 16px MINIMUM : en dessous, iOS Safari zoome automatiquement au focus du champ
     (et le zoom reste ensuite sur tout VTD BOT). 16px = seuil qui désactive ce zoom. */
  border-radius: var(--r-sm); font-size: 16px; color: var(--ink);
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input::placeholder, .textarea::placeholder { color: var(--slate-400); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue-400); box-shadow: var(--ring); outline: none; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
/* iOS Safari : les inputs date/heure gardent une largeur intrinsèque native qui
   déborde des grilles étroites (min-width:0 ne suffit PAS sur WebKit). On enlève
   l'apparence native -> ils se dimensionnent comme un input normal (largeur 100 %).
   min-height conserve une hauteur tappable, text-align garde la valeur à gauche. */
input[type="date"].input, input[type="datetime-local"].input,
input[type="time"].input, input[type="month"].input {
  -webkit-appearance: none; appearance: none; min-height: 47px;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7488' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; cursor: pointer; }

/* ── Menu déroulant VTD BOT (remplace le <select> natif) ──────────────────────────── */
.bsel { position: relative; width: 100%; }
.bsel > select.select {                     /* natif conservé (source de vérité) mais masqué */
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
  clip: rect(0 0 0 0); overflow: hidden;
}
.bsel-btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 47px; padding: 12px 14px;
  background: var(--surface); border: 1.5px solid var(--border-2); border-radius: var(--r-sm);
  font-size: 16px; color: var(--ink); text-align: left; cursor: pointer;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.bsel-btn:hover { border-color: var(--slate-300); }
.bsel-open .bsel-btn, .bsel-btn:focus-visible {
  border-color: var(--blue-400); box-shadow: var(--ring); outline: none;
}
.bsel-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bsel-chev { color: var(--slate-500); flex: none; transition: transform .2s; }
.bsel-open .bsel-chev { transform: rotate(180deg); }
.bsel-disabled { opacity: .55; pointer-events: none; }

.bsel-menu {                                 /* rendu en PORTAIL dans <body> (position fixe) */
  position: fixed; z-index: 1200; box-sizing: border-box;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--sh-lg); padding: 6px; max-height: 300px; overflow-y: auto;
  display: none; -webkit-overflow-scrolling: touch;
}
.bsel-menu.open { display: block; animation: bselpop .14s ease; }
@keyframes bselpop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.bsel-opt {
  display: flex; align-items: center; gap: 9px; padding: 10px 11px; border-radius: 10px;
  font-size: 14.5px; color: var(--ink); cursor: pointer; line-height: 1.3; user-select: none;
}
.bsel-opt .bsel-ck { color: var(--blue-400); opacity: 0; flex: none; }
.bsel-opt.bsel-active:not(.bsel-sel) { background: var(--slate-50); }
.bsel-opt.bsel-sel { color: var(--blue-400); font-weight: 700; background: var(--blue-50); }
.bsel-opt.bsel-sel .bsel-ck { opacity: 1; }
.bsel-opt.bsel-sel.bsel-active { background: var(--blue-100); }

.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--slate-400); pointer-events: none; }
.input-icon .input { padding-left: 42px; }

.range { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 999px; background: var(--slate-200); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--grad-dot); border: 3px solid var(--canvas); box-shadow: var(--sh-sm), var(--glow-xs); cursor: pointer; transition: transform .15s; }
.range::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: var(--slate-300); border-radius: 999px; transition: background .22s; }
.switch .track::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .22s var(--ease-spring); box-shadow: var(--sh-xs); }
.switch input:checked + .track { background: var(--grad-brand); box-shadow: var(--glow-xs); }
.switch input:checked + .track::before { transform: translateX(18px); }

/* Checkbox */
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--slate-700); }
.check input { appearance: none; width: 20px; height: 20px; border: 1.8px solid var(--slate-300); border-radius: 6px; transition: all .15s; flex: none; }
.check input:checked { background: var(--blue-500); border-color: var(--blue-600); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E"), var(--grad-brand); background-repeat: no-repeat; background-position: center; }

/* Segmented control */
.segmented { display: inline-flex; padding: 4px; background: var(--slate-100); border-radius: var(--r-pill); gap: 2px; }
.segmented button { padding: 8px 16px; border-radius: var(--r-pill); font-weight: 700; font-size: .85rem; color: var(--slate-500); transition: all .18s; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-xs); }

/* ------------------------------ Avatars --------------------------------- */
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: .9rem; flex: none; background: var(--grad-brand); }
.avatar.sm { width: 32px; height: 32px; font-size: .78rem; }
.avatar.lg { width: 52px; height: 52px; font-size: 1.05rem; }

/* ------------------------------ Table ----------------------------------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-500); font-weight: 700; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 14px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: var(--slate-50); }

/* ------------------------------ Tooltip --------------------------------- */
.has-tip { position: relative; }
.has-tip[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: var(--canvas); font-size: .76rem; font-weight: 600; padding: 6px 10px; border-radius: 8px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50;
}
.has-tip:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------ Toast ----------------------------------- */
#toast-root { position: fixed; top: 76px; right: 18px; z-index: 9000; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--blue-500);
  border-radius: var(--r-sm); box-shadow: var(--sh-lg); padding: 14px 42px 14px 16px;
  animation: rise .35s var(--ease-spring); position: relative; overflow: hidden;
}
.toast.success { border-left-color: var(--green-500); }
.toast.alert { border-left-color: var(--blue-500); }
.toast.info { border-left-color: var(--info-500); }
.toast .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.toast.success .ic { background: var(--green-50); color: var(--green-500); }
.toast.alert .ic { background: var(--blue-50); color: var(--blue-400); }
.toast.info .ic { background: var(--blue-50); color: var(--info-500); }
.toast .ic svg { width: 19px; height: 19px; }
.toast strong { display: block; font-size: .92rem; }
.toast p { font-size: .84rem; margin-top: 2px; }
.toast .x { position: absolute; top: 8px; right: 8px; color: var(--slate-400); padding: 4px; border-radius: 6px; }
.toast .x:hover { background: var(--slate-100); color: var(--ink); }
.toast.out { animation: toastout .3s var(--ease) forwards; }
@keyframes toastout { to { opacity: 0; transform: translateX(20px); } }

/* ------------------------------ Modal ----------------------------------- */
#modal-root:empty { display: none; }
.modal-overlay { position: fixed; inset: 0; background: rgba(20,22,31,.45); backdrop-filter: blur(4px); z-index: 8000; display: grid; place-items: center; padding: 20px; animation: rise .25s var(--ease); }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-lg); width: 100%; max-width: 540px; max-height: 90vh; overflow-x: hidden; overflow-y: auto; animation: pop .3s var(--ease-spring); }
.modal.wide { max-width: 760px; }
@media (max-width: 560px) { .modal, .modal.wide { max-width: calc(100vw - 24px); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-head h3 { font-size: 1.2rem; }
.modal-body { padding: 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 24px; border-top: 1px solid var(--border); position: sticky; bottom: 0; background: var(--surface); }

/* ------------------------------ Divers ---------------------------------- */
.divider { height: 1px; background: var(--border); border: none; }
.skeleton { background: linear-gradient(90deg, var(--slate-100) 25%, var(--slate-200) 37%, var(--slate-100) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.progress { height: 8px; background: var(--slate-100); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-400), var(--blue-600)); transition: width .6s var(--ease); }

.empty { text-align: center; padding: 48px 24px; color: var(--slate-500); grid-column: 1 / -1; }
/* Dans une grille de résultats : occupe toute la largeur et se centre dans le vide */
.lgrid > .empty { min-height: 320px; display: grid; align-content: center; }
.empty .ic { width: 64px; height: 64px; border-radius: 20px; background: var(--slate-50); display: grid; place-items: center; margin: 0 auto 16px; color: var(--slate-400); }
/* L'action d'un empty-state : centrée horizontalement, jamais étirée ni débordante,
   quel que soit le conteneur (grille de résultats, panneau, etc.). */
.empty h4 { margin-bottom: 8px; }
.empty p { line-height: 1.55; max-width: 42ch; margin: 0 auto; }
.empty-act { display: flex; justify-content: center; margin-top: 20px; }
.empty-act .btn { width: auto; max-width: 100%; }
.empty .ic svg { width: 30px; height: 30px; }

.kbd { font-family: var(--font-body); font-size: .74rem; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--slate-100); border: 1px solid var(--border-2); border-bottom-width: 2px; color: var(--slate-600); }

.avatar.avatar-img { background-size: cover; background-position: center; color: transparent; }


/* ---------------- Relief des surfaces (ajout) --------------------------- */
/* Une carte sombre sur un fond sombre n'a aucune arête : elle se confond. Un voile
   de lumière de 130 px en haut suffit à la détacher, sans éclaircir tout le bloc.
   Posé en FIN de feuille : `.card` déclare `background` en shorthand plus haut, qui
   remettrait l'image à `none` si cette règle passait avant. */
.card, .panel, .preview-card, .feat-card { background-image: var(--sheen); }
/* Au survol, la lueur de marque s'ajoute à l'ombre noire — seule, l'ombre noire est
   presque invisible sur le fond de page. */
@media (hover: hover) {
  .card-hover:hover { box-shadow: var(--sh-lg), var(--glow-sm); }
}

/* ---------------- Sélecteur de langue (ajout) --------------------------- */
/* Le menu est posé au niveau <body> et positionné en `fixed` par le script :
   imbriqué dans l'en-tête, il héritait de son contexte d'empilement et passait
   sous le hero. Même piège que le menu mobile, réglé de la même façon. */
.lang-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 11px 8px 10px; border-radius: var(--r-pill);
  background: var(--slate-100); border: 1px solid var(--border);
  color: var(--ink); font-weight: 700; font-size: .82rem; line-height: 1;
  cursor: pointer; transition: background .18s var(--ease), border-color .18s var(--ease);
}
.lang-btn:hover { background: var(--slate-200); border-color: var(--border-2); }
.lang-btn svg { width: 15px; height: 15px; color: var(--slate-500); transition: transform .2s var(--ease); }
.lang-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.lang-btn.compact .lang-code { display: none; }
.lang-btn.compact { padding: 8px 9px; gap: 4px; }
/* Le drapeau est un emoji : sa boîte et son encre ne coïncident pas, et l'écart
   diffère entre iOS et macOS. On le laisse donc en flux, sans le centrer dans une
   boîte fixe — un centrage par la boîte le décale visiblement sur iPhone. */
.lang-flag { font-size: 1.05rem; line-height: 1; }

.lang-pop {
  position: fixed; z-index: 3000; min-width: 216px; padding: 7px;
  background: var(--paper); border: 1px solid var(--border-2);
  border-radius: var(--r-md); box-shadow: var(--sh-lg), var(--glow-sm);
  max-height: min(70vh, 460px); overflow-y: auto;
}
.lang-pop[hidden] { display: none; }
.lang-opt {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--ink); font-size: .92rem; font-weight: 600;
  cursor: pointer; text-align: left;
}
.lang-opt:hover { background: var(--slate-100); }
.lang-opt.on { background: var(--blue-50); color: var(--blue-400); }
.lang-nom { flex: 1; }
.lang-check { display: flex; color: var(--blue-400); }
.lang-check svg { width: 16px; height: 16px; }
.lp-mobile-lang { margin-top: 14px; }
