/* ===== Floating toggle button ===== */
#chatToggleBtn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(220, 38, 38, 0.4);
  transition: transform 0.2s ease, background 0.2s ease;
}

#chatToggleBtn:hover {
  transform: scale(1.08);
  background: #b91c1c;
}

/* ===== Chat window ===== */
#chatWindow {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 380px;
  height: 520px;
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#chatWindow.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ===== Logo (replaces robot icon) ===== */
.chat-logo,
.chat-logo-welcome,
.chat-avatar,
.chat-avatar-typing {
  width: 50px;
  height: 50px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ===== Header ===== */
.chat-header {
  flex-shrink: 0;
  background: #dc2626;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

#chatCloseBtn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  opacity: 0.8;
  transition: opacity 0.15s;
}

#chatCloseBtn:hover {
  opacity: 1;
}

/* ===== Messages area ===== */
#chatMessages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
}

#chatMessages::-webkit-scrollbar {
  width: 5px;
}

#chatMessages::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 99px;
}

/* ===== Typing indicator ===== */
.typing-dots {
  display: inline-flex;
  gap: 2px;
  padding-left: 4px;
}

.typing-dots .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9ca3af;
  display: inline-block;
  animation: typingBounce 1.2s infinite;
}

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

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ===== Input area ===== */
.chat-input-area {
  flex-shrink: 0;
  padding: 10px 12px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #fff;
}

#chatInput {
  flex: 1;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  max-height: 160px;
  min-height: 42px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

#chatInput:focus {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

#chatSendBtn {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dc2626;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.15s, opacity 0.15s;
}

#chatSendBtn:hover:not(:disabled) {
  background: #b91c1c;
}

/* ===== Welcome message ===== */
.chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
  color: #6b7280;
}

.chat-welcome i {
  font-size: 40px;
  color: #dc2626;
  margin-bottom: 12px;
}

.chat-welcome p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  #chatWindow {
    width: calc(100vw - 16px);
    height: calc(100vh - 80px);
    bottom: 8px;
    right: 8px;
    border-radius: 12px;
  }

  #chatToggleBtn {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
}
