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

/* ------------------------------ Boutons --------------------------------- */
.btn {
  --bg: var(--ink); --fg: #fff; --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); }

.btn-primary { --bg: var(--orange-500); --fg: #fff; box-shadow: var(--sh-orange); }
.btn-primary:hover { --bg: var(--orange-600); box-shadow: 0 18px 40px -12px rgba(255,110,20,.7); }
.btn-dark { --bg: var(--ink); --fg: #fff; box-shadow: var(--sh-md); }
.btn-dark:hover { --bg: #000; }
.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(--orange-50); --fg: var(--orange-700); }
.btn-soft:hover { --bg: var(--orange-100); }
.btn-white { --bg: #fff; --fg: var(--ink); 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: #fbe0de; }
.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; }
.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: #0c8c51; }
.badge-red    { background: var(--red-50); color: #c5352c; }
.badge-amber  { background: var(--amber-50); color: #b97c05; }
.badge-orange { background: var(--orange-50); color: var(--orange-700); }
.badge-blue   { background: var(--blue-50); color: #1f51d6; }
.badge-violet { background: var(--violet-50); color: #5b3fd6; }
.badge-ink    { background: var(--ink); color: #fff; }
.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(--orange-500); border-color: var(--orange-500); color: #fff; box-shadow: var(--sh-orange); }
.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: #0c8c51;
}
.score.mid { background: var(--amber-50); color: #b97c05; }
.score.low { background: var(--red-50); color: #c5352c; }

/* ------------------------------ Formulaires ----------------------------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: .82rem; font-weight: 700; color: var(--slate-700); }
.input, .select, .textarea {
  width: 100%; padding: 12px 14px;
  background: var(--surface); border: 1.5px solid var(--border-2);
  border-radius: var(--r-sm); font-size: .94rem; 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(--orange-400); box-shadow: var(--ring); outline: none; }
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.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; }

.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(--orange-500); border: 3px solid #fff; box-shadow: var(--sh-sm); 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(--orange-500); }
.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(--orange-500); border-color: var(--orange-500); 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"); 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(--orange-500); }
.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: #fff; 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: 18px; 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(--orange-500);
  border-radius: var(--r-sm); box-shadow: var(--sh-lg); padding: 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(--orange-500); }
.toast.info { border-left-color: var(--blue-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(--orange-50); color: var(--orange-600); }
.toast.info .ic { background: var(--blue-50); color: var(--blue-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: auto; animation: pop .3s var(--ease-spring); }
.modal.wide { max-width: 760px; }
.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(--orange-400), var(--orange-600)); transition: width .6s var(--ease); }

.empty { text-align: center; padding: 48px 24px; color: var(--slate-500); }
.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); }
.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); }
