/* ─── EGS AI Chatbot Widget ─────────────────────────────── */

/* Bubble button */
#egs-chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #30D5F7;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(48,213,247,0.45);
  z-index: 9990;
  transition: transform 0.2s, box-shadow 0.2s;
}
#egs-chat-bubble:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(48,213,247,0.55); }
#egs-chat-bubble svg  { width: 26px; height: 26px; fill: #2F384E; transition: opacity 0.2s; }
#egs-chat-bubble .icon-close { display: none; }

#egs-chat-bubble.open .icon-chat  { display: none; }
#egs-chat-bubble.open .icon-close { display: block; }

/* Unread badge */
#egs-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e24b4a;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
}

/* Chat window */
#egs-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(47,56,78,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9989;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
  font-family: 'Nunito', sans-serif;
}
#egs-chat-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#egs-chat-header {
  background: #2F384E;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.egs-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #30D5F7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.egs-chat-avatar svg { width: 18px; height: 18px; fill: #2F384E; }
.egs-chat-hname  { color: #fff; font-size: 14px; font-weight: 700; line-height: 1; }
.egs-chat-hstatus { color: #8EEEFF; font-size: 11px; margin-top: 2px; }
.egs-chat-hdot  { width: 7px; height: 7px; border-radius: 50%; background: #30D5F7; display: inline-block; margin-right: 4px; }

/* Messages */
#egs-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f4f7f9;
  scroll-behavior: smooth;
}
#egs-chat-messages::-webkit-scrollbar { width: 4px; }
#egs-chat-messages::-webkit-scrollbar-thumb { background: #cde; border-radius: 4px; }

.egs-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 100%;
}
.egs-msg.bot  { align-self: flex-start; }
.egs-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.egs-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #30D5F7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.egs-msg-avatar svg { width: 13px; height: 13px; fill: #2F384E; }

.egs-msg-bubble {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
.egs-msg.bot  .egs-msg-bubble { background: #fff; color: #2F384E; border-bottom-left-radius: 4px; border: 1px solid #e4eef5; }
.egs-msg.user .egs-msg-bubble { background: #2F384E; color: #F1FCFE; border-bottom-right-radius: 4px; }

/* Typing indicator */
.egs-typing .egs-msg-bubble { background: #fff; border: 1px solid #e4eef5; padding: 10px 14px; }
.egs-typing-dots { display: flex; gap: 4px; align-items: center; }
.egs-typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #aab8c8; display: block;
  animation: egs-dot-bounce 1.2s infinite ease-in-out;
}
.egs-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.egs-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes egs-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* Quick replies */
#egs-quick-replies {
  padding: 6px 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: #f4f7f9;
  flex-shrink: 0;
}
.egs-qr {
  background: #fff;
  border: 1px solid #cce9f5;
  color: #2F384E;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.egs-qr:hover { background: #e4f9fe; border-color: #30D5F7; }

/* Input area */
#egs-chat-input-wrap {
  padding: 10px 12px 14px;
  background: #fff;
  border-top: 1px solid #e4eef5;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
#egs-chat-input {
  flex: 1;
  border: 1.5px solid #e4eef5;
  border-radius: 22px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: 'Nunito', sans-serif;
  outline: none;
  resize: none;
  max-height: 80px;
  overflow-y: auto;
  line-height: 1.4;
  color: #2F384E;
  transition: border-color 0.2s;
}
#egs-chat-input:focus { border-color: #30D5F7; }
#egs-chat-input::placeholder { color: #aab8c8; }

#egs-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #30D5F7;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, background 0.2s;
}
#egs-chat-send:hover { transform: scale(1.08); background: #22c4e6; }
#egs-chat-send:disabled { background: #cde; cursor: not-allowed; transform: none; }
#egs-chat-send svg { width: 16px; height: 16px; fill: #2F384E; }

/* Footer note */
#egs-chat-footer {
  text-align: center;
  font-size: 10px;
  color: #aab8c8;
  padding: 0 12px 8px;
  background: #fff;
  font-family: 'Nunito', sans-serif;
}

/* Mobile */
@media (max-width: 480px) {
  #egs-chat-window {
    bottom: 0; right: 0; left: 0;
    width: 100%; max-width: 100%;
    height: 75vh;
    border-radius: 16px 16px 0 0;
  }
  #egs-chat-bubble { bottom: 20px; right: 20px; }
}

/* ─── Lead capture form ──────────────────────────────────── */
#egs-lead-form {
  background: #fff;
  border-top: 1px solid #e4eef5;
  flex-shrink: 0;
}
.egs-lead-form-inner {
  padding: 12px 14px 10px;
}
.egs-lead-form-title {
  font-size: 13px;
  font-weight: 800;
  color: #2F384E;
  margin-bottom: 2px;
}
.egs-lead-form-sub {
  font-size: 11px;
  color: #888;
  margin-bottom: 10px;
}
.egs-lead-field {
  margin-bottom: 7px;
}
.egs-lf-input {
  width: 100%;
  border: 1.5px solid #e4eef5;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-family: 'Nunito', sans-serif;
  color: #2F384E;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.egs-lf-input:focus { border-color: #30D5F7; }
.egs-lf-input::placeholder { color: #aab8c8; }
.egs-lf-btn {
  width: 100%;
  background: #25D366;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 8px;
  transition: background 0.2s, transform 0.15s;
}
.egs-lf-btn:hover { background: #20bb5a; transform: translateY(-1px); }
.egs-lf-btn:disabled { background: #aaa; cursor: not-allowed; transform: none; }
.egs-lf-skip {
  width: 100%;
  background: transparent;
  border: none;
  color: #888;
  font-size: 11px;
  font-family: 'Nunito', sans-serif;
  cursor: pointer;
  padding: 6px 0 2px;
  text-decoration: underline;
  text-align: center;
  display: block;
}
.egs-lf-skip:hover { color: #2F384E; }

/* ─── WhatsApp button in chat bubble ────────────────────── */
.egs-wa-btn {
  display: inline-flex;
  align-items: center;
  background: #25D366;
  color: #fff;
  text-decoration: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 800;
  font-family: 'Nunito', sans-serif;
  margin-top: 6px;
  transition: background 0.2s;
}
.egs-wa-btn:hover { background: #20bb5a; }
