/* =========================================================
   24/7 chat assistant (js/chat.js). Uses the colour variables from style.css
   ========================================================= */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.chat { position: fixed; right: 22px; bottom: 22px; z-index: 90; font-family: var(--ff-body); }

/* ---------- Launcher button ---------- */
.chat__launcher {
  position: relative; width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--gold); color: var(--dark); display: grid; place-items: center;
  box-shadow: 0 14px 30px -10px rgba(42,26,14,.55); transition: transform .25s, background .25s;
}
.chat__launcher:hover { transform: scale(1.06); background: var(--gold-light); }
.chat__launcher::before { /* soft pulse ring */
  content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--gold);
  animation: chat-pulse 2.4s ease-out infinite;
}
.chat.is-open .chat__launcher::before { animation: none; opacity: 0; }
.chat__launcher svg { width: 28px; height: 28px; grid-area: 1 / 1; transition: transform .3s, opacity .3s; }
.chat__ic-open { fill: var(--dark); }
.chat__ic-open circle { fill: var(--gold); }
.chat__ic-close { fill: none; stroke: var(--dark); stroke-width: 2.4; stroke-linecap: round; opacity: 0; transform: rotate(-90deg); }
.chat.is-open .chat__ic-open { opacity: 0; transform: rotate(90deg); }
.chat.is-open .chat__ic-close { opacity: 1; transform: none; }
.chat__badge {
  position: absolute; top: -2px; right: -2px; min-width: 21px; height: 21px; border-radius: 11px; padding: 0 5px;
  background: #d93025; color: #fff; font: 700 .75rem/17px var(--ff-head); text-align: center; border: 2px solid #fff;
}
.chat__badge[hidden] { display: none; }
@keyframes chat-pulse { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- Teaser bubble ---------- */
.chat__teaser {
  position: absolute; right: 0; bottom: 78px; width: 250px; padding: .9rem 2rem .9rem 1rem; cursor: pointer;
  background: var(--white); color: var(--text); border-radius: 14px 14px 4px 14px; font-size: .9rem; line-height: 1.5;
  box-shadow: 0 18px 40px -14px rgba(42,26,14,.4); border: 1px solid var(--line); animation: chat-pop .4s cubic-bezier(.2,.8,.2,1);
}
.chat__teaser[hidden] { display: none; }
.chat__teaser strong { display: block; color: var(--dark); font-family: var(--ff-head); }
.chat__teaser-close {
  position: absolute; top: 4px; right: 6px; width: 26px; height: 26px; border: 0; background: none; cursor: pointer;
  font-size: 1.2rem; line-height: 1; color: var(--text); border-radius: 50%;
}
.chat__teaser-close:hover { background: var(--bg-soft); }

/* ---------- Panel ---------- */
.chat__panel {
  position: absolute; right: 0; bottom: 78px; width: 370px; height: min(600px, calc(100vh - 120px));
  display: flex; flex-direction: column; background: var(--white); border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 60px -20px rgba(42,26,14,.5); border: 1px solid var(--line);
  animation: chat-pop .35s cubic-bezier(.2,.8,.2,1); transform-origin: bottom right;
}
.chat__panel[hidden] { display: none; }
@keyframes chat-pop { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }

.chat__head {
  display: flex; align-items: center; gap: .75rem; padding: .9rem 1rem; color: #fff;
  background: radial-gradient(circle at 100% 0, rgba(212,162,55,.35), transparent 60%), var(--dark);
}
.chat__avatar { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.08); display: grid; place-items: center; flex: none; }
.chat__avatar img { width: 34px; height: 34px; }
.chat__who { flex: 1; line-height: 1.3; min-width: 0; }
.chat__who strong { display: block; font-family: var(--ff-head); font-size: 1rem; }
.chat__who small { font-size: .78rem; color: rgba(255,255,255,.75); display: flex; align-items: center; gap: .4rem; }
.chat__dot { width: 8px; height: 8px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgba(61,220,132,.25); animation: chat-blink 2s infinite; }
@keyframes chat-blink { 50% { box-shadow: 0 0 0 6px rgba(61,220,132,0); } }
.chat__head-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(255,255,255,.1); cursor: pointer;
  display: grid; place-items: center; flex: none; transition: background .2s;
}
.chat__head-btn:hover { background: var(--gold); }
.chat__head-btn svg { width: 18px; height: 18px; fill: #fff; }
button.chat__head-btn svg { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }

/* ---------- Messages ---------- */
.chat__log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .6rem; background: var(--bg-soft); overscroll-behavior: contain; }
.chat__msg { display: flex; animation: chat-pop .3s ease-out; }
.chat__msg p, .chat__bubble { margin: 0; padding: .65rem .9rem; border-radius: 14px; font-size: .92rem; line-height: 1.55; max-width: 85%; overflow-wrap: anywhere; }
.chat__msg--bot .chat__bubble, .chat__msg--bot p { background: var(--white); color: var(--dark); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat__msg--user { justify-content: flex-end; }
.chat__msg--user p { background: var(--dark); color: #fff; border-bottom-right-radius: 4px; }
.chat__bubble a:not(.chat__action) { color: var(--gold-dark); font-weight: 600; }
.chat__list { margin: .3rem 0 0; padding-left: 1.1rem; }
.chat__list li { margin-bottom: .3rem; }
.chat__summary { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .6rem 0; padding: .6rem .8rem; background: var(--bg-soft); border-radius: 8px; font-size: .88rem; }
.chat__summary dt { font-weight: 700; color: var(--text); }
.chat__summary dd { margin: 0; }
.chat__actions { display: grid; gap: .4rem; margin: .6rem 0 .3rem; }
.chat__action {
  display: block; width: 100%; text-align: center; padding: .55rem .8rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--dark); font: 600 .88rem var(--ff-head); cursor: pointer; transition: background .2s, border-color .2s;
}
.chat__action:hover { border-color: var(--gold); background: #fff6e0; }
.chat__action--wa { background: #25d366; border-color: #25d366; color: #fff; }
.chat__action--wa:hover { background: #1ebe5b; border-color: #1ebe5b; }
.chat__action--urgent { background: #d93025; border-color: #d93025; color: #fff; }
.chat__action--urgent:hover { background: #b9261d; border-color: #b9261d; }

.chat__typing p { display: flex; gap: 4px; padding: .8rem .9rem; }
.chat__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold-dark); opacity: .4; animation: chat-typing 1s infinite; }
.chat__typing i:nth-child(2) { animation-delay: .15s; }
.chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-typing { 30% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Quick replies + input ---------- */
.chat__chips { display: flex; flex-wrap: wrap; gap: .4rem; max-height: 112px; overflow-y: auto; padding: .6rem .8rem; background: var(--bg-soft); border-top: 1px solid var(--line); }
.chat__chips:empty { display: none; }
.chat__chip {
  padding: .4rem .8rem; border-radius: 999px; border: 1px solid var(--gold); background: var(--white);
  color: var(--gold-dark); font: 600 .82rem var(--ff-head); cursor: pointer; white-space: nowrap; transition: background .2s, color .2s;
}
.chat__chip:hover { background: var(--gold); color: var(--dark); }
.chat__form { display: flex; gap: .5rem; padding: .7rem .8rem .4rem; border-top: 1px solid var(--line); background: var(--white); }
.chat__form input {
  flex: 1; min-width: 0; padding: .65rem .9rem; border-radius: 999px; border: 1px solid var(--line);
  font: inherit; font-size: 1rem; color: var(--dark); background: var(--bg-soft);
}
.chat__form input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: transparent; }
.chat__form button { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 0; background: var(--dark); cursor: pointer; display: grid; place-items: center; transition: background .2s; }
.chat__form button:hover { background: var(--gold); }
.chat__form button svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linejoin: round; }
.chat__foot { margin: 0; padding: 0 .8rem .55rem; background: var(--white); text-align: center; font-size: .72rem; color: var(--text); }

/* sit above the mobile action bar (shown at 1160px and below) */
@media (max-width: 1160px) {
  .chat { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
}
@media (max-width: 640px) {
  .chat { right: 14px; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  .chat__launcher { width: 56px; height: 56px; }
  .chat.is-open .chat__launcher { display: none; }
  .chat__panel { position: fixed; inset: 0; width: auto; height: 100dvh; border-radius: 0; border: 0; }
  .chat__teaser { bottom: 70px; }
}
@media (prefers-reduced-motion: reduce) {
  .chat *, .chat *::before { animation: none !important; transition: none !important; }
}
