.chat-bubble-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #6366f1;
  color: white;
  border: none;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 9999;
  transition: transform 0.2s, background 0.2s;
}

.chat-bubble-btn:hover {
  transform: scale(1.1);
  background: #333;
}

.chat-window {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 340px;
  height: 480px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  overflow: hidden;
  transform: scale(0);
  transform-origin: bottom right;
  transition: transform 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.chat-window.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: all;
}

.chat-header {
  background: #111;
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-close-btn {
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.chat-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 2px;
}

.chat-message {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.bot {
  background: #f3f3f3;
  color: #111;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.chat-message.user {
  background: #111;
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 14px 10px;
  flex-shrink: 0;
}

.quick-reply-btn {
  background: white;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  color: #111;
  font-family: Arial, sans-serif;
}

.quick-reply-btn:hover {
  background: #f3f3f3;
  border-color: #999;
}

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #eee;
  align-items: center;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  outline: none;
  font-family: Arial, sans-serif;
  background: white;
  color: #111;
}

.chat-input:focus {
  border-color: #999;
}

.chat-send-btn {
  background: #111;
  color: white;
  border: none;
  border-radius: 50%;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.chat-send-btn:hover {
  background: #333;
}

.chat-input:disabled,
.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #f3f3f3;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Dark mode */
.dark-mode .chat-window {
  background: #1a1a1a;
  color: #eee;
}

.dark-mode .chat-message.bot {
  background: #2a2a2a;
  color: #eee;
}

.dark-mode .chat-messages::-webkit-scrollbar-thumb {
  background: #444;
}

.dark-mode .quick-reply-btn {
  background: #2a2a2a;
  border-color: #444;
  color: #eee;
}

.dark-mode .quick-reply-btn:hover {
  background: #333;
  border-color: #666;
}

.dark-mode .chat-input-area {
  border-top-color: #333;
}

.dark-mode .chat-input {
  background: #2a2a2a;
  border-color: #444;
  color: #eee;
}

.dark-mode .chat-input::placeholder {
  color: #888;
}

.dark-mode .typing-indicator {
  background: #2a2a2a;
}

.dark-mode .typing-dot {
  background: #666;
}

@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
    /* dvh tracks the visible viewport so the iOS keyboard doesn't cover the input */
    height: min(420px, 70dvh);
  }

  .chat-bubble-btn {
    right: 16px;
    bottom: 16px;
    width: 50px;
    height: 50px;
  }
}
