/* ===== Chat Widget ===== */
.chat-widget {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

/* Toggle Button */
.chat-toggle {
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #1a7a4c, #2d8f5e);
  color: #fff; font-size: 24px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(26,122,76,0.4);
  transition: all 0.3s ease; display: flex; align-items: center; justify-content: center;
}
.chat-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(26,122,76,0.5); }
.chat-toggle .chat-icon, .chat-toggle .close-icon { transition: all 0.3s ease; }
.chat-toggle .close-icon { display: none; }
.chat-toggle.active .chat-icon { display: none; }
.chat-toggle.active .close-icon { display: block; }

/* Chat Window */
.chat-window {
  position: absolute; bottom: 76px; right: 0;
  width: 380px; max-width: calc(100vw - 48px);
  height: 520px; border-radius: 16px; overflow: hidden;
  background: #fff; box-shadow: 0 8px 40px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  transform: translateY(20px) scale(0.95); opacity: 0; visibility: hidden;
  transition: all 0.3s ease;
}
.chat-window.open { transform: translateY(0) scale(1); opacity: 1; visibility: visible; }

/* Chat Header */
.chat-header {
  padding: 16px 20px; background: linear-gradient(135deg, #1a7a4c, #2d8f5e);
  color: #fff; display: flex; align-items: center; gap: 12px;
}
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.chat-header-info h4 { font-size: 15px; font-weight: 600; margin: 0; color: #fff; }
.chat-header-info p { font-size: 12px; margin: 0; opacity: 0.85; }
.chat-header-status { display: flex; align-items: center; gap: 4px; }
.chat-header-status::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; display: inline-block;
}

/* Messages Area */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 20px 16px;
  display: flex; flex-direction: column; gap: 12px;
  background: #f5f7fa;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Message Bubbles */
.msg { max-width: 85%; animation: msgIn 0.3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; }
.msg-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.5;
}
.msg-bot .msg-bubble {
  background: #fff; color: #333; border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.msg-user .msg-bubble {
  background: #1a7a4c; color: #fff; border-bottom-right-radius: 4px;
}
.msg-time { font-size: 11px; color: #999; margin-top: 4px; }
.msg-user .msg-time { text-align: right; }

/* Quick Reply Buttons */
.quick-replies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.quick-btn {
  padding: 6px 14px; border-radius: 20px; border: 1px solid #1a7a4c;
  background: #fff; color: #1a7a4c; font-size: 13px; cursor: pointer;
  transition: all 0.2s ease;
}
.quick-btn:hover { background: #1a7a4c; color: #fff; }

/* Typing Indicator */
.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; background: #fff; border-radius: 14px; width: fit-content; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #ccc;
  animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Phone CTA in messages */
.msg-phone-cta {
  margin-top: 10px; padding: 10px 14px; background: #fff3e0;
  border-radius: 10px; border-left: 3px solid #f08c00;
  display: flex; align-items: center; gap: 8px;
}
.msg-phone-cta a {
  font-size: 16px; font-weight: 700; color: #1a7a4c; text-decoration: none;
}
.msg-phone-cta span { font-size: 12px; color: #666; }

/* Chat Input */
.chat-input-area {
  padding: 12px 16px; border-top: 1px solid #eee; background: #fff;
  display: flex; gap: 8px; align-items: center;
}
.chat-input {
  flex: 1; padding: 10px 14px; border: 1px solid #e0e4e8; border-radius: 24px;
  font-size: 14px; outline: none; transition: border-color 0.2s;
  font-family: inherit;
}
.chat-input:focus { border-color: #1a7a4c; }
.chat-send {
  width: 36px; height: 36px; border-radius: 50%; border: none;
  background: #1a7a4c; color: #fff; cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chat-send:hover { background: #0f5c38; }

/* Floating Phone Button (always visible) */
.chat-phone-float {
  position: fixed; bottom: 96px; right: 24px; z-index: 9998;
  width: 48px; height: 48px; border-radius: 50%; border: none;
  background: #f08c00; color: #fff; font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 16px rgba(240,140,0,0.4);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.3s ease;
}
.chat-phone-float:hover { transform: scale(1.08); }
.chat-phone-float .pulse {
  position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid #f08c00; animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

@media (max-width: 480px) {
  .chat-window { width: calc(100vw - 32px); right: -8px; height: 70vh; bottom: 68px; }
  .chat-widget { bottom: 16px; right: 16px; }
  .chat-phone-float { bottom: 88px; right: 16px; }
}
