/* ============================================================
   FloatChat — global floating CaseLead Assistant
   Shared across dashboard, cases page, case-workspace
   ============================================================ */

#floatchat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 80;
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--cl-accent, #3b82f6) 0%, var(--cl-ai-highlight, #a78bfa) 100%);
  color: white; border: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(59,130,246,0.45), 0 0 0 1px rgba(255,255,255,0.06) inset;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform 0.15s, box-shadow 0.2s;
}
#floatchat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 32px rgba(59,130,246,0.55); }
#floatchat-fab.hidden { display: none; }
#floatchat-fab .pulse-ring {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--cl-accent, #3b82f6); opacity: 0;
  animation: floatPulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes floatPulse {
  0% { opacity: 0.7; transform: scale(0.95); }
  100% { opacity: 0; transform: scale(1.18); }
}
#floatchat-panel {
  position: fixed; right: 22px; bottom: 22px; z-index: 81;
  width: min(440px, calc(100vw - 32px)); height: min(660px, calc(100vh - 96px));
  background-color: var(--cl-bg-elevated, #0f172a);
  border: 1px solid var(--cl-border, #475569);
  border-radius: 16px;
  box-shadow: 0 18px 36px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.02);
  display: none; flex-direction: column; overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
[data-theme="dark"] #floatchat-panel {
  background-color: #0f172a;
  background-image: linear-gradient(180deg, #131c2e 0%, #0b1220 100%);
}
[data-theme="light"] #floatchat-panel {
  background-color: #ffffff;
  background-image: linear-gradient(180deg, #ffffff 0%, #f4f6fb 100%);
}
#floatchat-panel.open { display: flex; }
#floatchat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--cl-border-subtle, #28344a);
  background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(168,85,247,0.06) 100%);
}
#floatchat-header .titles { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#floatchat-header .title-row { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700; color: var(--cl-text, #f1f5f9); }
#floatchat-header .case-pill {
  font-size: 0.62rem; font-weight: 600; padding: 2px 8px;
  border-radius: 6px; background: var(--cl-accent-soft, rgba(59,130,246,0.14)); color: var(--cl-accent, #3b82f6);
  text-transform: uppercase; letter-spacing: 0.05em;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
#floatchat-header .grounding-pill {
  font-size: 0.6rem; font-weight: 600; padding: 2px 7px;
  border-radius: 6px; background: rgba(34,197,94,0.12); color: var(--cl-success, #22c55e);
  display: inline-flex; align-items: center; gap: 4px;
}
#floatchat-header .grounding-pill .gdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
#floatchat-header button { background: none; border: none; color: var(--cl-text-muted, #8997b1); cursor: pointer; padding: 4px 8px; border-radius: 6px; font-size: 0.95rem; }
#floatchat-header button:hover { background: var(--cl-row-hover, rgba(255,255,255,0.04)); color: var(--cl-text, #f1f5f9); }
#floatchat-context {
  padding: 8px 14px;
  font-size: 0.7rem; color: var(--cl-text-muted, #8997b1);
  border-bottom: 1px solid var(--cl-border-subtle, #28344a);
  display: flex; align-items: center; gap: 6px;
  background: var(--cl-row-stripe, rgba(255,255,255,0.02));
}
#floatchat-suggestions {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--cl-border-subtle, #28344a);
}
#floatchat-suggestions .sugg {
  font-size: 0.7rem; padding: 5px 10px; border-radius: 999px;
  background: var(--cl-row-stripe, rgba(255,255,255,0.02)); border: 1px solid var(--cl-border-subtle, #28344a);
  color: var(--cl-text-secondary, #b0bcd0); cursor: pointer; transition: all 0.12s;
}
#floatchat-suggestions .sugg:hover { background: var(--cl-accent-soft, rgba(59,130,246,0.14)); color: var(--cl-accent, #3b82f6); border-color: var(--cl-accent, #3b82f6); }
#floatchat-messages {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  background-color: var(--cl-bg, #0b1220);
}
[data-theme="dark"] #floatchat-messages { background-color: #0a1020; }
[data-theme="light"] #floatchat-messages { background-color: #f4f6fb; }
.fc-msg { display: flex; flex-direction: column; gap: 4px; max-width: 100%; }
.fc-msg .who { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--cl-text-muted, #8997b1); font-weight: 600; }
.fc-msg .body {
  padding: 10px 12px; border-radius: 10px;
  font-size: 0.83rem; line-height: 1.55; color: var(--cl-text, #f1f5f9);
  background: var(--cl-surface, #1e293b); border: 1px solid var(--cl-border-subtle, #28344a);
  white-space: normal; word-wrap: break-word;
}
.fc-msg.user .body { background: var(--cl-accent-soft, rgba(59,130,246,0.14)); border-color: rgba(59,130,246,0.3); }
.fc-msg .body p { margin: 0 0 6px; }
.fc-msg .body p:last-child { margin-bottom: 0; }
.fc-msg .body ul, .fc-msg .body ol { margin: 4px 0 6px; padding-left: 18px; }
.fc-msg .body li { margin-bottom: 2px; }
.fc-msg .body strong { color: var(--cl-text, #f1f5f9); font-weight: 700; }
.fc-msg .body code { font-family: ui-monospace, monospace; font-size: 0.78em; padding: 1px 5px; border-radius: 4px; background: var(--cl-row-stripe, rgba(255,255,255,0.02)); border: 1px solid var(--cl-border-subtle, #28344a); }
.fc-citations { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.fc-citations .chip {
  font-size: 0.65rem; padding: 2px 7px; border-radius: 999px;
  background: rgba(34,197,94,0.10); color: var(--cl-success, #22c55e); border: 1px solid rgba(34,197,94,0.25);
}
.fc-typing { display: inline-flex; align-items: center; gap: 4px; }
.fc-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--cl-text-muted, #8997b1); animation: cl-dot-bounce 1.4s ease-in-out infinite; }
.fc-typing span:nth-child(2) { animation-delay: 0.2s; }
.fc-typing span:nth-child(3) { animation-delay: 0.4s; }
#floatchat-input-row {
  display: flex; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--cl-border-subtle, #28344a); background: var(--cl-bg-elevated, #0f172a);
}
#floatchat-input {
  flex: 1; resize: none; min-height: 38px; max-height: 110px;
  padding: 9px 12px; border-radius: 10px;
  background: var(--cl-input-bg, #0f172a); border: 1px solid var(--cl-input-border, #334155);
  color: var(--cl-text, #f1f5f9); font-size: 0.82rem; font-family: inherit;
}
#floatchat-input:focus { outline: none; border-color: var(--cl-accent, #3b82f6); box-shadow: 0 0 0 2px var(--cl-accent-soft, rgba(59,130,246,0.14)); }
#floatchat-send { padding: 0 14px; border-radius: 10px; background: var(--cl-accent, #3b82f6); color: white; border: none; font-weight: 600; cursor: pointer; font-size: 0.8rem; }
#floatchat-send:hover { background: var(--cl-accent-strong, #2563eb); }
#floatchat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 640px) {
  #floatchat-panel { right: 8px; left: 8px; bottom: 8px; width: auto; height: 78vh; }
  #floatchat-fab { right: 14px; bottom: 14px; }
}

/* Reusable dot-bounce keyframe (also defined in caselead-core.css; safe duplicate) */
@keyframes cl-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}
