/* EWE Chatbot – scoped under #ewe-chatbot. z-index sits below Bootstrap modals (1050+). */
#ewe-chatbot {
  --ewe-accent: #ff633c;
  --ewe-accent-2: #fe4a1d;
  --ewe-dark: #292f36;
  --ewe-text: #3b424a;
  --ewe-muted: #6a7382;
  --ewe-bg: #f5f6f8;
  --ewe-line: #e6e8ec;
  --ewe-radius: 18px;
  --ewe-gap: 20px;
  position: fixed;
  bottom: var(--ewe-gap);
  right: var(--ewe-gap);
  z-index: 1040;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ewe-text);
  -webkit-font-smoothing: antialiased;
}
#ewe-chatbot.ewe-pos-left { right: auto; left: var(--ewe-gap); }
#ewe-chatbot *, #ewe-chatbot *::before, #ewe-chatbot *::after { box-sizing: border-box; }
#ewe-chatbot [hidden] { display: none !important; }
#ewe-chatbot button, #ewe-chatbot input, #ewe-chatbot textarea {
  font: inherit; color: inherit; margin: 0; letter-spacing: normal; text-transform: none;
}
#ewe-chatbot button { cursor: pointer; background: none; border: 0; padding: 0; box-shadow: none; }
#ewe-chatbot svg { display: block; width: 100%; height: 100%; }

/* ---------- launcher ---------- */
#ewe-chatbot .ewe-launcher {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ewe-accent), var(--ewe-accent-2));
  color: #fff;
  box-shadow: 0 10px 28px rgba(254, 74, 29, 0.38), 0 2px 6px rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  margin-left: auto;
}
#ewe-chatbot.ewe-pos-left .ewe-launcher { margin-left: 0; }
#ewe-chatbot .ewe-launcher:hover { transform: translateY(-2px) scale(1.04); }
#ewe-chatbot .ewe-launcher:focus-visible { outline: 3px solid rgba(255, 99, 60, 0.45); outline-offset: 3px; }
#ewe-chatbot .ewe-ico {
  grid-area: 1 / 1;
  width: 30px;
  height: 30px;
  transition: transform 0.25s ease, opacity 0.2s ease;
}
#ewe-chatbot .ewe-ico-close { width: 24px; height: 24px; opacity: 0; transform: rotate(-90deg) scale(0.6); }
#ewe-chatbot.ewe-open .ewe-ico-chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
#ewe-chatbot.ewe-open .ewe-ico-close { opacity: 1; transform: none; }
#ewe-chatbot .ewe-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--ewe-dark);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  border: 2px solid #fff;
}

/* ---------- avatar ---------- */
#ewe-chatbot .ewe-avatar {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ewe-accent), var(--ewe-accent-2));
  color: #fff;
  font-family: "Zilla Slab", Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  display: grid;
  place-items: center;
}
#ewe-chatbot .ewe-avatar-lg { width: 42px; height: 42px; font-size: 21px; background: #fff; color: var(--ewe-accent); }
#ewe-chatbot .ewe-avatar-sm { width: 28px; height: 28px; font-size: 14px; align-self: flex-end; }

/* ---------- teaser ---------- */
#ewe-chatbot .ewe-teaser {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 280px;
  opacity: 0;
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom right;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#ewe-chatbot.ewe-pos-left .ewe-teaser { right: auto; left: 0; transform-origin: bottom left; }
#ewe-chatbot .ewe-teaser.ewe-in { opacity: 1; transform: none; }
#ewe-chatbot .ewe-teaser-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  text-align: left;
  background: #fff;
  border-radius: 16px 16px 4px 16px;
  padding: 14px 16px;
  box-shadow: 0 12px 34px rgba(41, 47, 54, 0.18);
}
#ewe-chatbot.ewe-pos-left .ewe-teaser-body { border-radius: 16px 16px 16px 4px; }
#ewe-chatbot .ewe-teaser-text { display: flex; flex-direction: column; gap: 2px; }
#ewe-chatbot .ewe-teaser-text strong { font-size: 12px; font-weight: 600; color: var(--ewe-muted); }
#ewe-chatbot .ewe-teaser-text span { font-size: 15px; font-weight: 500; color: var(--ewe-dark); }
#ewe-chatbot .ewe-teaser-close {
  position: absolute;
  top: -10px;
  left: -10px;
  width: 24px;
  height: 24px;
  padding: 6px;
  border-radius: 50%;
  background: var(--ewe-dark);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

/* ---------- panel ---------- */
#ewe-chatbot .ewe-panel {
  padding: 0;
  margin: 0;
  position: absolute;
  bottom: 78px;
  right: 0;
  width: 370px;
  height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--ewe-radius);
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(41, 47, 54, 0.25);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
#ewe-chatbot.ewe-pos-left .ewe-panel { right: auto; left: 0; transform-origin: bottom left; }
#ewe-chatbot .ewe-panel.ewe-in { opacity: 1; transform: none; }

#ewe-chatbot .ewe-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 14px 16px 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--ewe-accent), var(--ewe-accent-2));
}
#ewe-chatbot .ewe-head-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#ewe-chatbot .ewe-head-text strong {
  font-family: "Zilla Slab", Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ewe-chatbot .ewe-status { font-size: 12px; opacity: 0.92; display: flex; align-items: center; gap: 6px; }
#ewe-chatbot .ewe-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc84;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6);
}
#ewe-chatbot .ewe-icon-btn {
  width: 34px;
  height: 34px;
  padding: 7px;
  border-radius: 50%;
  color: #fff;
  transition: background 0.15s;
}
#ewe-chatbot .ewe-icon-btn:hover { background: rgba(255, 255, 255, 0.18); }

/* ---------- messages ---------- */
#ewe-chatbot .ewe-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 14px 8px;
  background: var(--ewe-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #cfd3d9 transparent;
}
#ewe-chatbot .ewe-log::-webkit-scrollbar { width: 6px; }
#ewe-chatbot .ewe-log::-webkit-scrollbar-track { background: transparent; }
#ewe-chatbot .ewe-log::-webkit-scrollbar-thumb { background: #cfd3d9; border-radius: 3px; }
#ewe-chatbot .ewe-row { display: flex; gap: 8px; max-width: 100%; animation: ewe-pop 0.22s ease; }
#ewe-chatbot .ewe-from-visitor { justify-content: flex-end; }
#ewe-chatbot .ewe-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
#ewe-chatbot .ewe-from-bot .ewe-bubble {
  background: #fff;
  color: var(--ewe-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(41, 47, 54, 0.08);
}
#ewe-chatbot .ewe-from-visitor .ewe-bubble {
  background: var(--ewe-dark);
  color: #fff;
  border-bottom-right-radius: 4px;
}
@keyframes ewe-pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

#ewe-chatbot .ewe-typing { display: flex; gap: 4px; padding: 14px 16px; }
#ewe-chatbot .ewe-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b4bac3;
  animation: ewe-blink 1.2s infinite ease-in-out;
}
#ewe-chatbot .ewe-typing span:nth-child(2) { animation-delay: 0.15s; }
#ewe-chatbot .ewe-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ewe-blink { 0%, 80%, 100% { opacity: 0.35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- suggestion chips ---------- */
#ewe-chatbot .ewe-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; padding-left: 36px; animation: ewe-pop 0.25s ease; }
#ewe-chatbot .ewe-chip {
  padding: 7px 13px;
  border-radius: 18px;
  border: 1.5px solid var(--ewe-accent);
  background: #fff;
  color: var(--ewe-accent-2);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
#ewe-chatbot .ewe-chip:hover, #ewe-chatbot .ewe-chip:focus-visible { background: var(--ewe-accent); color: #fff; outline: none; }
#ewe-chatbot .ewe-chip-alt { border-color: var(--ewe-dark); color: var(--ewe-dark); }
#ewe-chatbot .ewe-chip-alt:hover, #ewe-chatbot .ewe-chip-alt:focus-visible { background: var(--ewe-dark); color: #fff; }

/* ---------- lead form ---------- */
#ewe-chatbot .ewe-lead {
  margin-left: 36px;
  padding: 14px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(41, 47, 54, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: ewe-pop 0.25s ease;
}
#ewe-chatbot .ewe-lead-title { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--ewe-dark); }
#ewe-chatbot .ewe-lead input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ewe-line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#ewe-chatbot .ewe-lead input:focus { border-color: var(--ewe-accent); box-shadow: 0 0 0 3px rgba(255, 99, 60, 0.15); }
#ewe-chatbot .ewe-lead-err { margin: 0; color: #d63638; font-size: 12px; }
#ewe-chatbot .ewe-lead-btn {
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ewe-accent), var(--ewe-accent-2));
  color: #fff;
  font-weight: 600;
}
#ewe-chatbot .ewe-lead-btn:disabled { opacity: 0.7; cursor: wait; }
#ewe-chatbot .ewe-lead-skip { font-size: 12px; color: var(--ewe-muted); align-self: center; text-decoration: underline; }

/* ---------- compose ---------- */
#ewe-chatbot .ewe-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border-top: 1px solid var(--ewe-line);
  background: #fff;
}
#ewe-chatbot .ewe-input {
  flex: 1;
  min-height: 40px;
  max-height: 110px;
  padding: 9px 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font-size: 14px;
  line-height: 22px;
  box-shadow: none;
}
#ewe-chatbot .ewe-send {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 50%;
  background: var(--ewe-accent);
  color: #fff;
  transition: background 0.15s, transform 0.15s;
}
#ewe-chatbot .ewe-send:hover { background: var(--ewe-accent-2); transform: scale(1.05); }

/* ---------- mobile: full-width panel ---------- */
@media (max-width: 575px) {
  #ewe-chatbot { --ewe-gap: 16px; }
  #ewe-chatbot .ewe-teaser { width: min(280px, calc(100vw - 32px)); }
  #ewe-chatbot .ewe-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
  }
  #ewe-chatbot.ewe-open .ewe-launcher { display: none; }
  #ewe-chatbot .ewe-input { font-size: 16px; } /* avoids iOS zoom on focus */
  html:has(#ewe-chatbot.ewe-open) { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  #ewe-chatbot *, #ewe-chatbot *::before, #ewe-chatbot *::after { animation: none !important; transition: none !important; }
}
