/* AVAG — website chatbot widget
   Scoped under .avag-chat to avoid clashing with landing styles.
   Brand tokens mirror index.html :root (olive / earth / warm neutral bg). */

.avag-chat {
  --ac-olive: #5A7A45;
  --ac-olive-l: #7A9B65;
  --ac-ink: #0F0F0F;
  --ac-bg: #FAFAF8;
  --ac-surface: #FFFFFF;
  --ac-surface-2: #F4F3EE;
  --ac-border: #E5E3DC;
  --ac-muted: #8A8A8A;
  --ac-text: #2A2A2A;
  --ac-radius: 18px;
  position: fixed;
  inset: auto;
  z-index: 2147483000;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ac-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Launcher bubble ─────────────────────────────────────── */
.avag-chat__bubble {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--ac-olive);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(15, 15, 15, 0.22);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  z-index: 2147483001;
}
.avag-chat__bubble:hover { transform: translateY(-2px) scale(1.03); background: var(--ac-olive-l); }
.avag-chat__bubble:active { transform: translateY(0) scale(0.98); }
.avag-chat__bubble svg { width: 26px; height: 26px; display: block; }

/* gentle attention pulse until first open */
.avag-chat__bubble.is-pulsing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(90, 122, 69, 0.5);
  animation: avag-pulse 2.4s ease-out infinite;
}
@keyframes avag-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(90, 122, 69, 0.45); }
  70%  { box-shadow: 0 0 0 16px rgba(90, 122, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(90, 122, 69, 0); }
}

/* ── Panel ───────────────────────────────────────────────── */
.avag-chat__panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 372px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 44px);
  background: var(--ac-surface);
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  box-shadow: 0 24px 60px rgba(15, 15, 15, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.avag-chat__panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.avag-chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--ac-olive);
  color: #fff;
}
.avag-chat__avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
  flex-shrink: 0;
}
.avag-chat__titles { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.avag-chat__title { font-weight: 700; font-size: 15px; }
.avag-chat__subtitle { font-size: 11.5px; opacity: 0.82; }
.avag-chat__close {
  border: none; background: transparent; color: #fff;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease;
}
.avag-chat__close:hover { background: rgba(255, 255, 255, 0.16); }
.avag-chat__close svg { width: 18px; height: 18px; }

/* Messages */
.avag-chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--ac-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.avag-chat__body::-webkit-scrollbar { width: 8px; }
.avag-chat__body::-webkit-scrollbar-thumb { background: var(--ac-border); border-radius: 8px; }

.avag-chat__msg { max-width: 84%; line-height: 1.5; font-size: 14px; }
.avag-chat__msg p { margin: 0 0 8px; }
.avag-chat__msg p:last-child { margin-bottom: 0; }
.avag-chat__msg strong { font-weight: 700; }

.avag-chat__msg--bot {
  align-self: flex-start;
  background: var(--ac-surface);
  border: 1px solid var(--ac-border);
  color: var(--ac-text);
  padding: 10px 13px;
  border-radius: 14px 14px 14px 4px;
}
.avag-chat__msg--user {
  align-self: flex-end;
  background: var(--ac-olive);
  color: #fff;
  padding: 10px 13px;
  border-radius: 14px 14px 4px 14px;
}

/* Typing indicator */
.avag-chat__typing { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.avag-chat__typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--ac-muted);
  animation: avag-bounce 1.2s infinite ease-in-out;
}
.avag-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.avag-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes avag-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Error note */
.avag-chat__err { font-size: 12.5px; color: #B4452F; align-self: center; text-align: center; }

/* Composer */
.avag-chat__form {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 12px;
  border-top: 1px solid var(--ac-border);
  background: var(--ac-surface);
}
.avag-chat__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--ac-border);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--ac-text);
  background: var(--ac-bg);
  max-height: 110px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.avag-chat__input:focus { border-color: var(--ac-olive-l); box-shadow: 0 0 0 3px rgba(122, 155, 101, 0.18); }
.avag-chat__input::placeholder { color: var(--ac-muted); }

.avag-chat__send {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: var(--ac-olive); color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.avag-chat__send:hover { background: var(--ac-olive-l); }
.avag-chat__send:active { transform: scale(0.94); }
.avag-chat__send:disabled { background: var(--ac-muted); cursor: not-allowed; }
.avag-chat__send svg { width: 18px; height: 18px; }

/* Footer note */
.avag-chat__foot { padding: 0 14px 10px; font-size: 10.5px; color: var(--ac-muted); text-align: center; background: var(--ac-surface); }

/* Small screens */
@media (max-width: 480px) {
  .avag-chat__panel {
    left: 0; right: 0; bottom: 0;
    width: auto; height: 100dvh;
    max-width: none; max-height: 100dvh;
    border-radius: 0;
  }
  .avag-chat__bubble { right: 16px; bottom: 16px; }
}
