/* ==========================================================
   ASSISTANT SWCI — widget de discussion (toutes pages)
========================================================== */
.swa {
  --swa-bg: #070a12;
  --swa-panel: rgba(9, 12, 20, .97);
  --swa-line: rgba(148, 163, 184, .16);
  --swa-line-strong: rgba(148, 163, 184, .3);
  --swa-text: #e8edf5;
  --swa-muted: #8a94a8;
  --swa-orange: #ff6b00;
  --swa-orange-2: #ff9a3c;
  --swa-cyan: #38bdf8;
  --swa-green: #22c55e;
  --swa-ease: cubic-bezier(.2, .7, .2, 1);
  --swa-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --swa-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--swa-text);
}
html.swa-lock { overflow: hidden; }

/* ---------- Bouton lanceur ---------- */
.swa-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 950;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #ff7a1a, #ff5500);
  color: #fff;
  font-size: 25px;
  cursor: pointer;
  box-shadow: 0 16px 36px -10px rgba(255, 107, 0, .85), inset 0 1px 0 rgba(255, 255, 255, .3);
  transition: transform .3s var(--swa-ease), border-radius .3s var(--swa-ease);
}
.swa-launcher:hover { transform: translateY(-3px) scale(1.04); }
.swa-launcher:focus-visible { outline: 2px solid var(--swa-cyan); outline-offset: 4px; }
.swa-launcher i { grid-area: 1 / 1; transition: transform .35s var(--swa-ease), opacity .25s; }
.swa-ico-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.swa.is-open .swa-ico-open { opacity: 0; transform: rotate(90deg) scale(.6); }
.swa.is-open .swa-ico-close { opacity: 1; transform: none; }
.swa.is-open .swa-launcher { border-radius: 50%; }
.swa-launcher-ring {
  position: absolute;
  inset: -6px;
  border-radius: 24px;
  border: 2px solid rgba(255, 107, 0, .55);
  animation: swa-ring 2.6s var(--swa-ease) infinite;
  pointer-events: none;
}
.swa.is-open .swa-launcher-ring { display: none; }
.swa-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #ef4444;
  border: 2px solid #05070d;
  color: #fff;
  font-family: var(--swa-mono);
  font-size: 11px;
  font-weight: 600;
}
.swa-badge[hidden] { display: none; }

/* ---------- Bulle d'invitation ---------- */
.swa-teaser {
  position: fixed;
  right: 98px;
  bottom: 30px;
  z-index: 949;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 260px;
  padding: 14px 38px 14px 16px;
  border-radius: 16px 16px 4px 16px;
  background: rgba(9, 12, 20, .96);
  border: 1px solid var(--swa-line-strong);
  box-shadow: 0 20px 50px -15px rgba(0, 0, 0, .9);
  font-size: 13px;
  line-height: 1.45;
  color: #cbd5e1;
  cursor: pointer;
  animation: swa-in .5s var(--swa-ease);
}
.swa-teaser[hidden] { display: none; }
.swa-teaser strong { color: #fff; font-family: var(--swa-display); font-size: 14px; }
.swa-teaser::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 16px;
  width: 34px;
  height: 2px;
  background: var(--swa-orange);
  box-shadow: 0 0 8px var(--swa-orange);
}
.swa-teaser-close {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .06);
  color: var(--swa-muted);
  font-size: 11px;
  cursor: pointer;
}
.swa-teaser-close:hover { color: #fff; background: rgba(255, 255, 255, .12); }

/* ---------- Panneau ---------- */
.swa-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 960;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 130px));
  overflow: hidden;
  border-radius: 22px;
  background: var(--swa-panel);
  border: 1px solid var(--swa-line-strong);
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 107, 0, .08);
  -webkit-backdrop-filter: blur(16px);
          backdrop-filter: blur(16px);
  transform-origin: 100% 100%;
  animation: swa-open .45s var(--swa-ease);
}
.swa-panel[hidden] { display: none; }
.swa-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 100% 0%, rgba(255, 107, 0, .14), transparent 45%),
    radial-gradient(ellipse at 0% 100%, rgba(56, 189, 248, .08), transparent 50%);
}

.swa-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px 14px 18px;
  border-bottom: 1px solid var(--swa-line);
}
.swa-avatar {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ff7a1a, #ff5500);
  color: #fff;
  font-size: 19px;
  box-shadow: 0 0 0 4px rgba(255, 107, 0, .12);
}
.swa-avatar::after {
  content: '';
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--swa-green);
  border: 2px solid #070a12;
}
.swa-id { flex: 1; min-width: 0; }
.swa-id strong { display: block; font-family: var(--swa-display); font-size: 16px; color: #fff; }
.swa-id span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--swa-mono);
  font-size: 10.5px;
  letter-spacing: .5px;
  color: var(--swa-muted);
}
.swa-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--swa-green);
  box-shadow: 0 0 8px var(--swa-green);
}
.swa-icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--swa-line);
  border-radius: 10px;
  background: rgba(255, 255, 255, .03);
  color: var(--swa-muted);
  font-size: 13px;
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.swa-icon-btn:hover { color: #fff; border-color: var(--swa-orange); }
.swa-icon-btn:focus-visible { outline: 2px solid var(--swa-cyan); outline-offset: 2px; }

/* ---------- Messages ---------- */
.swa-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .3) transparent;
}
.swa-msg { display: flex; }
.swa-msg.is-user { justify-content: flex-end; }
.swa-msg.is-new { animation: swa-in .4s var(--swa-ease); }
.swa-bubble {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.is-bot .swa-bubble {
  border-top-left-radius: 4px;
  background: rgba(22, 29, 45, .92);
  border: 1px solid var(--swa-line);
  color: #dbe2ec;
}
.is-user .swa-bubble {
  border-top-right-radius: 4px;
  background: linear-gradient(135deg, #ff7a1a, #ff5500);
  color: #fff;
  box-shadow: 0 10px 24px -14px rgba(255, 107, 0, .9);
}
.swa-bubble strong { color: #fff; }
.swa-bubble a { color: var(--swa-orange-2); text-decoration: underline; text-underline-offset: 2px; }
.swa-bubble small { color: var(--swa-muted); font-size: 11px; }
.swa-list { margin: 8px 0; padding: 0; list-style: none; }
.swa-list li {
  position: relative;
  margin-bottom: 5px;
  padding-left: 16px;
}
.swa-list li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: .62em;
  width: 6px;
  height: 6px;
  border-radius: 2px;
  background: var(--swa-orange);
}
.swa-list li i { width: 18px; color: var(--swa-orange-2); }
.swa-list li:has(i)::before { display: none; }
.swa-list li:has(i) { padding-left: 0; }
.swa-hint { display: inline-block; color: var(--swa-muted); font-size: 12px; }
.swa-step {
  display: block;
  margin-bottom: 4px;
  font-family: var(--swa-mono);
  font-size: 10.5px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--swa-orange-2);
}
.swa-card {
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(5, 8, 15, .8);
  border: 1px solid rgba(255, 107, 0, .35);
}
.swa-card-head {
  padding: 9px 12px;
  background: rgba(255, 107, 0, .12);
  border-bottom: 1px solid rgba(255, 107, 0, .25);
  font-family: var(--swa-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--swa-orange-2);
}
.swa-card dl { margin: 0; padding: 8px 12px 10px; }
.swa-card dl > div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 4px 0; }
.swa-card dl > div + div { border-top: 1px dashed var(--swa-line); }
.swa-card dt { font-size: 11.5px; color: var(--swa-muted); }
.swa-card dd { margin: 0; font-size: 12.5px; color: #fff; }
.swa-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.swa-act {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--swa-line-strong);
  background: rgba(255, 255, 255, .04);
  color: #fff !important;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none !important;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}
.swa-act:hover { border-color: var(--swa-orange); transform: translateY(-1px); }
.swa-act.is-primary { background: linear-gradient(135deg, #ff7a1a, #ff5500); border-color: transparent; }
.swa-act.is-wa { background: #16a34a; border-color: transparent; }
.swa-act.is-wa:hover { background: #22c55e; }

.swa-typing .swa-bubble { display: inline-flex; gap: 5px; padding: 14px 16px; }
.swa-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--swa-muted);
  animation: swa-dots 1.2s infinite ease-in-out;
}
.swa-typing span:nth-child(2) { animation-delay: .15s; }
.swa-typing span:nth-child(3) { animation-delay: .3s; }

/* ---------- Suggestions ---------- */
.swa-chips {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 128px;
  overflow-y: auto;
  padding: 8px 16px 10px;
}
.swa-chips[hidden] { display: none; }
.swa-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 107, 0, .45);
  background: rgba(255, 107, 0, .08);
  color: #ffd2ad;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  animation: swa-in .35s var(--swa-ease) backwards;
  transition: background .2s, color .2s, border-color .2s;
}
.swa-chip:nth-child(2) { animation-delay: .04s; }
.swa-chip:nth-child(3) { animation-delay: .08s; }
.swa-chip:nth-child(4) { animation-delay: .12s; }
.swa-chip:nth-child(5) { animation-delay: .16s; }
.swa-chip:nth-child(n+6) { animation-delay: .2s; }
.swa-chip:hover { background: var(--swa-orange); border-color: var(--swa-orange); color: #fff; }
.swa-chip:focus-visible { outline: 2px solid var(--swa-cyan); outline-offset: 2px; }

/* ---------- Saisie ---------- */
.swa-input {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--swa-line);
}
.swa-input input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--swa-line-strong);
  background: rgba(5, 8, 15, .85);
  color: #fff;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.swa-input input::placeholder { color: #5b6578; }
.swa-input input:focus { border-color: var(--swa-orange); box-shadow: 0 0 0 3px rgba(255, 107, 0, .14); }
.swa-input button {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #ff7a1a, #ff5500);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: transform .2s;
}
.swa-input button:hover { transform: translateY(-1px); }
.swa-input button:focus-visible { outline: 2px solid var(--swa-cyan); outline-offset: 2px; }

.swa-foot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0 14px 14px;
}
.swa-wa {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 11px;
  border: 0;
  border-radius: 12px;
  background: #16a34a;
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s;
}
.swa-wa i { font-size: 17px; }
.swa-wa:hover { background: #22c55e; }
.swa-wa:focus-visible { outline: 2px solid var(--swa-cyan); outline-offset: 2px; }
.swa-foot small { font-size: 10.5px; color: var(--swa-muted); text-align: center; }

/* ---------- Animations ---------- */
@keyframes swa-open { from { opacity: 0; transform: translateY(16px) scale(.94); } }
@keyframes swa-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes swa-dots { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes swa-ring { 0% { opacity: .9; transform: scale(.92); } 100% { opacity: 0; transform: scale(1.25); } }

/* ---------- Mobile : plein écran ---------- */
@media (max-width: 560px) {
  .swa-launcher { right: 16px; bottom: 16px; width: 56px; height: 56px; font-size: 22px; border-radius: 18px; }
  .swa-teaser { right: 84px; bottom: 20px; max-width: calc(100vw - 110px); }
  .swa-panel {
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .swa.is-open .swa-launcher { display: none; }
  .swa-head { padding-top: max(16px, env(safe-area-inset-top)); }
  .swa-foot { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .swa-bubble { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .swa *, .swa *::before, .swa *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
