/* ──────────────────────────────────────────────────────────────────────
   Biff AI chat widget — floating bubble + slide-up panel.
   Reuses brand palette from the main page CSS. Designed to drop in on
   any Biff AI page; the widget is self-scoped under #biff-chat.
   ────────────────────────────────────────────────────────────────────── */

/* Pair the bubble + "Ask Biff" pill side-by-side so the affordance is obvious */
#biff-chat-launcher-wrap {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 9000;
  display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}

#biff-chat-pill {
  pointer-events: auto;
  background: linear-gradient(135deg, #1E88E5 0%, #0D47A1 100%);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
  border: 0; cursor: pointer;
  box-shadow: 0 10px 30px rgba(13,71,161,0.45), 0 2px 8px rgba(0,0,0,0.2);
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform 160ms ease-out, box-shadow 200ms;
  font-family: inherit;
  white-space: nowrap;
}
#biff-chat-pill:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(13,71,161,0.55); }
#biff-chat-pill .arrow { font-size: 16px; line-height: 1; }
#biff-chat-pill .live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #43E97B;
  box-shadow: 0 0 0 0 rgba(67,233,123, 0.7);
  animation: biff-live-pulse 2s infinite;
}
@keyframes biff-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(67,233,123, 0.7); }
  70%  { box-shadow: 0 0 0 6px rgba(67,233,123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67,233,123, 0); }
}

#biff-chat-launcher {
  pointer-events: auto;
  width: 60px; height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1E88E5 0%, #0D47A1 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(13,71,161,0.45), 0 2px 8px rgba(0,0,0,0.2);
  border: 0;
  transition: transform 160ms ease-out, box-shadow 160ms;
  position: relative;
  font-size: 0;
}
#biff-chat-launcher:hover { transform: scale(1.06); box-shadow: 0 14px 36px rgba(13,71,161,0.55); }
#biff-chat-launcher svg { width: 26px; height: 26px; }
#biff-chat-launcher .pulse {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid #1E88E5; opacity: 0.6;
  animation: biff-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes biff-pulse {
  0%   { transform: scale(1);    opacity: 0.6; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* Peek tooltip — auto-appears on first visit to make the chat impossible to miss */
#biff-chat-peek {
  position: fixed;
  right: 24px; bottom: 96px;
  z-index: 8999;
  max-width: 260px;
  background: #fff; color: #222;
  padding: 14px 30px 14px 16px;
  border-radius: 14px;
  border: 1px solid #cfd8dc;
  box-shadow: 0 14px 40px rgba(13,71,161,0.18), 0 4px 12px rgba(0,0,0,0.08);
  font-size: 13.5px; line-height: 1.5;
  display: none; opacity: 0;
  transform: translateY(8px);
  transition: opacity 240ms ease-out, transform 240ms ease-out;
  cursor: pointer;
}
#biff-chat-peek.show { display: block; opacity: 1; transform: translateY(0); }
#biff-chat-peek::after {
  content: ''; position: absolute;
  right: 26px; bottom: -8px;
  width: 14px; height: 14px;
  background: #fff;
  border-right: 1px solid #cfd8dc;
  border-bottom: 1px solid #cfd8dc;
  transform: rotate(45deg);
}
#biff-chat-peek .peek-head {
  font-weight: 700; color: #0D47A1;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
  font-size: 13px;
}
#biff-chat-peek .peek-head .dot {
  width: 7px; height: 7px; background: #43E97B; border-radius: 50%;
}
#biff-chat-peek .peek-close {
  position: absolute; top: 6px; right: 8px;
  background: transparent; border: 0;
  color: #999; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 4px;
}
#biff-chat-peek .peek-close:hover { color: #333; }

@media (max-width: 520px) {
  #biff-chat-launcher-wrap { right: 14px; bottom: 14px; gap: 8px; }
  #biff-chat-pill { padding: 10px 14px; font-size: 13px; }
  #biff-chat-peek { right: 14px; bottom: 88px; max-width: 230px; }
}

#biff-chat-panel {
  position: fixed;
  right: 22px; bottom: 96px;
  width: min(380px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 130px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(13,71,161,0.25), 0 4px 16px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9001;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
#biff-chat-panel.open { display: flex; animation: biff-slide-up 220ms ease-out; }
@keyframes biff-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

#biff-chat-panel .header {
  background: linear-gradient(135deg, #0D47A1 0%, #082c66 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 2px solid #1E88E5;
}
#biff-chat-panel .header img {
  width: 36px; height: 36px; border-radius: 8px; background: #0A0A0A;
}
#biff-chat-panel .header .title {
  flex: 1;
  font-size: 15px; font-weight: 700; line-height: 1.2;
}
#biff-chat-panel .header .title .sub {
  display: block; font-size: 11px; font-weight: 400;
  color: #BBD7F2; letter-spacing: 0.04em; margin-top: 2px;
}
#biff-chat-panel .header .title .live-dot {
  display: inline-block; width: 8px; height: 8px;
  background: #43E97B; border-radius: 50%;
  vertical-align: middle; margin-right: 6px;
  box-shadow: 0 0 0 0 rgba(67,233,123, 0.7);
  animation: biff-live-pulse 2s infinite;
}
@keyframes biff-live-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(67,233,123, 0.7); }
  70%  { box-shadow: 0 0 0 8px rgba(67,233,123, 0); }
  100% { box-shadow: 0 0 0 0 rgba(67,233,123, 0); }
}
#biff-chat-panel .header button {
  background: rgba(255,255,255,0.1); color: #fff;
  border: 0; width: 32px; height: 32px; border-radius: 50%;
  cursor: pointer; font-size: 18px; line-height: 1;
}
#biff-chat-panel .header button:hover { background: rgba(255,255,255,0.2); }

#biff-chat-panel .messages {
  flex: 1; overflow-y: auto;
  padding: 16px;
  background: #F7F9FC;
  font-size: 14px; line-height: 1.55; color: #222;
}
#biff-chat-panel .msg { margin-bottom: 12px; display: flex; }
#biff-chat-panel .msg.user { justify-content: flex-end; }
#biff-chat-panel .msg .bubble {
  max-width: 88%;
  padding: 10px 14px; border-radius: 14px;
  white-space: pre-wrap; word-wrap: break-word;
}
#biff-chat-panel .msg.bot .bubble {
  background: #fff; border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}
#biff-chat-panel .msg.user .bubble {
  background: #0D47A1; color: #fff;
  border-bottom-right-radius: 4px;
}
#biff-chat-panel .msg.bot .bubble strong { color: #0D47A1; }

#biff-chat-panel .typing {
  display: inline-flex; gap: 4px; padding: 4px 0;
}
#biff-chat-panel .typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #1E88E5; opacity: 0.5;
  animation: biff-typing 1.2s infinite;
}
#biff-chat-panel .typing span:nth-child(2) { animation-delay: 0.2s; }
#biff-chat-panel .typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes biff-typing {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.5; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

#biff-chat-panel .suggest {
  padding: 6px 14px 14px;
  background: #F7F9FC;
  display: flex; gap: 8px; flex-wrap: wrap;
  border-top: 1px solid #e2e8f0;
}
#biff-chat-panel .suggest button {
  background: #fff; border: 1px solid #cfd8dc;
  color: #0D47A1;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; cursor: pointer;
  font-weight: 600;
  transition: background 140ms;
}
#biff-chat-panel .suggest button:hover { background: #E3F2FD; border-color: #1E88E5; }

#biff-chat-panel form.input {
  display: flex; gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
}
#biff-chat-panel form.input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #cfd8dc;
  border-radius: 999px;
  font-size: 14px;
  outline: none;
}
#biff-chat-panel form.input input:focus { border-color: #1E88E5; box-shadow: 0 0 0 3px rgba(30,136,229,0.15); }
#biff-chat-panel form.input button {
  background: #1E88E5; color: #fff;
  border: 0; padding: 0 18px; border-radius: 999px;
  cursor: pointer; font-weight: 700; font-size: 13px;
  letter-spacing: 0.04em;
}
#biff-chat-panel form.input button:disabled { opacity: 0.5; cursor: not-allowed; }
#biff-chat-panel form.input button:hover:not(:disabled) { background: #1565C0; }

#biff-chat-panel .disclaimer {
  background: #0A0A0A; color: #888;
  font-size: 10px; text-align: center;
  padding: 6px 12px;
  letter-spacing: 0.04em;
}
#biff-chat-panel .disclaimer strong { color: #E53935; }
#biff-chat-panel .disclaimer a { color: #1E88E5; text-decoration: none; }

@media (max-width: 520px) {
  #biff-chat-panel {
    right: 8px; left: 8px; bottom: 84px;
    width: auto;
    height: calc(100vh - 100px);
    max-height: 700px;
    border-radius: 14px;
  }
  #biff-chat-launcher { right: 14px; bottom: 14px; }
}
