/* ============================================================
   ASEF — FAQ Chatbot widget (rule-based, no backend)
   Sits above the Call/WhatsApp floating buttons.
   ============================================================ */

/* Chat bubble button — same square grey style as the .fab buttons */
.fab-chat {
  background: var(--mid-grey, #6b6b6b);
  border: none;
  cursor: pointer;
  padding: 0;
  position: relative;
}
.fab-chat:hover { background: var(--dark-grey, #2b2b2b); }
.fab-chat svg { display: block; margin: 0; }

/* Small attention dot on the chat button */
.fab-chat::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #25d366;
  border: 2px solid #fff;
  animation: chatDotPulse 1.6s ease-in-out infinite;
}
.fab-chat.chat-seen::after { display: none; }
@keyframes chatDotPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.6; }
}

/* Panel */
.chatbot-panel {
  position: fixed;
  right: 1.4rem;
  bottom: 1.4rem;
  width: 360px;
  max-width: calc(100vw - 2.8rem);
  height: 560px;
  max-height: calc(100vh - 2.8rem);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1600;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}
.chatbot-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.chatbot-header {
  background: #2b2b2b;
  color: #fff;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chatbot-avatar svg { width: 22px; height: 22px; }
.chatbot-head-text { display: flex; flex-direction: column; line-height: 1.2; }
.chatbot-title { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.02em; }
.chatbot-status {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.75);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.chatbot-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #25d366;
}
.chatbot-close {
  margin-left: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.15rem 0.35rem;
  opacity: 0.85;
}
.chatbot-close:hover { opacity: 1; }

/* Messages area */
.chatbot-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.chat-msg {
  max-width: 82%;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 12px;
  white-space: pre-line;
  word-wrap: break-word;
}
.chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #2b2b2b;
  border: 1px solid rgba(0, 0, 0, 0.07);
  border-bottom-left-radius: 4px;
}
.chat-msg.user {
  align-self: flex-end;
  background: #2b2b2b;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.07);
  display: inline-flex;
  gap: 4px;
  padding: 0.7rem 0.85rem;
}
.chat-msg.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9a9a9a;
  animation: chatTyping 1.2s infinite;
}
.chat-msg.typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-msg.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Quick reply chips */
.chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.5rem 1rem 0.75rem;
  background: #f5f5f5;
  flex-shrink: 0;
  max-height: 150px;
  overflow-y: auto;
}
.chat-chip {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: #2b2b2b;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 100px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}
.chat-chip:hover {
  background: #2b2b2b;
  color: #fff;
  border-color: #2b2b2b;
}

/* Lead form */
.chat-lead {
  padding: 0.85rem 1rem 1rem;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  flex-shrink: 0;
}
.chat-lead.show { display: flex; }
.chat-lead label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #2b2b2b;
  text-transform: uppercase;
}
.chat-lead input {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 0;
  outline: none;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.chat-lead input:focus {
  border-color: #2b2b2b;
  box-shadow: 0 0 0 3px rgba(43, 43, 43, 0.08);
}
.chat-lead .chat-lead-error {
  font-size: 0.75rem;
  color: #c0392b;
  display: none;
}
.chat-lead-error.show { display: block; }
.chat-send-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #fff;
  background: #25d366;
  border: none;
  padding: 0.7rem 1rem;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.2s ease;
  margin-top: 0.15rem;
}
.chat-send-btn:hover { background: #1eb959; }
.chat-send-btn svg { width: 18px; height: 18px; }

/* Input row */
.chatbot-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  background: #fff;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}
.chatbot-input input {
  flex: 1;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 100px;
  outline: none;
  transition: border-color 0.2s ease;
}
.chatbot-input input:focus { border-color: #2b2b2b; }
.chatbot-input button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #2b2b2b;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.chatbot-input button:hover { background: #000; }
.chatbot-input button svg { width: 18px; height: 18px; }

/* Mobile tweaks */
@media (max-width: 600px) {
  .chatbot-panel {
    right: 0.8rem;
    left: 0.8rem;
    bottom: 0.8rem;
    width: auto;
    max-width: none;
    height: calc(100vh - 1.6rem);
    max-height: none;
  }
}

/* Teaser popup near the chat button */
.chatbot-teaser {
  position: fixed;
  right: 1.4rem;
  bottom: calc(1.4rem + 52px + 52px + 52px + 0.75rem * 3 + 14px); /* above the 3-button stack */
  max-width: 220px;
  background: #fff;
  color: #2b2b2b;
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  z-index: 1590;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}
.chatbot-teaser.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  animation: teaserNudge 3s ease-in-out infinite;
}
@keyframes teaserNudge {
  0%, 70%, 100% { transform: translateY(0) scale(1); }
  79% { transform: translateY(-4px) scale(1); }
  88% { transform: translateY(0) scale(1); }
}
.chatbot-teaser::after {
  content: "";
  position: absolute;
  bottom: -6px;
  right: 24px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  transform: rotate(45deg);
}
.chatbot-teaser strong {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b6b6b;
  margin-bottom: 0.15rem;
}

@media (max-width: 600px) {
  .chatbot-teaser {
    right: 0.8rem;
    max-width: 200px;
  }
}
