/* ===================================================
   Asheville Tree Experts — Chatbot Styles
   =================================================== */

:root {
  --primary: #075c07;
  --accent: #6fcf6f;
  --bg: #0A0F07;
  --surface: #111a0d;
  --text: #F5F0E8;
  --text-muted: rgba(245, 240, 232, 0.5);
  --border: rgba(111, 207, 111, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  --radius: 20px;
}

/* =====================
   KEYFRAMES
   ===================== */
@keyframes chatPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111, 207, 111, 0.5), 0 6px 24px rgba(0,0,0,0.5); }
  50%       { box-shadow: 0 0 0 10px rgba(111, 207, 111, 0), 0 6px 24px rgba(0,0,0,0.5); }
}

@keyframes chatOpen {
  from { opacity: 0; transform: scale(0.7) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes messageIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

@keyframes hexSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

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

/* =====================
   FLOATING BUTTON
   ===================== */
#ate-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #075c07, #0a8a0a);
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background 0.3s ease;
  animation: chatPulse 2.5s ease-in-out infinite;
  border: none;
  outline: none;
}

#ate-chat-toggle:hover {
  transform: scale(1.1);
  animation: none;
  box-shadow: 0 0 0 6px rgba(111, 207, 111, 0.25);
}

#ate-chat-toggle.is-open {
  background: linear-gradient(135deg, #0a8a0a, #075c07);
  animation: none;
  transform: rotate(30deg);
}

#ate-chat-toggle .btn-icon {
  width: 32px;
  height: 32px;
  transition: transform 0.3s ease;
}

#ate-chat-toggle.is-open .btn-icon {
  transform: rotate(-30deg);
}

/* Badge */
#ate-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #e53e3e;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  animation: badgePop 0.4s ease-out;
  border: 2px solid #0A0F07;
}

/* =====================
   CHAT CONTAINER
   ===================== */
#ate-chat-container {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transform-origin: bottom right;
  animation: chatOpen 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
}

#ate-chat-container.is-hidden {
  display: none;
}

/* =====================
   HEADER
   ===================== */
.ate-header {
  background: linear-gradient(135deg, #053d05, #075c07);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ate-header-avatar {
  width: 42px;
  height: 42px;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  background: linear-gradient(135deg, #0a8a0a, #6fcf6f);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

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

.ate-header-name {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ate-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-size: 12px;
  margin-top: 2px;
}

.ate-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: chatPulse 2s ease-in-out infinite;
}

.ate-header-close {
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.ate-header-close:hover {
  background: rgba(255,255,255,0.2);
}

/* =====================
   MESSAGES AREA
   ===================== */
.ate-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
  scroll-behavior: smooth;
}

.ate-messages::-webkit-scrollbar {
  width: 4px;
}

.ate-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ate-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Message bubbles */
.ate-message {
  display: flex;
  flex-direction: column;
  animation: messageIn 0.3s ease-out both;
  max-width: 85%;
}

.ate-message.user {
  align-self: flex-end;
  align-items: flex-end;
}

.ate-message.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.ate-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.ate-message.user .ate-bubble {
  background: linear-gradient(135deg, #075c07, #0a8a0a);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.ate-message.bot .ate-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.ate-bubble strong { font-weight: 700; color: var(--accent); }
.ate-bubble em     { font-style: italic; opacity: 0.9; }
.ate-bubble a      { color: var(--accent); text-decoration: underline; }
.ate-bubble ul     { margin: 6px 0 0 16px; padding: 0; }
.ate-bubble li     { margin-bottom: 3px; }

.ate-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* =====================
   TYPING INDICATOR
   ===================== */
.ate-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  animation: messageIn 0.3s ease-out both;
}

.ate-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: dotBounce 1.2s ease-in-out infinite;
}

.ate-typing span:nth-child(2) { animation-delay: 0.2s; }
.ate-typing span:nth-child(3) { animation-delay: 0.4s; }

/* =====================
   QUICK BUTTONS
   ===================== */
.ate-quick-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  scrollbar-width: none;
}

.ate-quick-row::-webkit-scrollbar { display: none; }

.ate-quick-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s;
  font-family: 'Space Grotesk', sans-serif;
  flex-shrink: 0;
}

.ate-quick-btn:hover {
  background: var(--accent);
  color: #0A0F07;
}

/* =====================
   INPUT AREA
   ===================== */
.ate-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.ate-textarea {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  padding: 10px 14px;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  overflow-y: auto;
  font-family: 'Space Grotesk', sans-serif;
  transition: border-color 0.2s;
  outline: none;
}

.ate-textarea::placeholder {
  color: var(--text-muted);
}

.ate-textarea:focus {
  border-color: rgba(111, 207, 111, 0.4);
}

.ate-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #075c07, #0a8a0a);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.ate-send-btn:hover {
  transform: scale(1.05);
}

.ate-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ate-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* =====================
   MOBILE
   ===================== */
@media (max-width: 480px) {
  #ate-chat-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    max-height: 100vh;
  }

  #ate-chat-toggle {
    bottom: 16px;
    right: 16px;
  }
}
