/* ====== AI Chat Widget ====== */
.ast-chat-fab-wrap {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
}

.ast-chat-fab {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2f7d43, #1f9d6e);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: transform 0.15s ease;
  order: 2;
  animation: ast-chat-fab-glow 3.2s ease-in-out infinite;
}
.ast-chat-fab:hover {
  transform: scale(1.06);
}
.ast-chat-fab:active {
  transform: scale(0.97);
}
@keyframes ast-chat-fab-glow {
  0%, 100% {
    box-shadow: 0 8px 24px rgba(47, 125, 67, 0.4), 0 0 18px 3px rgba(34, 197, 94, 0.35);
  }
  50% {
    box-shadow: 0 8px 24px rgba(47, 125, 67, 0.4), 0 0 26px 7px rgba(6, 182, 212, 0.45);
  }
}
.ast-chat-fab .ast-chat-fab-icon-close {
  display: none;
}
.ast-chat-fab-wrap.open .ast-chat-fab .ast-chat-fab-icon-open {
  display: none;
}
.ast-chat-fab-wrap.open .ast-chat-fab .ast-chat-fab-icon-close {
  display: block;
}

/* pulsing ring to draw the eye without being obnoxious */
.ast-chat-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(47, 125, 67, 0.5);
  animation: ast-chat-pulse 2.6s ease-out infinite;
  pointer-events: none;
}
.ast-chat-fab-wrap.open .ast-chat-fab::after {
  animation: none;
  box-shadow: none;
}
@keyframes ast-chat-pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 125, 67, 0.45); }
  70% { box-shadow: 0 0 0 14px rgba(47, 125, 67, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 125, 67, 0); }
}

/* tooltip */
.ast-chat-tooltip {
  order: 1;
  background: #fff;
  color: #1f2937;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  white-space: nowrap;
  opacity: 1;
  transform: translateX(0);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  position: relative;
}
.ast-chat-tooltip::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px 0 6px 6px;
  border-style: solid;
  border-color: transparent transparent transparent #fff;
}
/* Visible by default; only hidden once the chat panel is opened */
.ast-chat-fab-wrap.open .ast-chat-tooltip {
  display: none;
}

/* chat panel */
.ast-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 9999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 140px);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(34, 197, 94, 0.12),
    0 0 44px rgba(34, 197, 94, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.ast-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ast-chat-header {
  background: linear-gradient(135deg, #2f7d43, #1f9d6e);
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ast-chat-header .ast-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15), 0 0 14px rgba(255, 255, 255, 0.35);
}
.ast-chat-header .ast-chat-header-text {
  flex: 1;
  min-width: 0;
}
.ast-chat-header .ast-chat-header-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.ast-chat-ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22c55e, #06b6d4);
  color: #fff;
  animation: ast-chat-badge-glow 2.4s ease-in-out infinite;
}
@keyframes ast-chat-badge-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(34, 197, 94, 0.55); }
  50% { box-shadow: 0 0 12px rgba(6, 182, 212, 0.75); }
}
.ast-chat-header .ast-chat-header-sub {
  font-size: 12px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 5px;
}
.ast-chat-header .ast-chat-header-sub::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7CFC9A;
  display: inline-block;
  box-shadow: 0 0 6px #7CFC9A;
  animation: ast-chat-dot-pulse 1.8s ease-in-out infinite;
}
@keyframes ast-chat-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
.ast-chat-close {
  background: none;
  border: none;
  color: #fff;
  opacity: 0.85;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.ast-chat-close:hover { opacity: 1; }

.ast-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f7f8f6;
}
.ast-chat-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.ast-chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: #1f2937;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.ast-chat-phone-link {
  color: #2f7d43;
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px dashed rgba(47, 125, 67, 0.5);
}
.ast-chat-phone-link:hover {
  color: #22c55e;
  border-bottom-style: solid;
}
.ast-chat-msg.user {
  align-self: flex-end;
  background: #2f7d43;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ast-chat-msg.error {
  align-self: flex-start;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.ast-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.ast-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: ast-chat-bounce 1.2s infinite ease-in-out;
}
.ast-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.ast-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ast-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ast-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eef0ee;
  flex-shrink: 0;
  background: #fff;
}
.ast-chat-input {
  flex: 1;
  border: 1px solid #d8dbe0;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease;
}
.ast-chat-input:focus {
  border-color: #2f7d43;
}
.ast-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #2f7d43;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 14px;
  transition: opacity 0.15s ease;
}
.ast-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ast-chat-credit {
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
  padding: 7px 0 10px;
  flex-shrink: 0;
  background: #fff;
}
.ast-chat-credit a {
  color: #6b7280;
  font-weight: 600;
  text-decoration: none;
}
.ast-chat-credit a:hover {
  color: #2f7d43;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .ast-chat-panel {
    right: 16px;
    left: 16px;
    width: auto;
    bottom: 92px;
  }
  .ast-chat-fab-wrap {
    right: 16px;
    bottom: 16px;
  }
}
