/* Avoria Chat widget - scoped to #avoria-chat-root, brand blue like the rest of the site. */
/* The lift lives on <html>: the launcher, the panel and the theme's scroll-to-top
   button all move up together when the consent box is in the way. */
:root { --avoria-chat-lift: 0px; }
#avoria-chat-root {
  --avoria-chat-blue: #065192;
  --avoria-chat-blue-dark: #0d3b6e;
  --avoria-chat-blue-light: #1a6fb5;
  --avoria-chat-ink: #0b1728;
  --avoria-chat-muted: #5b6b80;
  --avoria-chat-bg: #ffffff;
  --avoria-chat-soft: #f1f5fb;
  --avoria-chat-line: rgba(6, 81, 146, 0.16);
  --avoria-chat-z: 2147482800;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--avoria-chat-ink);
}
#avoria-chat-root *,
#avoria-chat-root *::before,
#avoria-chat-root *::after { box-sizing: border-box; }
#avoria-chat-root [hidden] { display: none !important; }

/* In-flow access stays available while the floating launcher gives forms room. */
.avoria-chat-inline {
  display: block;
  margin: 18px 0 0;
  padding: 10px 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.avoria-chat-inline:focus-visible { outline: 3px solid #7eb8ed; outline-offset: 4px; }
html:has(#avoria-chat-root.avoria-chat-enquiry-near) #scroll-top-btn {
  opacity: 0 !important;
  pointer-events: none !important;
}
@media (prefers-reduced-motion: reduce) {
  #avoria-chat-root *, #avoria-chat-root *::before, #avoria-chat-root *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- launcher ---------- */
#avoria-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--avoria-chat-lift));
  z-index: var(--avoria-chat-z);
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--avoria-chat-blue-dark) 0%, var(--avoria-chat-blue-light) 100%);
  color: #fff;
  font: 600 15px/1 Inter, system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(6, 81, 146, 0.35);
  transition: transform .15s ease, box-shadow .15s ease, bottom .2s ease;
}
#avoria-chat-launcher:hover { transform: translateY(-1px); box-shadow: 0 14px 34px rgba(6, 81, 146, 0.42); }
#avoria-chat-launcher:focus-visible,
#avoria-chat-root button:focus-visible,
#avoria-chat-root a:focus-visible,
#avoria-chat-root input:focus-visible,
#avoria-chat-root textarea:focus-visible { outline: 3px solid #7eb8ed; outline-offset: 2px; }
#avoria-chat-launcher.is-open .avoria-chat-launcher-label,
#avoria-chat-launcher.is-compact .avoria-chat-launcher-label { max-width: 0; opacity: 0; margin-left: -10px; }
#avoria-chat-launcher.is-open,
#avoria-chat-launcher.is-compact { padding: 0 15px; }
.avoria-chat-launcher-icon { display: inline-flex; }
.avoria-chat-launcher-label {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  max-width: 320px;
  opacity: 1;
  transition: max-width .45s ease, opacity .3s ease .1s, margin-left .45s ease;
}

#avoria-chat-root.avoria-chat-consent-hides #avoria-chat-launcher { opacity: 0; pointer-events: none; transform: translateY(24px); }

/* ---------- theme scroll-to-top button ----------
   The theme puts #scroll-top-btn in the same corner as the launcher (bottom/right 36px,
   48 x 56). Park it above the launcher so both stay visible, and hide it while the
   chat window is open (the window covers that spot anyway). */
#scroll-top-btn {
  bottom: calc(20px + 56px + 14px + var(--avoria-chat-lift, 0px)) !important;
  right: 24px !important;
}
html.avoria-chat-open #scroll-top-btn { opacity: 0 !important; pointer-events: none !important; }

/* ---------- panel ---------- */
.avoria-chat-panel {
  position: fixed;
  right: 20px;
  bottom: calc(88px + var(--avoria-chat-lift));
  z-index: var(--avoria-chat-z);
  width: min(390px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  background: var(--avoria-chat-bg);
  border: 1px solid var(--avoria-chat-line);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(4, 11, 23, 0.28);
  overflow: hidden;
  transition: bottom .2s ease;
}

.avoria-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background: linear-gradient(135deg, var(--avoria-chat-blue-dark) 0%, var(--avoria-chat-blue-light) 100%);
  color: #fff;
}
.avoria-chat-avatar {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
}
.avoria-chat-heading { flex: 1 1 auto; min-width: 0; }
.avoria-chat-title { font-weight: 700; font-size: 16px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avoria-chat-subline { display: flex; align-items: center; min-width: 0; margin-top: 2px; }
.avoria-chat-subtitle { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avoria-chat-badge {
  flex: 0 0 auto;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: #22c55e; color: #05240f;
  white-space: nowrap;
}
.avoria-chat-badge:not([hidden]) + .avoria-chat-subtitle { display: none; }
.avoria-chat-new {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: transparent;
  color: #fff;
  font: 600 12px/1 Inter, system-ui, sans-serif;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.avoria-chat-new:hover { background: rgba(255, 255, 255, 0.14); }
.avoria-chat-close {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.avoria-chat-close:hover { background: rgba(255, 255, 255, 0.24); }

/* ---------- conversation ---------- */
.avoria-chat-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fbfcfe;
}
.avoria-chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.avoria-chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.avoria-chat-msg-assistant { align-self: flex-start; }
.avoria-chat-msg-user { align-self: flex-end; align-items: flex-end; }
.avoria-chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 14.5px;
}
.avoria-chat-msg-assistant .avoria-chat-bubble {
  background: var(--avoria-chat-soft);
  color: var(--avoria-chat-ink);
  border-bottom-left-radius: 6px;
}
.avoria-chat-msg-user .avoria-chat-bubble {
  background: var(--avoria-chat-blue);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.avoria-chat-msg.is-error .avoria-chat-bubble { background: #fff3f2; color: #8a1c1c; border: 1px solid #f5c2c0; }

.avoria-chat-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.avoria-chat-link {
  display: inline-block;
  padding: 6px 11px;
  border: 1px solid var(--avoria-chat-blue);
  border-radius: 999px;
  color: var(--avoria-chat-blue);
  background: #fff;
  font-size: 13px; font-weight: 600;
  text-decoration: none;
}
.avoria-chat-link:hover { background: var(--avoria-chat-blue); color: #fff; }

.avoria-chat-typing .avoria-chat-bubble { display: inline-flex; gap: 5px; padding: 12px 14px; }
.avoria-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--avoria-chat-muted);
  animation: avoria-chat-blink 1.2s infinite ease-in-out;
}
.avoria-chat-typing span:nth-child(2) { animation-delay: .2s; }
.avoria-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes avoria-chat-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- pre-chat form ---------- */
.avoria-chat-form {
  flex: 0 0 auto;
  padding: 6px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid var(--avoria-chat-line);
  background: #fff;
}
.avoria-chat-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--avoria-chat-muted); }
.avoria-chat-field input,
.avoria-chat-input {
  width: 100%;
  border: 1px solid #c9d4e2;
  border-radius: 10px;
  padding: 10px 12px;
  font: 400 15px/1.4 Inter, system-ui, sans-serif;
  color: var(--avoria-chat-ink);
  background: #fff;
}
.avoria-chat-field input:focus, .avoria-chat-input:focus { border-color: var(--avoria-chat-blue); }
.avoria-chat-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; line-height: 1.45; color: var(--avoria-chat-muted); cursor: pointer; }
.avoria-chat-consent input { margin: 3px 0 0; flex: 0 0 auto; width: 16px; height: 16px; accent-color: var(--avoria-chat-blue); }
.avoria-chat-consent a { color: var(--avoria-chat-blue); text-decoration: underline; text-underline-offset: 2px; }
.avoria-chat-hint { font: 400 12px/1.35 Inter, system-ui, sans-serif; color: var(--avoria-chat-muted); }

/* The one-line "leave a phone number?" step before a handoff. */
.avoria-chat-phoneask {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 2px 0 6px 0;
  padding: 12px;
  border: 1px solid #c9d4e2;
  border-radius: 12px;
  background: #fff;
}
.avoria-chat-phoneinput {
  width: 100%;
  border: 1px solid #c9d4e2;
  border-radius: 10px;
  padding: 10px 12px;
  font: 400 15px/1.4 Inter, system-ui, sans-serif;
  color: var(--avoria-chat-ink);
  background: #fff;
}
.avoria-chat-phoneinput:focus { border-color: var(--avoria-chat-blue); outline: none; }
.avoria-chat-phoneask-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.avoria-chat-phoneask .avoria-chat-chip { min-height: 44px; }

.avoria-chat-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.avoria-chat-error { font-size: 13px; color: #8a1c1c; background: #fff3f2; border: 1px solid #f5c2c0; border-radius: 8px; padding: 8px 10px; }
.avoria-chat-start {
  border: 0;
  border-radius: 999px;
  background: var(--avoria-chat-blue);
  color: #fff;
  font: 700 15px/1 Inter, system-ui, sans-serif;
  padding: 13px 18px;
  cursor: pointer;
}
.avoria-chat-start:hover { background: var(--avoria-chat-blue-dark); }
.avoria-chat-start[disabled] { opacity: .6; cursor: default; }

/* ---------- chips + composer ---------- */
.avoria-chat-chips {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px 0;
  background: #fff;
  border-top: 1px solid var(--avoria-chat-line);
}
.avoria-chat-chip {
  flex: 0 0 auto;
  border: 1px solid var(--avoria-chat-line);
  border-radius: 999px;
  background: var(--avoria-chat-soft);
  color: var(--avoria-chat-blue);
  font: 600 12.5px/1 Inter, system-ui, sans-serif;
  padding: 8px 12px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.avoria-chat-chip:hover { background: var(--avoria-chat-blue); color: #fff; }
.avoria-chat-chip[disabled] { opacity: .55; cursor: default; }
.avoria-chat-chip[disabled]:hover { background: var(--avoria-chat-soft); color: var(--avoria-chat-blue); }

.avoria-chat-composer {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 12px;
  background: #fff;
}
.avoria-chat-input { flex: 1 1 auto; resize: none; max-height: 120px; }
.avoria-chat-send {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border: 0; border-radius: 50%;
  background: var(--avoria-chat-blue);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.avoria-chat-send:hover { background: var(--avoria-chat-blue-dark); }
.avoria-chat-send[disabled] { opacity: .5; cursor: default; }

.avoria-chat-footer {
  flex: 0 0 auto;
  padding: 6px 14px 9px;
  font-size: 11px;
  color: var(--avoria-chat-muted);
  background: #fff;
  border-top: 1px solid #eef2f7;
  text-align: center;
}
.avoria-chat-footer a { color: var(--avoria-chat-muted); text-decoration: underline; }

/* ---------- phones ---------- */
@media (max-width: 520px) {
  #avoria-chat-launcher { right: 14px; bottom: calc(14px + var(--avoria-chat-lift)); height: 52px; padding: 0 14px; }
  #scroll-top-btn { bottom: calc(14px + 52px + 12px + var(--avoria-chat-lift, 0px)) !important; right: 18px !important; }
  .avoria-chat-launcher-label { font-size: 14px; max-width: 240px; }
  .avoria-chat-panel {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: min(92vh, 92dvh);
    max-height: none;
    border-radius: 18px 18px 0 0;
  }
  .avoria-chat-new { display: none; }
  .avoria-chat-msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) {
  #avoria-chat-launcher, .avoria-chat-panel, .avoria-chat-launcher-label { transition: none; }
  .avoria-chat-typing span { animation: none; opacity: .6; }
  .avoria-chat-log { scroll-behavior: auto; }
}
