/* Holly Acre Chat widget. Colors come from settings via --hc1/--hc2/--hc3/--hink. */
#hachat-root {
  --hc1: #0072ff;
  --hc2: #8200f4;
  --hc3: #ff6c5f;
  --hink: #000;
  --hnavy: #01082a;
  --hgrad: linear-gradient(135deg, var(--hc1), var(--hc2) 55%, var(--hc3));
  --hfont: "Manrope", system-ui, -apple-system, "Segoe UI", Arial, Helvetica, sans-serif;
  --hhead: "Google Sans", "Manrope", system-ui, Arial, Helvetica, sans-serif;
  position: fixed;
  bottom: 20px;
  z-index: 2147483000;
  font-family: var(--hfont);
  font-size: 15px;
  line-height: 1.5;
  color: var(--hnavy);
  -webkit-font-smoothing: antialiased;
}
#hachat-root.hachat-pos-right { right: 20px; }
#hachat-root.hachat-pos-left { left: 20px; }
#hachat-root *, #hachat-root *::before, #hachat-root *::after { box-sizing: border-box; }
/* Themes often style p, li, and strong globally (color, size, margins). Reset them inside the widget. */
#hachat-root p,
#hachat-root ul,
#hachat-root ol,
#hachat-root li,
#hachat-root span,
#hachat-root strong,
#hachat-root a {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
}

/* Launcher */
#hachat-root .hachat-launcher {
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: var(--hgrad);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(130, 0, 244, .28), 0 2px 6px rgba(0, 0, 0, .12);
  transition: transform .18s ease, box-shadow .18s ease;
  margin-left: auto;
}
#hachat-root.hachat-pos-left .hachat-launcher { margin-left: 0; }
#hachat-root .hachat-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(130, 0, 244, .34), 0 2px 6px rgba(0, 0, 0, .12); }
#hachat-root .hachat-launcher:focus-visible,
#hachat-root button:focus-visible { outline: 3px solid var(--hc1); outline-offset: 2px; }
#hachat-root .hachat-launcher svg { width: 26px; height: 26px; grid-area: 1 / 1; transition: opacity .15s ease, transform .2s ease; }
#hachat-root .hachat-launcher svg:last-child { opacity: 0; transform: rotate(-45deg); }
#hachat-root.is-open .hachat-launcher svg:first-child { opacity: 0; transform: rotate(45deg); }
#hachat-root.is-open .hachat-launcher svg:last-child { opacity: 1; transform: none; }

/* Panel */
#hachat-root .hachat-panel {
  position: absolute;
  bottom: 76px;
  width: 380px;
  height: min(620px, calc(100vh - 120px));
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(1, 8, 42, .22), 0 2px 8px rgba(1, 8, 42, .08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: hachat-in .2s ease;
}
#hachat-root.hachat-pos-right .hachat-panel { right: 0; transform-origin: bottom right; }
#hachat-root.hachat-pos-left .hachat-panel { left: 0; transform-origin: bottom left; }
#hachat-root .hachat-panel[hidden] { display: none; }
@keyframes hachat-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

#hachat-root .hachat-head {
  background: var(--hgrad);
  color: #fff;
  padding: 16px 14px 16px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: none;
}
#hachat-root .hachat-ident { display: flex; flex-direction: column; min-width: 0; flex: 1; }
#hachat-root .hachat-name { font-family: var(--hhead); font-weight: 500; font-size: 17px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hachat-root .hachat-subtitle { font-size: 13px; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hachat-root .hachat-badge { font-size: 11px; font-weight: 700; letter-spacing: .02em; background: rgba(255, 255, 255, .22); border-radius: 99px; padding: 3px 9px; flex: none; }
#hachat-root .hachat-close {
  width: 34px; height: 34px; border: 0; border-radius: 50%; padding: 0; flex: none;
  background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; display: grid; place-items: center;
}
#hachat-root .hachat-close:hover { background: rgba(255, 255, 255, .28); }
#hachat-root .hachat-close svg { width: 18px; height: 18px; }

/* Avatar */
#hachat-root .hachat-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .2);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .55);
  font-family: var(--hhead); font-weight: 600; font-size: 15px; color: #fff;
}
#hachat-root .hachat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
#hachat-root .hachat-avatar.is-small {
  width: 28px; height: 28px; font-size: 11px; box-shadow: none; background: var(--hgrad); align-self: flex-end;
}

/* Messages */
#hachat-root .hachat-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  background: #f8f9fa;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
#hachat-root .hachat-row { display: flex; gap: 8px; margin: 0 0 12px; }
#hachat-root .hachat-user { justify-content: flex-end; }
#hachat-root .hachat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
#hachat-root .hachat-bot .hachat-bubble { color: var(--hnavy); background: #fff; border-bottom-left-radius: 6px; box-shadow: 0 2px 6px rgba(0, 0, 0, .05); }
#hachat-root .hachat-user .hachat-bubble { background: var(--hink); color: #fff; border-bottom-right-radius: 6px; }
#hachat-root .hachat-bubble p { margin: 0 0 8px; }
#hachat-root .hachat-bubble p:last-child,
#hachat-root .hachat-bubble ul:last-child,
#hachat-root .hachat-bubble ol:last-child { margin-bottom: 0; }
#hachat-root .hachat-bubble ul,
#hachat-root .hachat-bubble ol { margin: 0 0 8px; padding-left: 20px; }
#hachat-root .hachat-bubble ul { list-style: disc outside; }
#hachat-root .hachat-bubble ol { list-style: decimal outside; }
#hachat-root .hachat-bubble li { margin: 2px 0; padding: 0; display: list-item; list-style: inherit; background: none; }
#hachat-root .hachat-bubble li::before { content: none; }
#hachat-root .hachat-bubble a { color: var(--hc2); text-decoration: underline; text-underline-offset: 2px; }
#hachat-root .hachat-user .hachat-bubble a { color: #fff; }
#hachat-root .hachat-bubble strong { font-weight: 700; }

/* Typing dots */
#hachat-root .hachat-typing .hachat-bubble { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
#hachat-root .hachat-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--hc2); opacity: .35; animation: hachat-dot 1.2s infinite ease-in-out; }
#hachat-root .hachat-typing span:nth-child(2) { animation-delay: .15s; }
#hachat-root .hachat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hachat-dot { 0%, 80%, 100% { opacity: .35; transform: none; } 40% { opacity: 1; transform: translateY(-3px); } }

/* Suggested questions */
#hachat-root .hachat-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 12px 36px; }
#hachat-root .hachat-chip {
  font: inherit; font-size: 14px; line-height: 1.3;
  background: #fff; color: var(--hnavy);
  border: 1px solid rgba(1, 8, 42, .14);
  border-radius: 99px; padding: 8px 14px; cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
#hachat-root .hachat-chip:hover { border-color: var(--hc2); color: var(--hc2); }

/* Input */
#hachat-root .hachat-form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 10px 10px 14px; border-top: 1px solid #eceef1; background: #fff; flex: none; margin: 0;
}
#hachat-root .hachat-input {
  flex: 1; resize: none; border: 0; outline: none; background: transparent;
  font: inherit; color: var(--hnavy); padding: 9px 0; max-height: 120px; min-height: 22px; line-height: 1.45;
  box-shadow: none;
}
#hachat-root .hachat-form:focus-within { border-top-color: var(--hc2); box-shadow: inset 0 1px 0 var(--hc2); }
#hachat-root .hachat-input:focus,
#hachat-root .hachat-input:focus-visible { outline: none; box-shadow: none; border: 0; }
#hachat-root .hachat-input::placeholder { color: #8a8f9c; }
#hachat-root .hachat-send {
  width: 40px; height: 40px; border: 0; border-radius: 50%; padding: 0; flex: none;
  background: var(--hink); color: #fff; cursor: pointer; display: grid; place-items: center;
  transition: opacity .15s ease, transform .15s ease;
}
#hachat-root .hachat-send:hover { transform: translateY(-1px); }
#hachat-root .hachat-send:disabled { opacity: .45; cursor: default; transform: none; }
#hachat-root .hachat-send svg { width: 18px; height: 18px; }
#hachat-root .hachat-foot { margin: 0; padding: 0 14px 10px; font-size: 11.5px; color: #8a8f9c; background: #fff; text-align: center; }

/* Phones: full screen */
@media (max-width: 520px) {
  #hachat-root { bottom: 16px; }
  #hachat-root.hachat-pos-right { right: 16px; }
  #hachat-root.hachat-pos-left { left: 16px; }
  #hachat-root .hachat-panel {
    position: fixed; inset: 0; width: 100%; height: 100%; height: 100dvh; border-radius: 0; bottom: auto;
  }
  #hachat-root.is-open .hachat-launcher { display: none; }
  #hachat-root .hachat-input { font-size: 16px; } /* stops iOS zooming in */
}

@media (prefers-reduced-motion: reduce) {
  #hachat-root * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print { #hachat-root { display: none; } }
