/* ============================================================
   Docs ONEQ · Floating chat widget styles
   ============================================================ */

#docsoneq-fab {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 100;
  font-family: var(--font-sans);
}

/* Trigger button */
.fab-trigger {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--grad-brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-lg), 0 0 0 0 rgba(31, 45, 140, 0.6);
  transition: all var(--dur) var(--ease-out);
  cursor: pointer;
}
.fab-trigger:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: var(--shadow-xl), 0 0 0 8px rgba(31, 45, 140, 0.12);
}
.fab-trigger.hidden { opacity: 0; pointer-events: none; transform: scale(0.7); }
.fab-icon { line-height: 1; }
.fab-pulse {
  position: absolute; right: 6px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%; background: var(--accent);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 0 rgba(49, 130, 246, 0.7);
  animation: fabPulse 2s infinite;
}
@keyframes fabPulse {
  0% { box-shadow: 0 0 0 0 rgba(49, 130, 246, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(49, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(49, 130, 246, 0); }
}

/* Panel */
.fab-panel {
  position: absolute;
  bottom: 0; right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 80px);
  background: var(--paper);
  border: 1px solid var(--ink-9);
  border-radius: 22px;
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0; transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transform-origin: bottom right;
  transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring);
}
.fab-panel.shown {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.fab-header {
  background: var(--grad-brand);
  color: white;
  padding: 16px 18px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  position: relative; overflow: hidden;
}
.fab-header::after {
  content: ""; position: absolute; right: -60px; top: -40px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(49, 130, 246, 0.4), transparent 70%);
  filter: blur(12px); pointer-events: none;
}
.fab-h-left { display: flex; align-items: center; gap: 10px; position: relative; z-index: 1; }
.fab-h-glyph {
  width: 36px; height: 36px; border-radius: 10px;
  overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.fab-h-glyph img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: 10px; }
.fab-h-meta { display: flex; flex-direction: column; gap: 2px; line-height: 1.25; }
.fab-h-title { font-size: 14px; font-weight: 700; }
.fab-h-status {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: rgba(255,255,255,0.78);
}
.fab-h-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
  animation: fabPulse 2s infinite;
}
.fab-close {
  width: 28px; height: 28px; border-radius: 8px;
  color: white; opacity: 0.7;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer;
  transition: all var(--dur);
  position: relative; z-index: 1;
}
.fab-close:hover { background: rgba(255,255,255,0.16); opacity: 1; }

/* Thread */
.fab-thread {
  flex: 1; overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 8px;
  background: var(--ink-10);
}
.fab-bubble {
  display: flex;
  max-width: 90%;
  animation: fabFade 280ms var(--ease-out);
}
@keyframes fabFade { from { opacity: 0; transform: translateY(6px); } }
.fab-bubble.agent { align-self: flex-start; }
.fab-bubble.user { align-self: flex-end; }
.fab-bubble .body {
  font-size: 13px; line-height: 1.55;
  padding: 9px 14px;
  border-radius: 16px;
  word-wrap: break-word;
}
.fab-bubble.agent .body {
  background: var(--paper);
  border: 1px solid var(--ink-9);
  border-bottom-left-radius: 4px;
  color: var(--ink-1);
  box-shadow: var(--shadow-xs);
}
.fab-bubble.user .body {
  background: var(--brand);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Typing dots */
.fab-bubble.typing .body { padding: 12px 16px; }
.fab-bubble.typing .dots {
  display: inline-flex; gap: 4px; align-items: center;
}
.fab-bubble.typing .dots span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ink-5);
  animation: typingBounce 1.2s infinite;
}
.fab-bubble.typing .dots span:nth-child(2) { animation-delay: 0.15s; }
.fab-bubble.typing .dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.6; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Chips */
.fab-chips {
  display: flex; gap: 6px;
  padding: 10px 14px;
  background: var(--paper);
  border-top: 1px solid var(--ink-9);
  overflow-x: auto;
  scrollbar-width: none;
}
.fab-chips::-webkit-scrollbar { display: none; }
.fab-chip {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px; font-weight: 600;
  background: var(--ink-10);
  border: 1px solid var(--ink-9);
  border-radius: var(--r-pill);
  color: var(--ink-3);
  cursor: pointer;
  transition: all var(--dur);
}
.fab-chip:hover {
  background: var(--brand-wash); color: var(--brand);
  border-color: rgba(31, 45, 140, 0.18);
}

/* Composer */
.fab-composer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 14px;
  background: var(--paper);
  border-top: 1px solid var(--ink-9);
}
.fab-composer input {
  flex: 1; height: 38px;
  padding: 0 14px;
  border: 1.5px solid var(--ink-8);
  border-radius: var(--r-pill);
  background: var(--ink-10);
  font-size: 13px;
  font-family: inherit;
  color: var(--ink-1);
  outline: none;
  transition: all var(--dur);
}
.fab-composer input:focus {
  border-color: var(--brand);
  background: var(--paper);
  box-shadow: 0 0 0 3px rgba(31, 45, 140, 0.08);
}
.fab-composer input::placeholder { color: var(--ink-6); }
.fab-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--brand); color: white;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--dur);
  flex-shrink: 0;
}
.fab-send:hover { background: var(--brand-2); transform: scale(1.06); }

/* Mobile */
@media (max-width: 540px) {
  #docsoneq-fab { bottom: 16px; right: 16px; }
  .fab-panel {
    position: fixed;
    right: 16px; bottom: 16px; left: 16px;
    width: auto;
    height: calc(100vh - 100px);
  }
}

/* When Tweaks panel is open, shift FAB up so it doesn't collide */
body.tweaks-open #docsoneq-fab { bottom: 90px; }
