/* ============================================================
 *  bubble.css — bulle de tchat privé (toutes les pages)
 *  Tout est préfixé .chb. Position : .chb--left / .chb--right
 *  Thème 2027 (.chb--t2027) : remontée au-dessus de la barre d'onglets.
 * ============================================================ */
.chb {
  --chb-bg: #131a24; --chb-bg2: #0f1520; --chb-line: rgba(255,255,255,.09);
  --chb-text: #e5e7eb; --chb-muted: #9ca3af; --chb-acc: #a855f7; --chb-acc2: #c084fc; --chb-ok: #34d399;
  --chb-x: 20px; --chb-y: 20px;
  position: fixed; z-index: 9990; bottom: var(--chb-y);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 14px; line-height: 1.45;
  color: var(--chb-text);
}
.chb *, .chb *::before, .chb *::after { box-sizing: border-box; }
.chb [hidden] { display: none !important; }
.chb--left  { left: var(--chb-x); }
.chb--right { right: var(--chb-x); }
.chb--t2027 { --chb-y: calc(96px + env(safe-area-inset-bottom, 0px)); --chb-x: 14px; }

/* ── Bouton rond ─────────────────────────────────────────── */
.chb-fab {
  position: relative; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(135deg, var(--chb-acc), #6d28d9); color: #fff; font-size: 22px;
  box-shadow: 0 10px 28px -6px rgba(168,85,247,.6), 0 2px 6px rgba(0,0,0,.4);
  display: grid; place-items: center; transition: transform .15s;
}
.chb-fab:hover { transform: scale(1.06); }
.chb-fab:focus-visible { outline: 3px solid rgba(192,132,252,.6); outline-offset: 3px; }
.chb-ico-close { display: none; }
.chb.is-open .chb-ico-open { display: none; }
.chb.is-open .chb-ico-close { display: inline-block; }
.chb-dot {
  position: absolute; right: 2px; bottom: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: #6b7280; border: 2px solid #1a1030;
}
.chb.is-online .chb-dot { background: var(--chb-ok); animation: chb-pulse 2s infinite; }
@keyframes chb-pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.6); } 70% { box-shadow: 0 0 0 8px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }
.chb-badge {
  position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
  border: 2px solid #0a0e14;
}

/* ── Panneau ─────────────────────────────────────────────── */
.chb-panel {
  position: absolute; bottom: 70px; width: 340px; height: 470px; max-height: calc(100vh - var(--chb-y) - 90px);
  background: var(--chb-bg); border: 1px solid var(--chb-line); border-radius: 18px;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,.7); display: flex; flex-direction: column; overflow: hidden;
  animation: chb-in .18s ease-out;
}
.chb--left  .chb-panel { left: 0; transform-origin: bottom left; }
.chb--right .chb-panel { right: 0; transform-origin: bottom right; }
@keyframes chb-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.chb-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--chb-line);
  background: radial-gradient(260px 80px at 0 0, rgba(168,85,247,.22), transparent 70%), rgba(255,255,255,.02); }
.chb-av { position: relative; width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--chb-acc), #6366f1); color: #fff; font-weight: 700; }
.chb-av i { position: absolute; right: -1px; bottom: -1px; width: 12px; height: 12px; border-radius: 50%; background: #6b7280; border: 2px solid var(--chb-bg); }
.chb.is-online .chb-av i { background: var(--chb-ok); }
.chb-who { flex: 1; min-width: 0; }
.chb-who strong { display: block; color: #fff; font-size: 14px; }
.chb-who small { display: block; color: var(--chb-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chb.is-online [data-chb-label] { color: var(--chb-ok); font-weight: 600; }
.chb-expand { color: var(--chb-muted); padding: 6px; border-radius: 8px; text-decoration: none; }
.chb-expand:hover { color: #fff; background: rgba(255,255,255,.06); }

.chb-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 3px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.chb-empty { margin: auto; text-align: center; color: var(--chb-muted); padding: 0 12px; }
.chb-empty i { font-size: 30px; color: var(--chb-acc2); opacity: .7; margin-bottom: 8px; }
.chb-empty p, .chb-locked p { margin: 0; }
.chb-empty b { color: #fff; }
.chb-day { align-self: center; margin: 8px 0 4px; padding: 2px 10px; border-radius: 999px; font-size: 11px; color: var(--chb-muted); background: rgba(255,255,255,.05); }
.chb-msg { display: flex; flex-direction: column; max-width: 84%; margin-top: 3px; }
.chb-msg.is-me { align-self: flex-end; align-items: flex-end; }
.chb-msg.is-admin { align-self: flex-start; }
.chb-bubble { padding: 7px 11px; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.is-me .chb-bubble { background: linear-gradient(135deg, var(--chb-acc), #7c3aed); color: #fff; border-bottom-right-radius: 4px; }
.is-admin .chb-bubble { background: #1f2937; border: 1px solid var(--chb-line); border-bottom-left-radius: 4px; }
.chb-meta { font-size: 10.5px; color: var(--chb-muted); margin: 2px 4px 0; }

.chb-typing { padding: 0 14px 6px; font-size: 12px; color: var(--chb-muted); display: flex; gap: 3px; align-items: center; }
.chb-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--chb-muted); animation: chb-blink 1.2s infinite; }
.chb-typing span:nth-child(2) { animation-delay: .2s; } .chb-typing span:nth-child(3) { animation-delay: .4s; margin-right: 5px; }
@keyframes chb-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chb-err { margin: 0 12px 8px; padding: 6px 10px; border-radius: 8px; font-size: 12.5px; background: rgba(248,113,113,.12); color: #fecaca; }

.chb-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--chb-line); margin: 0; }
.chb .chb-input textarea {
  flex: 1; margin: 0; min-height: 40px; max-height: 110px; resize: none; padding: 10px 12px; border-radius: 12px;
  background: var(--chb-bg2); color: var(--chb-text); border: 1px solid rgba(255,255,255,.14);
  font: inherit; font-size: 13.5px; outline: none; box-shadow: none;
}
.chb .chb-input textarea:focus { border-color: var(--chb-acc); box-shadow: 0 0 0 3px rgba(168,85,247,.2); }
.chb-input button { flex: 0 0 auto; width: 40px; height: 40px; border: 0; border-radius: 12px; cursor: pointer;
  background: linear-gradient(135deg, var(--chb-acc), #7c3aed); color: #fff; font-size: 14px; }
.chb-input button:disabled { opacity: .55; cursor: wait; }

.chb-locked { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; }
.chb-locked > i { font-size: 32px; color: var(--chb-acc2); opacity: .8; }
.chb-locked p { color: var(--chb-muted); }
.chb-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%; padding: 10px 14px; border-radius: 11px;
  background: linear-gradient(135deg, var(--chb-acc), #7c3aed); color: #fff !important; text-decoration: none !important; font-weight: 600; font-size: 13.5px; border: 1px solid transparent; }
.chb-btn--ghost { background: transparent; border-color: rgba(255,255,255,.16); color: var(--chb-text) !important; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 640px) {
  .chb { --chb-x: 12px; }
  .chb-fab { width: 50px; height: 50px; font-size: 20px; }
  .chb-panel { position: fixed; left: 10px !important; right: 10px !important; width: auto; bottom: calc(var(--chb-y) + 62px); height: min(470px, calc(100vh - var(--chb-y) - 90px)); }
}
@media (prefers-reduced-motion: reduce) { .chb * { animation: none !important; transition: none !important; } }
@media print { .chb { display: none !important; } }
