/* Rethink Healing Chat Widget */
:root {
  --rc-accent: #2E7D5E;
  --rc-accent-dark: #1f5a43;
  --rc-white: #ffffff;
  --rc-bg: #f8f9fa;
  --rc-border: #e0e0e0;
  --rc-text: #1a1a1a;
  --rc-subtext: #666;
  --rc-bubble-bot: #f0f4f2;
  --rc-bubble-user: var(--rc-accent);
  --rc-shadow: 0 8px 32px rgba(0,0,0,0.18);
  --rc-radius: 16px;
}

#rethink-chat-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--rc-accent);
  border: none;
  cursor: pointer;
  box-shadow: var(--rc-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s ease, background 0.2s ease;
}
#rethink-chat-launcher:hover { background: var(--rc-accent-dark); transform: scale(1.07); }
#rethink-chat-launcher svg { width: 28px; height: 28px; fill: var(--rc-white); }
#rethink-chat-launcher.rc-left { right: auto; left: 24px; }

#rethink-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #e53935;
  border-radius: 50%;
  border: 2px solid var(--rc-white);
  display: none;
}
#rethink-chat-badge.rc-show { display: block; }

#rethink-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--rc-white);
  border-radius: var(--rc-radius);
  box-shadow: var(--rc-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9999;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#rethink-chat-window.rc-left { right: auto; left: 24px; }
#rethink-chat-window.rc-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#rc-header {
  background: var(--rc-accent);
  color: var(--rc-white);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#rc-header .rc-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(255,255,255,0.25);
  border: 2px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
#rc-header .rc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#rc-header .rc-info { flex: 1; }
#rc-header .rc-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
#rc-header .rc-status { font-size: 12px; opacity: 0.85; }
#rc-close-btn {
  background: none; border: none; cursor: pointer;
  color: var(--rc-white); opacity: 0.8; padding: 4px;
  display: flex; align-items: center;
}
#rc-close-btn:hover { opacity: 1; }
#rc-close-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* Messages */
#rc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#rc-messages::-webkit-scrollbar { width: 4px; }
#rc-messages::-webkit-scrollbar-track { background: transparent; }
#rc-messages::-webkit-scrollbar-thumb { background: var(--rc-border); border-radius: 4px; }

.rc-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.rc-msg.rc-bot {
  background: var(--rc-bubble-bot);
  color: var(--rc-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.rc-msg.rc-user {
  background: var(--rc-bubble-user);
  color: var(--rc-white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.rc-msg a {
  color: var(--rc-accent);
  text-decoration: underline;
  word-break: break-word;
}
.rc-msg.rc-user a {
  color: var(--rc-white);
}
.rc-msg.rc-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 14px 18px;
}
.rc-dot {
  width: 7px; height: 7px;
  background: var(--rc-subtext);
  border-radius: 50%;
  animation: rc-bounce 1.2s infinite;
}
.rc-dot:nth-child(2) { animation-delay: 0.2s; }
.rc-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes rc-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Live agent handoff divider */
.rc-divider {
  text-align: center;
  font-size: 11px;
  color: var(--rc-subtext);
  padding: 4px 0;
  position: relative;
}
.rc-divider::before, .rc-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 18%;
  height: 1px;
  background: var(--rc-border);
}
.rc-divider::before { left: 0; }
.rc-divider::after  { right: 0; }

/* Footer / Input */
#rc-footer {
  border-top: 1px solid var(--rc-border);
  padding: 12px 14px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#rc-input {
  flex: 1;
  border: 1px solid var(--rc-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  max-height: 120px;
  line-height: 1.4;
  color: var(--rc-text);
}
#rc-input:focus { border-color: var(--rc-accent); }
#rc-send-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--rc-accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
#rc-send-btn:hover { background: var(--rc-accent-dark); }
#rc-send-btn:disabled { background: var(--rc-border); cursor: default; }
#rc-send-btn svg { width: 18px; height: 18px; fill: var(--rc-white); }

#rc-powered {
  text-align: center;
  font-size: 11px;
  color: var(--rc-subtext);
  padding: 4px 0 8px;
}

/* Responsive */
@media (max-width: 420px) {
  #rethink-chat-window { width: calc(100vw - 16px); right: 8px; bottom: 80px; }
  #rethink-chat-window.rc-left { left: 8px; right: auto; }
  #rethink-chat-launcher { right: 16px; bottom: 16px; }
  #rethink-chat-launcher.rc-left { left: 16px; right: auto; }
}
