/* Chat Widget */
.chat-widget {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 999;
  font-family: 'Poppins', sans-serif;
}

/* Trigger button */
.chat-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.chat-bubble {
  background-color: #1a1c20;
  color: #fff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.dark-mode .chat-bubble {
  background-color: #2a2a40;
}

.chat-trigger:hover .chat-bubble {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.chat-avatar {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  border: 3px solid #7c3aed;
  object-fit: cover;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

body.dark-mode .chat-avatar {
  border-color: #a78bfa;
}

.chat-trigger:hover .chat-avatar {
  transform: scale(1.05);
}

/* Chat box */
.chat-box {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 360px;
  max-height: 480px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

body.dark-mode .chat-box {
  background: #1e1e32;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

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

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 18px;
  background: #7c3aed;
  color: #fff;
}

body.dark-mode .chat-header {
  background: #a78bfa;
}

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

.chat-header-info img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  object-fit: cover;
}

.chat-header-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.chat-status {
  font-size: 11px;
  opacity: 0.85;
}

.chat-close {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s ease;
}

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

/* Body */
.chat-body {
  flex: 1;
  padding: 20px 18px;
  overflow-y: auto;
}

.chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chat-message img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 2px;
}

.chat-msg-bubble {
  background: #f0f0f5;
  border-radius: 0 12px 12px 12px;
  padding: 10px 14px;
  max-width: 240px;
}

body.dark-mode .chat-msg-bubble {
  background: #2a2a40;
  color: #e4e6eb;
}

.chat-msg-bubble p {
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.chat-msg-bubble p + p {
  margin-top: 4px;
}

/* Sent messages (user) */
.chat-message.sent {
  flex-direction: row-reverse;
}

.chat-message.sent .chat-msg-bubble {
  background: #7c3aed;
  color: #fff;
  border-radius: 12px 0 12px 12px;
}

body.dark-mode .chat-message.sent .chat-msg-bubble {
  background: #a78bfa;
}

.chat-message.sent img {
  display: none;
}

.chat-message + .chat-message {
  margin-top: 12px;
}

/* Input */
.chat-input {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid #eee;
  gap: 8px;
}

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

.chat-input input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  font-family: 'Poppins', sans-serif;
  padding: 8px 12px;
  border-radius: 20px;
  background: #f0f0f5;
  color: #1a1c20;
}

body.dark-mode .chat-input input {
  background: #2a2a40;
  color: #e4e6eb;
}

.chat-input input::placeholder {
  color: #999;
}

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

.chat-input button {
  background: none;
  border: none;
  color: #7c3aed;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.2s ease;
}

body.dark-mode .chat-input button {
  color: #a78bfa;
}

.chat-input button:hover {
  background: rgba(124, 58, 237, 0.1);
}

/* Intro form */
.chat-intro-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #eee;
}

body.dark-mode .chat-intro-form {
  border-top-color: #333;
}

.chat-intro-form input {
  border: none;
  outline: none;
  font-size: 13px;
  font-family: 'Poppins', sans-serif;
  padding: 8px 12px;
  border-radius: 20px;
  background: #f0f0f5;
  color: #1a1c20;
}

body.dark-mode .chat-intro-form input {
  background: #2a2a40;
  color: #e4e6eb;
}

.chat-intro-form input::placeholder {
  color: #999;
}

body.dark-mode .chat-intro-form input::placeholder {
  color: #777;
}

.chat-intro-form button {
  background: #7c3aed;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

body.dark-mode .chat-intro-form button {
  background: #a78bfa;
}

.chat-intro-form button:hover {
  opacity: 0.85;
}

/* Sending state */
.chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile */
@media (max-width: 480px) {
  .chat-widget {
    bottom: 15px;
    right: 15px;
  }

  .chat-bubble {
    display: none;
  }

  .chat-box {
    width: calc(100vw - 30px);
    right: 0;
    bottom: 70px;
  }
}
