/* BioCollex AI Support Agent — widget styles. Scoped under #bcx-agent. */
#bcx-agent {
  --bcx-accent: #1E6FD9;
  --bcx-ink: #0E1A2B;
  --bcx-bg: #ffffff;
  --bcx-soft: #F3F6FA;
  --bcx-line: #E3E8EF;
  --bcx-text: #142033;
  --bcx-muted: #64748B;
  position: fixed; bottom: 20px; z-index: 2147483647;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  color: var(--bcx-text);
}
#bcx-agent *, #bcx-agent *::before, #bcx-agent *::after { box-sizing: border-box; }
#bcx-agent.bcx-pos-right { right: 20px; }
#bcx-agent.bcx-pos-left { left: 20px; }

#bcx-agent .bcx-launcher {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--bcx-ink); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(14, 26, 43, .28); position: relative;
  transition: transform .2s ease, background .2s ease;
}
#bcx-agent .bcx-launcher:hover { transform: translateY(-2px); background: var(--bcx-accent); }
#bcx-agent .bcx-launcher svg { width: 26px; height: 26px; }
#bcx-agent .bcx-dot {
  position: absolute; top: 8px; right: 9px; width: 11px; height: 11px; border-radius: 50%;
  background: #22C55E; border: 2px solid var(--bcx-ink);
}
#bcx-agent.bcx-open .bcx-launcher { transform: scale(.92); }

/* The panel is promoted to the browser's top layer (popover) when open, so no site element
   can sit on top of it. It is positioned against the viewport either way. */
#bcx-agent .bcx-panel {
  position: fixed; inset: auto; bottom: 94px; margin: 0; padding: 0; border: 0;
  width: 384px; max-width: calc(100vw - 40px); height: min(640px, calc(100vh - 120px));
  color: var(--bcx-text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  z-index: 2147483647;
  background: var(--bcx-bg); border-radius: 18px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(14, 26, 43, .22), 0 0 0 1px rgba(14, 26, 43, .06);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none; transform: translateY(12px) scale(.98);
  transition: opacity .18s ease, transform .18s ease;
}
#bcx-agent.bcx-pos-right .bcx-panel { right: 20px; }
#bcx-agent.bcx-pos-left .bcx-panel { left: 20px; }
#bcx-agent .bcx-panel::backdrop { background: transparent; }
#bcx-agent.bcx-open .bcx-panel { opacity: 1; pointer-events: auto; transform: none; }

#bcx-agent .bcx-head {
  background: var(--bcx-ink); color: #fff; padding: 14px 12px 14px 16px;
  display: flex; align-items: center; gap: 10px; flex: none;
}
#bcx-agent .bcx-avatar { width: 36px; height: 36px; border-radius: 10px; background: #fff; object-fit: contain; padding: 4px; }
#bcx-agent .bcx-avatar-fallback { display: grid; place-items: center; color: var(--bcx-ink); font-weight: 700; }
#bcx-agent .bcx-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#bcx-agent .bcx-title strong { font-size: 15px; letter-spacing: .01em; }
#bcx-agent .bcx-title span { font-size: 11.5px; opacity: .75; display: flex; align-items: center; gap: 6px; }
#bcx-agent .bcx-title i { width: 7px; height: 7px; border-radius: 50%; background: #22C55E; display: inline-block; }
#bcx-agent .bcx-icon {
  width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: #fff;
  cursor: pointer; display: grid; place-items: center; opacity: .8;
}
#bcx-agent .bcx-icon:hover { background: rgba(255, 255, 255, .12); opacity: 1; }
#bcx-agent .bcx-icon svg { width: 18px; height: 18px; fill: none; }

#bcx-agent .bcx-body { flex: 1; overflow-y: auto; padding: 16px 14px 8px; background: var(--bcx-soft); scroll-behavior: smooth; }
#bcx-agent .bcx-msg { display: flex; margin: 0 0 10px; }
#bcx-agent .bcx-user { justify-content: flex-end; }
#bcx-agent .bcx-bubble {
  max-width: 86%; padding: 10px 13px; border-radius: 14px; word-wrap: break-word; overflow-wrap: anywhere;
}
#bcx-agent .bcx-bot .bcx-bubble { background: #fff; border: 1px solid var(--bcx-line); border-top-left-radius: 4px; }
#bcx-agent .bcx-user .bcx-bubble { background: var(--bcx-accent); color: #fff; border-top-right-radius: 4px; }
#bcx-agent .bcx-bubble p { margin: 0 0 6px; }
#bcx-agent .bcx-bubble p:last-child { margin-bottom: 0; }
#bcx-agent .bcx-bubble ul { margin: 4px 0 6px; padding-left: 18px; }
#bcx-agent .bcx-bubble li { margin: 2px 0; }
#bcx-agent .bcx-bubble a { color: var(--bcx-accent); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

#bcx-agent .bcx-typing .bcx-bubble { display: flex; gap: 4px; padding: 13px 14px; }
#bcx-agent .bcx-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--bcx-muted); animation: bcx-b 1.2s infinite ease-in-out; }
#bcx-agent .bcx-typing span:nth-child(2) { animation-delay: .15s; }
#bcx-agent .bcx-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bcx-b { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

#bcx-agent .bcx-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
#bcx-agent .bcx-chip {
  border: 1px solid var(--bcx-line); background: #fff; color: var(--bcx-ink); border-radius: 999px;
  padding: 6px 12px; font: 600 12.5px/1.2 inherit; cursor: pointer; text-decoration: none;
}
#bcx-agent .bcx-chip:hover { border-color: var(--bcx-accent); color: var(--bcx-accent); }

#bcx-agent .bcx-cards { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 0 6px; scroll-snap-type: x mandatory; }
#bcx-agent .bcx-card {
  flex: 0 0 150px; background: #fff; border: 1px solid var(--bcx-line); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; gap: 4px; scroll-snap-align: start;
}
#bcx-agent .bcx-card-img { display: block; background: var(--bcx-soft); border-radius: 8px; aspect-ratio: 1; overflow: hidden; }
#bcx-agent .bcx-card-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
#bcx-agent .bcx-card-name { font-weight: 700; font-size: 13px; line-height: 1.25; }
#bcx-agent .bcx-card-price { font-size: 12px; color: var(--bcx-muted); }
#bcx-agent .bcx-card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }
#bcx-agent .bcx-btn, #bcx-agent .bcx-btn-ghost {
  flex: 1; text-align: center; border-radius: 8px; padding: 6px 4px; font: 600 12px/1.2 inherit; text-decoration: none;
}
#bcx-agent .bcx-btn { background: var(--bcx-accent); color: #fff; }
#bcx-agent .bcx-btn-ghost { border: 1px solid var(--bcx-line); color: var(--bcx-ink); }
#bcx-agent .bcx-oos { flex: 1; text-align: center; font-size: 11.5px; color: var(--bcx-muted); padding: 6px 0; }

#bcx-agent .bcx-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--bcx-line); background: #fff; flex: none; }
#bcx-agent .bcx-input textarea {
  flex: 1; resize: none; border: 1px solid var(--bcx-line); border-radius: 12px; padding: 10px 12px;
  font: inherit; color: var(--bcx-text); background: #fff; max-height: 120px; outline: none; margin: 0; min-height: 0;
}
#bcx-agent .bcx-input textarea:focus { border-color: var(--bcx-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bcx-accent) 18%, transparent); }
#bcx-agent .bcx-send {
  width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--bcx-accent); color: #fff;
  cursor: pointer; display: grid; place-items: center; flex: none; padding: 0;
}
#bcx-agent .bcx-send:disabled { opacity: .5; cursor: default; }
#bcx-agent .bcx-send svg { width: 18px; height: 18px; }

#bcx-agent .bcx-handoff { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bcx-soft); }
#bcx-agent .bcx-handoff[hidden], #bcx-agent .bcx-input[hidden], #bcx-agent .bcx-body[hidden] { display: none; }
#bcx-agent .bcx-ho-title { font-weight: 700; font-size: 15px; margin: 0 0 2px; }
#bcx-agent .bcx-handoff input, #bcx-agent .bcx-handoff textarea {
  width: 100%; border: 1px solid var(--bcx-line); border-radius: 10px; padding: 10px 12px; font: inherit; background: #fff; color: var(--bcx-text); margin: 0;
}
#bcx-agent .bcx-primary { border: 0; border-radius: 10px; padding: 11px; background: var(--bcx-accent); color: #fff; font: 700 14px/1 inherit; cursor: pointer; }
#bcx-agent .bcx-primary:disabled { opacity: .6; }
#bcx-agent .bcx-link { border: 0; background: none; color: var(--bcx-muted); cursor: pointer; font: inherit; text-decoration: underline; }
#bcx-agent .bcx-ho-status { margin: 0; font-size: 12.5px; color: #B42318; min-height: 1em; }

#bcx-agent .bcx-foot { font-size: 10.5px; line-height: 1.35; color: var(--bcx-muted); text-align: center; padding: 6px 14px 10px; background: #fff; flex: none; }
#bcx-agent .bcx-foot a { color: var(--bcx-muted); }

@media (max-width: 520px) {
  /* --bcx-lb lifts the launcher above Safari's floating link bar (set in JS). */
  #bcx-agent { bottom: var(--bcx-lb, 16px); }
  #bcx-agent.bcx-pos-right { right: 16px; }
  #bcx-agent.bcx-pos-left { left: 16px; }
  /* Full-screen on phones, edge to edge. JS sets top/height from the viewport (and from the
     visual viewport while the keyboard is up) and --bcx-pb, the bottom space that keeps the
     input and footer clear of Safari's floating link bar. */
  #bcx-agent .bcx-panel {
    position: fixed; left: 0; right: 0; bottom: auto;
    top: var(--bcx-top, 0px); width: 100%; max-width: none;
    height: var(--bcx-h, 100%); min-height: 0; border-radius: 0; box-shadow: none;
    padding-bottom: var(--bcx-pb, env(safe-area-inset-bottom, 0px));
    background: var(--bcx-bg);
  }
  #bcx-agent.bcx-pos-right .bcx-panel, #bcx-agent.bcx-pos-left .bcx-panel { left: 0; right: 0; }
  #bcx-agent .bcx-head { padding-top: calc(14px + env(safe-area-inset-top)); }
  #bcx-agent.bcx-open .bcx-launcher { display: none; }
  #bcx-agent .bcx-input textarea { font-size: 16px; } /* stops iOS zoom */
}
/* While the chat is open on a phone, the page behind it is hidden and frozen, so nothing
   shows around the panel — including the strip under Safari's translucent link bar. */
html.bcx-lock, html.bcx-lock body { overflow: hidden !important; background: #fff !important; }
html.bcx-lock body > *:not(#bcx-agent) { visibility: hidden !important; }
@media (prefers-reduced-motion: reduce) {
  #bcx-agent * { transition: none !important; animation: none !important; }
}
