/* ==========================================================================
   Website chat assistant
   Colours come from the admin theme (--site-*), so it restyles with the site.
   ========================================================================== */
.chat-widget { position: fixed; right: 16px; bottom: 16px; z-index: 1050; font-family: var(--site-font-body); }

/* launcher ---------------------------------------------------------------- */
.chat-launcher {
  position: relative; width: 56px; height: 56px; border-radius: 50%; border: 0;
  background: var(--site-primary); color: #fff; font-size: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px color-mix(in srgb, var(--site-primary) 45%, transparent);
  cursor: pointer; transition: transform .18s var(--site-ease), background .18s;
}
.chat-launcher:hover { transform: scale(1.06); background: var(--site-primary-dark); }
.chat-launcher .chat-ic-close { display: none; }
.chat-widget.is-open .chat-launcher .chat-ic-open { display: none; }
.chat-widget.is-open .chat-launcher .chat-ic-close { display: inline-block; font-size: 1.15rem; }
.chat-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 99px; background: var(--site-secondary); color: #fff;
  font-size: .72rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--site-body-bg);
}

/* panel ------------------------------------------------------------------- */
.chat-panel {
  position: absolute; right: 0; bottom: 70px; width: min(92vw, 380px);
  max-height: min(74vh, 620px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--site-card-bg); border: 1px solid var(--site-border);
  border-radius: calc(var(--site-radius) + 6px); box-shadow: 0 24px 60px rgba(15, 23, 42, .22);
  opacity: 0; transform: translateY(12px) scale(.98); pointer-events: none;
  transition: opacity .18s var(--site-ease), transform .18s var(--site-ease);
}
.chat-widget.is-open .chat-panel { opacity: 1; transform: none; pointer-events: auto; }

.chat-head { display: flex; align-items: center; gap: .65rem; padding: .85rem 1rem;
  background: linear-gradient(120deg, var(--site-primary-dark), var(--site-primary)); color: #fff; }
.chat-avatar { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; background: rgba(255,255,255,.18);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.chat-head-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.chat-head-text strong { font-size: .95rem; }
.chat-head-text small { font-size: .74rem; opacity: .9; display: inline-flex; align-items: center; gap: .35rem; }
.chat-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74,222,128,.25); }
.chat-close { margin-left: auto; background: none; border: 0; color: #fff; font-size: 1.1rem; width: 34px; height: 34px; border-radius: 8px; }
.chat-close:hover { background: rgba(255,255,255,.15); }

.chat-body { flex: 1 1 auto; overflow-y: auto; padding: 1rem .85rem .5rem; background: var(--site-soft);
  display: flex; flex-direction: column; gap: .6rem; scroll-behavior: smooth; overscroll-behavior: contain; }
.chat-msg { max-width: 86%; padding: .6rem .8rem; border-radius: 14px; font-size: .88rem; line-height: 1.5; white-space: pre-line; word-break: break-word; }
.chat-msg.bot { align-self: flex-start; background: var(--site-card-bg); border: 1px solid var(--site-border); border-bottom-left-radius: 4px; color: var(--site-body-text); }
.chat-msg.user { align-self: flex-end; background: var(--site-primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg a { color: inherit; text-decoration: underline; }

.chat-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: .7rem .85rem;
  background: var(--site-card-bg); border: 1px solid var(--site-border); border-radius: 14px; border-bottom-left-radius: 4px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--site-muted); animation: chatBlink 1.2s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .18s; }
.chat-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes chatBlink { 0%, 60%, 100% { opacity: .28; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* result cards ------------------------------------------------------------ */
.chat-cards { align-self: stretch; display: flex; flex-direction: column; gap: .45rem; }
.chat-card { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; text-decoration: none;
  background: var(--site-card-bg); border: 1px solid var(--site-border); border-radius: var(--site-radius); transition: all .16s var(--site-ease); }
.chat-card:hover { border-color: var(--site-primary); box-shadow: var(--site-shadow-sm); transform: translateY(-1px); }
.chat-card img { width: 46px; height: 34px; object-fit: contain; flex: 0 0 46px; }
.chat-card .cc-ic { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 9px; background: var(--site-soft);
  color: var(--site-primary); display: inline-flex; align-items: center; justify-content: center; }
.chat-card .cc-body { min-width: 0; display: flex; flex-direction: column; }
.chat-card .cc-title { font-size: .85rem; font-weight: 700; color: var(--site-heading); }
.chat-card .cc-sub { font-size: .74rem; color: var(--site-muted); }
.chat-card .cc-price { margin-left: auto; font-size: .85rem; font-weight: 800; color: var(--site-primary); white-space: nowrap; }

.chat-cta { align-self: flex-start; display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: var(--site-radius-pill); background: var(--site-btn-bg); color: var(--site-btn-text);
  font-size: .84rem; font-weight: 700; text-decoration: none; }
.chat-cta:hover { background: var(--site-btn-hover); color: var(--site-btn-text); }

/* quick replies ----------------------------------------------------------- */
.chat-quick { display: flex; flex-wrap: wrap; gap: .35rem; padding: .5rem .85rem 0; background: var(--site-soft); }
.chat-quick:empty { padding: 0; }
.chat-quick button { background: var(--site-card-bg); border: 1px solid var(--site-primary); color: var(--site-primary);
  border-radius: var(--site-radius-pill); padding: .35rem .75rem; font-size: .8rem; font-weight: 600; cursor: pointer; }
.chat-quick button:hover { background: var(--site-primary); color: #fff; }

/* lead form --------------------------------------------------------------- */
.chat-lead { align-self: stretch; background: var(--site-card-bg); border: 1px solid var(--site-border);
  border-radius: var(--site-radius); padding: .75rem; display: flex; flex-direction: column; gap: .45rem; }
.chat-lead label { font-size: .76rem; font-weight: 700; color: var(--site-heading); }
.chat-lead input { border: 1px solid var(--site-border); border-radius: var(--site-radius-sm); padding: .5rem .65rem; font-size: .85rem; width: 100%; }
.chat-lead input:focus { outline: 0; border-color: var(--site-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--site-primary) 15%, transparent); }
.chat-lead .err { color: #dc2626; font-size: .75rem; }
.chat-lead button { background: var(--site-primary); color: #fff; border: 0; border-radius: var(--site-radius-sm); padding: .55rem; font-weight: 700; font-size: .85rem; cursor: pointer; }

/* input ------------------------------------------------------------------- */
.chat-input { display: flex; gap: .4rem; padding: .6rem .7rem; border-top: 1px solid var(--site-border); background: var(--site-card-bg); }
.chat-input input { flex: 1 1 auto; min-width: 0; border: 1px solid var(--site-border); border-radius: var(--site-radius-pill);
  padding: .6rem .9rem; font-size: 16px; background: var(--site-body-bg); color: var(--site-body-text); }
.chat-input input:focus { outline: 0; border-color: var(--site-primary); }
.chat-input button { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--site-primary); color: #fff; font-size: 1rem; cursor: pointer; }
.chat-input button:disabled { opacity: .5; cursor: default; }
.chat-foot { margin: 0; padding: 0 .8rem .7rem; font-size: .7rem; color: var(--site-muted); background: var(--site-card-bg); text-align: center; }
.chat-foot a { color: var(--site-primary); font-weight: 600; }

/* phones: full-width sheet, and keep clear of the bottom tab bar ----------- */
@media (max-width: 575.98px) {
  .chat-widget { right: 12px; bottom: calc(12px + var(--site-bottombar, 56px) + var(--site-safe-b, 0px)); }
  .chat-panel { position: fixed; right: 0; left: 0; bottom: 0; width: 100%;
    max-height: 88vh; height: 88vh; border-radius: 18px 18px 0 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .chat-msg { max-width: 90%; }
}
@media print { .chat-widget { display: none; } }
