/* ============================================================
   RVP Connect — AI Chatbot CSS
   Floating button + chat window. Depends on main.css variables.
   ============================================================ */

/* ── Floating Action Button ────────────────────────────────── */
.rvp-chat-fab {
  position: fixed;
  bottom: 88px; /* above mobile bottom nav */
  right: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6C2BD9 0%, #8B5CF6 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(108,43,217,.45), 0 2px 8px rgba(0,0,0,.18);
  z-index: 9990;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  outline: none;
  padding: 0;
}
.rvp-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 32px rgba(108,43,217,.55), 0 4px 12px rgba(0,0,0,.2);
}
.rvp-chat-fab:active { transform: scale(.95); }
.rvp-chat-fab.is-open {
  background: linear-gradient(135deg, #4338CA 0%, #6C2BD9 100%);
}
.rvp-chat-fab__icon { display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }

/* Pulse ring */
.rvp-chat-fab__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(108,43,217,.35);
  animation: rvp-pulse 3s ease-out infinite;
  pointer-events: none;
}
@keyframes rvp-pulse {
  0%   { transform: scale(1);   opacity: .7; }
  60%  { transform: scale(1.65); opacity: 0; }
  100% { transform: scale(1.65); opacity: 0; }
}

/* Desktop: sit above footer, not above mobile nav */
@media (min-width: 769px) {
  .rvp-chat-fab { bottom: 28px; right: 28px; }
}

/* ── Chat Window ───────────────────────────────────────────── */
.rvp-chat-window {
  position: fixed;
  bottom: 158px;
  right: 18px;
  width: min(380px, calc(100vw - 24px));
  height: min(520px, calc(100vh - 200px));
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 60px rgba(0,0,0,.18), 0 4px 20px rgba(108,43,217,.14);
  display: flex;
  flex-direction: column;
  z-index: 9989;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.4,.64,1);
  border: 1px solid rgba(108,43,217,.1);
}
.rvp-chat-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
.rvp-chat-window.is-minimized {
  height: 0 !important;
  opacity: 0;
  pointer-events: none;
}

@media (min-width: 769px) {
  .rvp-chat-window { bottom: 100px; right: 28px; }
}
@media (max-width: 400px) {
  .rvp-chat-window { right: 8px; bottom: 150px; width: calc(100vw - 16px); }
}

/* ── Header ────────────────────────────────────────────────── */
.rvp-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #6C2BD9 0%, #8B5CF6 100%);
  color: #fff;
  flex-shrink: 0;
  gap: 8px;
}
.rvp-chat-header__info { display: flex; align-items: center; gap: 10px; }
.rvp-chat-header__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.rvp-chat-header__title {
  font-size: .9rem; font-weight: 700; line-height: 1.2;
  font-family: 'Poppins', 'Inter', sans-serif;
}
.rvp-chat-header__sub {
  font-size: .7rem; opacity: .8; font-weight: 400; margin-top: 1px;
  font-family: 'Poppins', 'Inter', sans-serif;
}
.rvp-chat-header__actions { display: flex; gap: 4px; }
.rvp-chat-icon-btn {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,.15); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.rvp-chat-icon-btn:hover { background: rgba(255,255,255,.28); }

/* ── Messages ──────────────────────────────────────────────── */
.rvp-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.rvp-chat-messages::-webkit-scrollbar { width: 4px; }
.rvp-chat-messages::-webkit-scrollbar-track { background: transparent; }
.rvp-chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 99px; }

/* Message bubble */
.rvp-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: rvp-msg-in .18s ease;
}
@keyframes rvp-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.rvp-msg--user  { align-self: flex-end; align-items: flex-end; }
.rvp-msg--bot   { align-self: flex-start; align-items: flex-start; }
.rvp-msg--system { align-self: center; align-items: center; max-width: 100%; }

.rvp-msg__bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: .82rem;
  line-height: 1.55;
  font-family: 'Poppins', 'Inter', sans-serif;
  word-break: break-word;
  white-space: pre-wrap;
}
.rvp-msg--user .rvp-msg__bubble {
  background: linear-gradient(135deg, #6C2BD9, #8B5CF6);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.rvp-msg--bot .rvp-msg__bubble {
  background: #f1f5f9;
  color: #0F172A;
  border-bottom-left-radius: 4px;
}
.rvp-msg--system .rvp-msg__bubble {
  background: #EDE9FE;
  color: #4c1d95;
  font-size: .76rem;
  text-align: center;
  border-radius: 12px;
}

/* Markdown-like formatting inside bot bubbles */
.rvp-msg--bot .rvp-msg__bubble strong { font-weight: 700; }
.rvp-msg--bot .rvp-msg__bubble em { font-style: italic; }

/* Timestamp + copy row */
.rvp-msg__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  padding: 0 2px;
}
.rvp-msg__time {
  font-size: .65rem;
  color: #94a3b8;
  font-family: 'Poppins', 'Inter', sans-serif;
}
.rvp-msg__copy {
  font-size: .65rem;
  color: #94a3b8;
  cursor: pointer;
  background: none; border: none; padding: 0;
  display: flex; align-items: center; gap: 3px;
  transition: color .15s;
  font-family: 'Poppins', 'Inter', sans-serif;
}
.rvp-msg__copy:hover { color: #6C2BD9; }
.rvp-msg__copy svg { flex-shrink: 0; }

/* Typing indicator */
.rvp-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #f1f5f9;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.rvp-typing span {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #8B5CF6;
  animation: rvp-bounce .9s infinite ease-in-out;
}
.rvp-typing span:nth-child(1) { animation-delay: 0s; }
.rvp-typing span:nth-child(2) { animation-delay: .18s; }
.rvp-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes rvp-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* ── Suggested Questions ───────────────────────────────────── */
.rvp-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 10px;
  flex-shrink: 0;
  border-top: 1px solid #f1f5f9;
  background: #fff;
}
.rvp-chat-suggestions.is-hidden { display: none; }
.rvp-chip {
  font-size: .72rem;
  font-family: 'Poppins', 'Inter', sans-serif;
  font-weight: 500;
  color: #6C2BD9;
  background: #EDE9FE;
  border: 1.5px solid #c4b5fd;
  border-radius: 99px;
  padding: 5px 12px;
  cursor: pointer;
  transition: background .15s, color .15s, transform .1s;
  white-space: nowrap;
}
.rvp-chip:hover { background: #6C2BD9; color: #fff; border-color: #6C2BD9; }
.rvp-chip:active { transform: scale(.94); }

/* ── Footer ────────────────────────────────────────────────── */
.rvp-chat-footer {
  padding: 10px 14px 12px;
  border-top: 1px solid #f1f5f9;
  flex-shrink: 0;
  background: #fff;
}
.rvp-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 14px;
  padding: 8px 8px 8px 12px;
  transition: border-color .2s;
}
.rvp-chat-input-wrap:focus-within { border-color: #8B5CF6; background: #fff; }
.rvp-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  font-size: .83rem;
  color: #0F172A;
  font-family: 'Poppins', 'Inter', sans-serif;
  outline: none;
  max-height: 100px;
  min-height: 22px;
  line-height: 1.5;
  overflow-y: auto;
}
.rvp-chat-input::placeholder { color: #94a3b8; }
.rvp-chat-send-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, #6C2BD9, #8B5CF6);
  color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .1s;
}
.rvp-chat-send-btn:hover { opacity: .9; }
.rvp-chat-send-btn:active { transform: scale(.92); }
.rvp-chat-send-btn:disabled { opacity: .4; cursor: not-allowed; }

.rvp-chat-footer__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 7px;
}
.rvp-chat-clear-btn {
  font-size: .67rem; color: #94a3b8; background: none; border: none;
  cursor: pointer; display: flex; align-items: center; gap: 4px;
  font-family: 'Poppins', 'Inter', sans-serif;
  padding: 0; transition: color .15s;
}
.rvp-chat-clear-btn:hover { color: #6C2BD9; }
.rvp-chat-footer__hint {
  font-size: .65rem; color: #cbd5e1;
  font-family: 'Poppins', 'Inter', sans-serif;
}
