/* chatbox.css — MediHiveRx Hub AI assistant widget
 * Uses Hub design tokens (pt-* variables expected to be present in
 * design-tokens.css). Self-contained — no external deps.
 */

/* ── Floating bubble (bottom-right) ─────────────────────────────────────── */
.mhrx-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 26px;
  background: #0078D4;
  color: #fff;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 150ms ease-out, background 150ms;
  touch-action: none;
}
.mhrx-chat-bubble:active {
  cursor: grabbing;
}
.mhrx-chat-bubble:hover {
  background: #106EBE;
  transform: scale(1.05);
}
.mhrx-chat-bubble.is-active {
  background: #605E5C;
}

/* ── Chat panel (slide-up from bubble) ──────────────────────────────────── */
.mhrx-chat-panel {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border: 1px solid #E1DFDD;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
}
/* Honor the [hidden] HTML attribute — without this rule, display:flex above
   overrides the user-agent display:none for [hidden], leaving the panel
   stuck visible. LL-069 candidate. */
.mhrx-chat-panel[hidden] {
  display: none !important;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.mhrx-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #E1DFDD;
  background: #FAFAFA;
}
.mhrx-chat-title {
  font-size: 14px;
  font-weight: 600;
  color: #222;
}
.mhrx-chat-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #605E5C;
  padding: 0 4px;
}
.mhrx-chat-close:hover { color: #222; }

/* ── Messages area ──────────────────────────────────────────────────────── */
.mhrx-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #FAFAFA;
}

/* Empty state */
.mhrx-chat-empty {
  padding: 24px 8px;
  text-align: center;
}
.mhrx-chat-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: #222;
  margin-bottom: 6px;
}
.mhrx-chat-empty-sub {
  font-size: 12px;
  color: #605E5C;
  margin-bottom: 20px;
}
.mhrx-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mhrx-chat-suggest {
  text-align: left;
  font-size: 12px;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid #E1DFDD;
  border-radius: 6px;
  color: #0078D4;
  cursor: pointer;
  transition: background 100ms;
}
.mhrx-chat-suggest:hover {
  background: #F0F8FF;
  border-color: #0078D4;
}

/* Message bubbles */
.mhrx-chat-msg {
  display: flex;
  margin-bottom: 10px;
}
.mhrx-chat-msg-user { justify-content: flex-end; }
.mhrx-chat-msg-assistant { justify-content: flex-start; }

.mhrx-chat-bubble-text {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}
.mhrx-chat-msg-user .mhrx-chat-bubble-text {
  background: #0078D4;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.mhrx-chat-msg-assistant .mhrx-chat-bubble-text {
  background: #fff;
  color: #222;
  border: 1px solid #E1DFDD;
  border-bottom-left-radius: 4px;
}

/* Assistant content: bullet lists and paragraphs */
.mhrx-chat-msg-assistant .mhrx-chat-bubble-text p {
  margin: 0 0 6px 0;
}
.mhrx-chat-msg-assistant .mhrx-chat-bubble-text p:last-child { margin-bottom: 0; }
.mhrx-chat-msg-assistant .mhrx-chat-bubble-text ul {
  margin: 0;
  padding-left: 18px;
}
.mhrx-chat-msg-assistant .mhrx-chat-bubble-text li {
  margin: 2px 0;
}

/* Typing indicator */
.mhrx-chat-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px;
}
.mhrx-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 3px;
  background: #605E5C;
  opacity: 0.5;
  animation: mhrx-chat-pulse 1.2s infinite ease-in-out;
}
.mhrx-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.mhrx-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes mhrx-chat-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50%      { opacity: 1.0; transform: translateY(-3px); }
}

/* ── Input row ──────────────────────────────────────────────────────────── */
.mhrx-chat-input-row {
  display: flex;
  padding: 10px 12px;
  border-top: 1px solid #E1DFDD;
  background: #fff;
  gap: 8px;
  align-items: flex-end;
}
.mhrx-chat-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #E1DFDD;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 100ms;
}
.mhrx-chat-input:focus { border-color: #0078D4; }

.mhrx-chat-send {
  background: #0078D4;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 12px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 100ms;
}
.mhrx-chat-send:hover { background: #106EBE; }
.mhrx-chat-send:disabled { background: #C8C6C4; cursor: not-allowed; }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.mhrx-chat-foot {
  padding: 6px 12px;
  font-size: 10px;
  color: #605E5C;
  border-top: 1px solid #F3F2F1;
  background: #FAFAFA;
  text-align: center;
}
.mhrx-chat-foot-warn {
  color: #986F0B;
  background: #FFF4CE;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .mhrx-chat-panel {
    width: calc(100vw - 16px);
    right: 8px;
    bottom: 78px;
    height: calc(100vh - 110px);
  }
  .mhrx-chat-bubble {
    right: 16px;
    bottom: 16px;
  }
}
