/* VMR Floating Chat Widget */

/* ── Trigger Button ─────────────────────────────────────── */
#vmr-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #272361 0%, #3B5AA9 100%);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(39, 35, 97, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

#vmr-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(39, 35, 97, 0.55);
}

#vmr-chat-btn svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.15s;
}

#vmr-chat-btn .vmr-chat-icon-close {
  display: none;
}

#vmr-chat-btn.is-open .vmr-chat-icon-chat {
  display: none;
}

#vmr-chat-btn.is-open .vmr-chat-icon-close {
  display: block;
}

/* Unread badge */
#vmr-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  pointer-events: none;
  transition: opacity 0.2s;
}

#vmr-chat-badge.hidden {
  opacity: 0;
  pointer-events: none;
}

/* ── Panel ──────────────────────────────────────────────── */
#vmr-chat-panel {
  position: fixed;
  bottom: 98px;
  right: 24px;
  z-index: 9998;
  width: 340px;
  height: 480px;
  max-height: min(480px, calc(100dvh - 120px));
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(50, 50, 93, 0.18), 0 6px 20px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.18s ease;
}

#vmr-chat-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel Header ───────────────────────────────────────── */
#vmr-chat-header {
  background: #0a2540;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.vmr-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #272361, #3B5AA9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.vmr-chat-avatar svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.vmr-chat-header-info {
  flex: 1;
  min-width: 0;
}

.vmr-chat-title {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.vmr-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  color: #94a3b8;
  margin-top: 1px;
}

.vmr-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
  animation: vmr-pulse 2s infinite;
}

@keyframes vmr-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

#vmr-chat-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
  margin-right: 2px;
}
#vmr-chat-clear:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}
#vmr-chat-clear svg {
  width: 16px;
  height: 16px;
}

#vmr-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

#vmr-chat-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

#vmr-chat-close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
}

/* ── Messages Area ──────────────────────────────────────── */
#vmr-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafbfc;
  scroll-behavior: smooth;
}

#vmr-chat-messages::-webkit-scrollbar {
  width: 4px;
}

#vmr-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#vmr-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 4px;
}

/* ── Message Bubbles ────────────────────────────────────── */
.vmr-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: vmr-msg-in 0.2s ease;
}

@keyframes vmr-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.vmr-msg--bot {
  align-self: flex-start;
}

.vmr-msg--user {
  align-self: flex-end;
}

.vmr-msg__bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.vmr-msg--bot .vmr-msg__bubble {
  background: #f0f4f8;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.vmr-msg--user .vmr-msg__bubble {
  background: #272361;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.vmr-msg__time {
  font-size: 10.5px;
  color: #9ca3af;
  margin-top: 3px;
  padding: 0 2px;
}

.vmr-msg--user .vmr-msg__time {
  text-align: right;
}

/* ── Typing Indicator ───────────────────────────────────── */
#vmr-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 13px;
  background: #f0f4f8;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}

#vmr-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  animation: vmr-bounce 1.2s infinite ease-in-out;
}

#vmr-typing span:nth-child(2) { animation-delay: 0.15s; }
#vmr-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes vmr-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Input Bar ──────────────────────────────────────────── */
#vmr-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

#vmr-chat-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  padding: 9px 15px;
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: none;
}

#vmr-chat-input:focus {
  border-color: #272361;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(39, 35, 97, 0.1);
}

#vmr-chat-input::placeholder {
  color: #9ca3af;
}

#vmr-chat-send {
  width: 38px;
  height: 38px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #272361 0%, #3B5AA9 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 3px 10px rgba(39, 35, 97, 0.35);
}

#vmr-chat-send:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 5px 15px rgba(39, 35, 97, 0.45);
}

#vmr-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#vmr-chat-send svg {
  width: 16px;
  height: 16px;
  fill: #fff;
  margin-left: 2px;
}

/* ── Quick Replies ──────────────────────────────────────── */
#vmr-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
  background: #fafbfc;
}

.vmr-qr-btn {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: #272361;
  background: #fff;
  border: 1.5px solid #c7d2fe;
  border-radius: 20px;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  min-height: 44px;
  padding: 0.625rem 1rem;
}

.vmr-qr-btn:hover {
  background: #272361;
  color: #fff;
  border-color: #272361;
}

/* ── Book a Valuation Button ────────────────────────────── */
.vmr-chat-book-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 14px;
  background: #635bff;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(99, 91, 255, 0.35);
  align-self: flex-start;
}

.vmr-chat-book-btn:hover {
  background: #4f46e5;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(99, 91, 255, 0.45);
  color: #fff;
}

/* ── Responsive ─────────────────────────────────────────── */
#vmr-chat-btn {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 480px) {
  #vmr-chat-panel {
    width: 100vw;
    height: calc(100dvh - env(safe-area-inset-bottom, 0px));
    max-height: none;
    bottom: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
  }

  #vmr-chat-btn {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    right: 16px;
  }
}
