/* Chat Widget Container */
#custom-chat-widget {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  z-index: 2147483647 !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;

  /* Default CSS variables for Bot 1 */
  --chat-header-bg: linear-gradient(135deg, #f7d879 0%, #c88913 58%, #7c4c05 100%);
  --chat-window-bg: #fffaf0;
  --chat-messages-bg: #fff7e3;
  --chat-bot-bubble-bg: #ffffff;
  --chat-bot-bubble-border: #efd89d;
  --chat-bot-bubble-color: #3b2a10;
  --chat-user-bubble-bg: linear-gradient(135deg, #edbd42 0%, #b97809 100%);
  --chat-button-bg: linear-gradient(135deg, #f8d66d 0%, #d99a20 52%, #9f6408 100%);
  --chat-button-border: #ffe39a;
  --chat-button-shadow: rgba(159,100,8,0.34);
  --chat-avatar-border: #fff0bc;
  --chat-input-border-focus: #c88913;
  --chat-send-btn-bg: linear-gradient(135deg, #f2ca55 0%, #b97809 100%);
  --chat-typing-dot: #b97809;
}

/* Chat Button (Bottom Right Trigger) */
#custom-chat-widget #chat-widget-button {
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  padding: 0 !important;
  margin: 0 !important;
  border-radius: 50% !important;
  background: var(--chat-button-bg) !important;
  color: white !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 4px 14px var(--chat-button-shadow) !important;
  cursor: pointer !important;
  transition: transform 0.2s !important;
  border: 2px solid var(--chat-button-border) !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  line-height: normal !important;
}

#custom-chat-widget #chat-widget-button:hover {
  transform: scale(1.08) !important;
}

#custom-chat-widget #chat-widget-button img,
#custom-chat-widget #chat-widget-button-avatar {
  width: 100% !important;
  height: 100% !important;
  min-width: 100% !important;
  min-height: 100% !important;
  object-fit: cover !important;
  border-radius: 50% !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Chat Window */
#custom-chat-widget #chat-widget-window {
  display: none;
  flex-direction: column;
  position: absolute !important;
  bottom: 70px !important;
  right: 0 !important;
  width: 380px !important;
  max-width: calc(100vw - 40px) !important;
  height: 600px !important;
  max-height: calc(100vh - 100px) !important;
  background-color: var(--chat-window-bg) !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18) !important;
  overflow: hidden !important;
  border: 1px solid var(--chat-bot-bubble-border) !important;
  animation: chat-fade-in 0.2s ease-out !important;
  box-sizing: border-box !important;
}

@keyframes chat-fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Chat Header */
#custom-chat-widget #chat-widget-header {
  position: relative !important;
  background: var(--chat-header-bg) !important;
  color: white !important;
  padding: 16px !important;
  font-weight: 600 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
  gap: 10px !important;
  text-align: center !important;
  box-sizing: border-box !important;
}

#custom-chat-widget #chat-widget-header-avatar {
  width: 64px !important;
  height: 64px !important;
  min-width: 64px !important;
  min-height: 64px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 2px solid var(--chat-avatar-border) !important;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2) !important;
  display: block !important;
  margin: 0 !important;
}

#custom-chat-widget #chat-widget-close {
  position: absolute !important;
  top: 14px !important;
  right: 14px !important;
  cursor: pointer !important;
  background: none !important;
  border: none !important;
  color: white !important;
  font-size: 20px !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  width: auto !important;
  height: auto !important;
  min-width: unset !important;
}

/* Chat Messages Area */
#custom-chat-widget #chat-widget-messages {
  flex: 1 !important;
  padding: 16px !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  background-color: var(--chat-messages-bg) !important;
  box-sizing: border-box !important;
}

/* Message Bubbles */
#custom-chat-widget .chat-message-row {
  width: 100% !important;
  display: flex !important;
  align-items: flex-end !important;
  gap: 8px !important;
  box-sizing: border-box !important;
}

#custom-chat-widget .chat-message-row.user {
  flex-direction: row-reverse !important;
}

#custom-chat-widget .chat-avatar {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  min-height: 32px !important;
  flex: 0 0 32px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  box-shadow: 0 1px 5px rgba(0,0,0,0.15) !important;
  display: block !important;
  margin: 0 !important;
}

#custom-chat-widget .chat-message {
  max-width: calc(85% - 40px) !important;
  padding: 10px 14px !important;
  border-radius: 12px !important;
  font-size: 14px !important;
  line-height: 1.4 !important;
  word-wrap: break-word !important;
  box-sizing: border-box !important;
}

#custom-chat-widget .chat-message.user {
  background: var(--chat-user-bubble-bg) !important;
  color: white !important;
  border-bottom-right-radius: 2px !important;
}

#custom-chat-widget .chat-message.bot {
  background-color: var(--chat-bot-bubble-bg) !important;
  color: var(--chat-bot-bubble-color) !important;
  border: 1px solid var(--chat-bot-bubble-border) !important;
  border-bottom-left-radius: 2px !important;
}

/* Chat Input Area */
#custom-chat-widget #chat-widget-input-area {
  display: flex !important;
  padding: 12px !important;
  background-color: var(--chat-window-bg) !important;
  border-top: 1px solid var(--chat-bot-bubble-border) !important;
  box-sizing: border-box !important;
}

#custom-chat-widget #chat-widget-input {
  flex: 1 !important;
  padding: 10px 12px !important;
  border: 1px solid var(--chat-bot-bubble-border) !important;
  border-radius: 20px !important;
  outline: none !important;
  font-size: 14px !important;
  transition: border-color 0.2s !important;
  box-sizing: border-box !important;
  background: white !important;
  color: #333 !important;
}

#custom-chat-widget #chat-widget-input:focus {
  border-color: var(--chat-input-border-focus) !important;
}

#custom-chat-widget #chat-widget-send {
  background: var(--chat-send-btn-bg) !important;
  color: white !important;
  border: 1px solid var(--chat-button-border) !important;
  border-radius: 50% !important;
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  margin-left: 8px !important;
  padding: 0 !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 16px !important;
  box-sizing: border-box !important;
}

#custom-chat-widget #chat-widget-send:disabled {
  opacity: 0.6 !important;
  cursor: not-allowed !important;
}

/* Loader */
#custom-chat-widget .typing-indicator {
  display: inline-flex !important;
  gap: 4px !important;
  padding: 4px 8px !important;
}

#custom-chat-widget .typing-dot {
  width: 6px !important;
  height: 6px !important;
  background-color: var(--chat-typing-dot) !important;
  border-radius: 50% !important;
  animation: typing 1.4s infinite ease-in-out !important;
}

#custom-chat-widget .typing-dot:nth-child(1) { animation-delay: -0.32s !important; }
#custom-chat-widget .typing-dot:nth-child(2) { animation-delay: -0.16s !important; }

@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
