/* =====================================================
   AG Construction & Pavers — AI Chatbot Styles
   Colors extracted from site design tokens:
   Primary:  #3D6B2E  (green)
   Deep:     #1E3D14  (green-deep)
   Sage mid: #7AAE5C
   Sage:     #A8CC8C
   Sage lt:  #D4E8C4
   Cream:    #F8F4EE
   ===================================================== */

/* ── Keyframes ────────────────────────────────────── */
@keyframes ag-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61,107,46,0.45); }
  50%       { box-shadow: 0 0 0 12px rgba(61,107,46,0); }
}

@keyframes ag-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

@keyframes ag-slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

@keyframes ag-fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

@keyframes ag-badgePop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ── Floating Button ──────────────────────────────── */
#ag-chat-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D6B2E 0%, #7AAE5C 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  box-shadow: 0 4px 20px rgba(61,107,46,0.4);
  animation: ag-pulse 2.5s ease-in-out infinite;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

#ag-chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(61,107,46,0.55);
  animation: none;
}

#ag-chat-toggle:active {
  transform: scale(0.96);
}

#ag-chat-toggle svg {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

/* Notification badge */
#ag-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #E53935;
  color: #fff;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: ag-badgePop 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}

#ag-chat-badge.ag-hidden {
  display: none;
}

/* ── Chat Window ──────────────────────────────────── */
#ag-chat-window {
  position: fixed;
  bottom: 100px;
  left: 24px;
  width: 380px;
  height: 520px;
  background: #FFFFFF;
  border-radius: 20px;
  box-shadow: 0 16px 60px rgba(30,61,20,0.18), 0 4px 20px rgba(30,61,20,0.10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  animation: ag-slideUp 0.32s cubic-bezier(0.34,1.56,0.64,1) both;
  font-family: 'DM Sans', system-ui, sans-serif;
}

#ag-chat-window.ag-hidden {
  display: none;
}

/* ── Header ───────────────────────────────────────── */
.ag-chat-header {
  background: linear-gradient(135deg, #3D6B2E 0%, #7AAE5C 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.ag-chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ag-chat-header-avatar svg {
  width: 22px;
  height: 22px;
}

.ag-chat-header-info {
  flex: 1;
  min-width: 0;
}

.ag-chat-header-name {
  font-size: 14px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ag-chat-header-status {
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.ag-chat-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #A8CC8C;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

.ag-chat-close {
  background: rgba(255,255,255,0.18);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s;
  line-height: 1;
}

.ag-chat-close:hover {
  background: rgba(255,255,255,0.30);
}

/* ── Messages Area ────────────────────────────────── */
.ag-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F8F4EE;
  scroll-behavior: smooth;
}

.ag-chat-messages::-webkit-scrollbar { width: 3px; }
.ag-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ag-chat-messages::-webkit-scrollbar-thumb { background: #D4E8C4; border-radius: 2px; }

/* ── Message Bubbles ──────────────────────────────── */
.ag-msg {
  display: flex;
  gap: 8px;
  animation: ag-fadeIn 0.22s ease both;
  max-width: 88%;
}

.ag-msg.ag-msg-bot {
  align-self: flex-start;
}

.ag-msg.ag-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ag-msg-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.ag-msg-bot .ag-msg-bubble {
  background: #FFFFFF;
  color: #1C1C1C;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(30,61,20,0.08);
}

.ag-msg-user .ag-msg-bubble {
  background: linear-gradient(135deg, #3D6B2E 0%, #7AAE5C 100%);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(61,107,46,0.25);
}

.ag-msg-bubble p { margin: 0 0 6px; }
.ag-msg-bubble p:last-child { margin-bottom: 0; }
.ag-msg-bubble strong { font-weight: 700; }
.ag-msg-bubble ul, .ag-msg-bubble ol {
  margin: 4px 0 4px 18px;
  padding: 0;
}
.ag-msg-bubble li { margin: 2px 0; }

/* ── Typing Indicator ─────────────────────────────── */
.ag-typing {
  display: flex;
  gap: 8px;
  align-self: flex-start;
  animation: ag-fadeIn 0.22s ease both;
}

.ag-typing-bubble {
  background: #FFFFFF;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(30,61,20,0.08);
}

.ag-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7AAE5C;
  animation: ag-bounce 1.2s ease-in-out infinite;
}

.ag-typing-dot:nth-child(1) { animation-delay: 0s; }
.ag-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.ag-typing-dot:nth-child(3) { animation-delay: 0.36s; }

/* ── Quick Options ────────────────────────────────── */
.ag-quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px 14px 4px;
  background: #F8F4EE;
  flex-shrink: 0;
}

.ag-quick-btn {
  background: #FFFFFF;
  color: #3D6B2E;
  border: 1.5px solid #A8CC8C;
  border-radius: 20px;
  padding: 6px 13px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  white-space: nowrap;
}

.ag-quick-btn:hover {
  background: #3D6B2E;
  color: #FFFFFF;
  border-color: #3D6B2E;
}

/* ── Lead Capture Form ────────────────────────────── */
.ag-lead-form {
  padding: 10px 14px;
  background: #F8F4EE;
  flex-shrink: 0;
  border-top: 1px solid #D4E8C4;
}

.ag-lead-form input {
  width: 100%;
  background: #FFFFFF;
  border: 1.5px solid #D4E8C4;
  border-radius: 10px;
  padding: 10px 13px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.5px;
  color: #1C1C1C;
  outline: none;
  transition: border-color 0.18s;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.ag-lead-form input:focus {
  border-color: #7AAE5C;
}

.ag-lead-submit {
  width: 100%;
  background: linear-gradient(135deg, #3D6B2E 0%, #7AAE5C 100%);
  color: #FFFFFF;
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.18s;
}

.ag-lead-submit:hover {
  opacity: 0.88;
}

/* ── Input Row ────────────────────────────────────── */
.ag-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #FFFFFF;
  border-top: 1px solid #EDE8DC;
  flex-shrink: 0;
}

.ag-chat-input {
  flex: 1;
  background: #F8F4EE;
  border: 1.5px solid #D4E8C4;
  border-radius: 22px;
  padding: 9px 14px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13.5px;
  color: #1C1C1C;
  outline: none;
  resize: none;
  transition: border-color 0.18s;
  max-height: 80px;
  line-height: 1.4;
}

.ag-chat-input:focus {
  border-color: #7AAE5C;
}

.ag-chat-input::placeholder {
  color: #7A7A7A;
}

.ag-chat-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D6B2E 0%, #7AAE5C 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.18s, transform 0.15s;
  box-shadow: 0 2px 8px rgba(61,107,46,0.3);
}

.ag-chat-send:hover {
  opacity: 0.88;
  transform: scale(1.05);
}

.ag-chat-send:active {
  transform: scale(0.95);
}

.ag-chat-send svg {
  width: 17px;
  height: 17px;
  color: #fff;
}

/* ── Mobile: Full Screen ──────────────────────────── */
@media (max-width: 480px) {
  #ag-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
  }

  #ag-chat-toggle {
    bottom: 16px;
    left: 16px;
  }
}
