/* chatbot.css — bottom-right floating assistant + shared floating-window sizing.
   The "half-height" window size is defined here and reused by earnings.css. */

/* ---- shared FAB (floating action bubble) ---- */
.fab {
  position: fixed;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.35), 0 2px 6px rgba(0,0,0,0.2);
  z-index: 40;
  transition: transform 200ms cubic-bezier(0.2,0.8,0.2,1), box-shadow 200ms ease;
}
.fab:hover { transform: translateY(-2px) scale(1.04); }
.fab:active { transform: translateY(0) scale(0.98); }
.fab.is-active { transform: scale(0.92); }

.fab--chat {
  right: 22px; bottom: 22px;
  background: linear-gradient(135deg, #0a84ff 0%, #6c5ce7 100%);
}

/* ---- the chat window (full-height: top aligns with header bar, bottom stays at 90px) ---- */
.chatwin {
  position: fixed;
  right: 22px;
  top: 0;                       /* top edge aligns with the sticky header bar */
  bottom: 90px;                  /* bottom stays at current position (above the FAB) */
  width: 380px;                  /* match the API (earnings) window size */
  height: auto;                  /* stretch to fill between top and bottom */
  max-height: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md), 0 20px 50px rgba(15,23,42,0.18);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 41;
  opacity: 0; transform: translateY(12px) scale(0.98);
  transform-origin: top right;
  transition: opacity 220ms ease, transform 240ms cubic-bezier(0.2,0.8,0.2,1),
              width 300ms cubic-bezier(0.2,0.8,0.2,1), height 300ms cubic-bezier(0.2,0.8,0.2,1);
}
.chatwin.is-open { opacity: 1; transform: translateY(0) scale(1); }

/* grown = full-height (kept for backward compatibility) */
.chatwin.is-grown {
  top: 0;
  bottom: 90px;
  width: 380px;
  height: auto;
  max-height: none;
}

.chatwin__hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card-2);
}
.chatwin__title { font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.chatwin__sub { font-weight: 500; font-size: 11px; color: var(--ink-soft); }
.dot-ai {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, #0a84ff, #6c5ce7);
  box-shadow: 0 0 0 3px rgba(108,92,231,0.18);
}
.chatwin__x {
  border: 0; background: transparent; font-size: 20px; line-height: 1;
  color: var(--ink-mute); cursor: pointer; padding: 2px 6px; border-radius: 8px;
}
.chatwin__x:hover { background: var(--bg-soft); color: var(--ink); }

.chatwin__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 12px 4px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty { color: var(--ink-mute); font-size: 12.5px; line-height: 1.5; padding: 6px 4px; }

.msg { display: flex; }
.msg--user { justify-content: flex-end; }
.msg--ai   { justify-content: flex-start; }
.msg__bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13px; line-height: 1.5;
  word-break: break-word;
}
.msg--user .msg__bubble {
  background: var(--brand); color: #fff;
  border-bottom-right-radius: 5px;
}
.msg--ai .msg__bubble {
  background: var(--bg-soft); color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg__err { color: var(--bad); }

/* typing indicator */
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 2px 0; }
.typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-soft);
  animation: ec-typing 1s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes ec-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chatwin__foot {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
#chatInput {
  flex: 1 1 auto;
  font: inherit; font-size: 13px;
  resize: none;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 9px 11px;
  max-height: 120px;
  outline: none;
  background: var(--card-2);
  color: var(--ink);
  line-height: 1.4;
}
#chatInput:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10,132,255,0.16); }
.chatwin__send {
  flex: none;
  width: 38px; height: 38px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: var(--brand); color: #fff;
  font-size: 18px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.chatwin__send:hover { background: var(--brand-strong); }
.chatwin__send:disabled { opacity: 0.5; cursor: progress; }

/* disclaimer strip at the very bottom of the chat window */
.chatwin__disclaimer {
  flex: none;
  padding: 6px 12px 8px;
  font-size: 10px;
  line-height: 1.35;
  color: var(--ink-soft);
  background: var(--card);
  border-top: 1px solid var(--border);
  text-align: center;
}

@media (max-width: 760px) {
  .chatwin { right: 12px; left: 12px; width: auto; bottom: 84px; }
  .chatwin.is-grown { width: auto; height: auto; }
  .fab--chat { right: 16px; bottom: 16px; }
}
