/* ==============================================
   ZGrov AI Chatbot Widget Styles
   Colors match website theme (#012A4A)
   ============================================== */

#zg-chatbot {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483000;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- Toggle button ---------- */
#zg-chat-toggle {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #f5f9ff;
  background: linear-gradient(135deg, #012A4A 0%, #0d4b77 100%);
  box-shadow: 0 8px 24px rgba(1, 42, 74, 0.45);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
#zg-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(1, 42, 74, 0.55);
}
#zg-chat-toggle #zg-chat-close-icon { display: none; }
#zg-chatbot.zg-open #zg-chat-toggle #zg-chat-open-icon { display: none; }
#zg-chatbot.zg-open #zg-chat-toggle #zg-chat-close-icon { display: block; }
#zg-chatbot.zg-open #zg-chat-toggle { background: #b4302f; }

/* ---------- Chat window ---------- */
#zg-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(1, 42, 74, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
  border: 1px solid rgba(1, 42, 74, 0.12);
}
#zg-chatbot.zg-open #zg-chat-window {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* ---------- Header ---------- */
#zg-chat-header {
  background: linear-gradient(135deg, #012A4A 0%, #0d4b77 100%);
  color: #f5f9ff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}
#zg-chat-header .zg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#zg-chat-header .zg-header-text { flex: 1; min-width: 0; }
#zg-chat-header strong { display: block; font-size: 15px; letter-spacing: 0.2px; }
#zg-chat-header .zg-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
#zg-chat-header .zg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #34d399; display: inline-block;
  animation: zg-pulse 1.6s infinite;
}
@keyframes zg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
#zg-chat-minimize {
  background: transparent;
  border: none;
  color: #f5f9ff;
  cursor: pointer;
  padding: 4px;
  opacity: 0.9;
  transition: opacity 0.2s;
}
#zg-chat-minimize:hover { opacity: 1; }

/* ---------- Messages area ---------- */
#zg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  background: #f5f9ff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#zg-chat-messages::-webkit-scrollbar { width: 6px; }
#zg-chat-messages::-webkit-scrollbar-thumb { background: rgba(1, 42, 74, 0.25); border-radius: 3px; }

.zg-msg {
  display: flex;
  max-width: 88%;
  animation: zg-msg-in 0.3s ease;
}
@keyframes zg-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.zg-msg.zg-bot { align-self: flex-start; }
.zg-msg.zg-user { align-self: flex-end; }

.zg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}
.zg-msg.zg-bot .zg-bubble {
  background: #ffffff;
  color: #212529;
  border: 1px solid rgba(1, 42, 74, 0.1);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(1, 42, 74, 0.06);
}
.zg-msg.zg-user .zg-bubble {
  background: #012A4A;
  color: #f5f9ff;
  border-top-right-radius: 4px;
}

.zg-msg.zg-bot .zg-bubble a {
  color: #0d4b77;
  font-weight: 600;
  text-decoration: underline;
}

/* typing indicator */
.zg-typing {
  display: inline-flex;
  gap: 5px;
  padding: 12px 16px;
}
.zg-typing span {
  width: 8px; height: 8px; border-radius: 50%;
  background: #012A4A;
  animation: zg-bounce 1.2s infinite;
}
.zg-typing span:nth-child(2) { animation-delay: 0.15s; }
.zg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes zg-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Input bar ---------- */
#zg-chat-inputbar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: #ffffff;
  border-top: 1px solid rgba(1, 42, 74, 0.1);
}
#zg-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid rgba(1, 42, 74, 0.25);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: #212529;
  background: #f5f9ff;
  outline: none;
  max-height: 120px;
  transition: border-color 0.2s, background 0.2s;
}
#zg-chat-input:focus {
  border-color: #012A4A;
  background: #ffffff;
}
#zg-chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #012A4A;
  color: #f5f9ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}
#zg-chat-send:hover { background: #0d4b77; transform: scale(1.05); }
#zg-chat-send:disabled { background: #8ba0b5; cursor: not-allowed; transform: none; }

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  #zg-chatbot { bottom: 18px; right: 18px; }
  #zg-chat-window {
    bottom: 84px;
    right: 12px;
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
  }
}

/* source badge */
.zg-source-badge {
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.6;
  display: block;
}

/* WhatsApp button */
.zg-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 9px 16px;
  border-radius: 24px;
  background: #25D366;
  color: #fff !important;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none !important;
  box-shadow: 0 3px 10px rgba(37, 211, 102, 0.4);
  transition: transform 0.2s ease, background 0.2s ease;
}
.zg-wa-btn:hover {
  background: #1eb858;
  transform: translateY(-1px);
}
