/* ==========================================================================
   KENT AI WORKS — Receptionist chat widget styles
   Every class starts with "rx-" so the widget won't clash with the styles of
   whatever website it is added to. Colours are set per business through
   the CSS variables below (the widget script fills them in from its options).
   ========================================================================== */

/* Colour/font variables. ".rx-scope" lets forms outside the chat (e.g. a pop-up) share the same field styles. */
.rx-root, .rx-scope {
  --rx-accent: #14B8A6;
  --rx-accent-ink: #101827;
  --rx-header-bg: #101827;
  --rx-header-ink: #FFFFFF;
  --rx-user-bg: #101827;
  --rx-user-ink: #FFFFFF;
  --rx-ink: #101827;
  --rx-muted: #64748B;
  --rx-line: #E2E8F0;
  --rx-surface: #F7F8FA;
  --rx-white: #FFFFFF;
  --rx-error: #B42318;
  --rx-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --rx-font-head: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.rx-root {
  position: fixed; right: 24px; bottom: 24px; z-index: 2147483000;
  font-family: var(--rx-font); font-size: 15px; line-height: 1.5; color: var(--rx-ink);
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}
.rx-root *, .rx-root *::before, .rx-root *::after { box-sizing: border-box; }
.rx-root p { margin: 0; }
.rx-root button { font-family: inherit; }
.rx-root :focus-visible { outline: 3px solid var(--rx-accent); outline-offset: 2px; }
.rx-icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
.rx-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Visually hidden but still read out by screen readers */
.rx-is-open .rx-launcher-label, .rx-compact .rx-launcher-label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Launcher ---------- */
.rx-launcher {
  order: 3; position: relative;
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px 0 18px; border: 0; border-radius: 999px;
  background: var(--rx-header-bg); color: var(--rx-header-ink);
  font-family: var(--rx-font-head); font-weight: 700; font-size: 15px;
  box-shadow: 0 14px 34px -12px rgba(16, 24, 39, .55), 0 2px 6px rgba(16, 24, 39, .15);
  cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.rx-launcher:hover { transform: translateY(-1px); }
.rx-launcher-icon { display: grid; place-items: center; width: 24px; height: 24px; }
.rx-launcher-icon .rx-icon { width: 24px; height: 24px; }
.rx-launcher::after {
  /* small "online" dot */
  content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%;
  background: var(--rx-accent); border: 2px solid var(--rx-header-bg);
  top: 12px; left: 34px;
}
.rx-when-open { display: none !important; }
.rx-is-open .rx-when-open { display: grid !important; }
.rx-is-open .rx-when-closed { display: none !important; }
.rx-is-open .rx-launcher, .rx-compact .rx-launcher { width: 56px; padding: 0; justify-content: center; }
.rx-is-open .rx-launcher::after { display: none; }
.rx-compact .rx-launcher::after { top: 10px; left: 34px; }

/* ---------- Teaser ---------- */
.rx-teaser {
  order: 2; position: relative; max-width: 290px;
  background: var(--rx-white); border: 1px solid var(--rx-line); border-radius: 14px 14px 4px 14px;
  box-shadow: 0 16px 40px -16px rgba(16, 24, 39, .35);
  animation: rx-rise .25s ease-out;
}
.rx-teaser[hidden] { display: none; }
.rx-teaser-body {
  display: block; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 14px 36px 14px 16px; font-size: 14.5px; line-height: 1.45; color: var(--rx-ink);
}
.rx-teaser-close {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border: 0; border-radius: 8px;
  background: none; color: var(--rx-muted); cursor: pointer; display: grid; place-items: center;
}
.rx-teaser-close:hover { background: var(--rx-surface); }
.rx-teaser-close .rx-icon { width: 16px; height: 16px; }

/* ---------- Panel ---------- */
.rx-panel {
  order: 1;
  width: 390px; height: min(660px, calc(100vh - 120px)); height: min(660px, calc(100dvh - 120px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--rx-white); border: 1px solid var(--rx-line); border-radius: 18px;
  box-shadow: 0 30px 70px -24px rgba(16, 24, 39, .45), 0 4px 14px rgba(16, 24, 39, .08);
  animation: rx-rise .2s ease-out;
}
.rx-panel[hidden] { display: none; }

.rx-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 12px 14px 16px;
  background: var(--rx-header-bg); color: var(--rx-header-ink);
}
.rx-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  font-family: var(--rx-font-head); font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.rx-avatar .rx-icon { width: 20px; height: 20px; }
.rx-mini-avatar .rx-icon { width: 14px; height: 14px; stroke-width: 2.1; }
.rx-heading { flex: 1; min-width: 0; }
.rx-title { font-family: var(--rx-font-head); font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.rx-badge {
  font-family: var(--rx-font); font-weight: 600; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 5px; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .35); color: var(--rx-header-ink);
}
.rx-subtitle { font-size: 12.5px; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rx-subtitle-text { opacity: .82; overflow: hidden; text-overflow: ellipsis; }
.rx-online { width: 7px; height: 7px; border-radius: 50%; background: #34D399; flex: none; }
.rx-icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: inherit;
  display: grid; place-items: center; cursor: pointer; opacity: .85; flex: none;
}
.rx-icon-btn:hover { background: rgba(255, 255, 255, .1); opacity: 1; }
.rx-icon-btn .rx-icon { width: 19px; height: 19px; }

.rx-notice {
  display: flex; align-items: center; gap: 8px; padding: 8px 16px;
  background: var(--rx-surface); border-bottom: 1px solid var(--rx-line);
  font-size: 12px; color: var(--rx-muted);
}
.rx-notice .rx-icon { width: 15px; height: 15px; }

/* ---------- Messages ---------- */
.rx-messages {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 14px 8px; display: flex; flex-direction: column; gap: 10px;
  background: var(--rx-white);
}
.rx-messages:focus { outline: none; }
.rx-row { display: flex; gap: 8px; align-items: flex-end; animation: rx-fade .18s ease-out; }
.rx-row-user { justify-content: flex-end; }
.rx-mini-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--rx-header-bg); color: var(--rx-header-ink);
  font-family: var(--rx-font-head); font-weight: 800; font-size: 9.5px;
}
.rx-bubble { max-width: 84%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.5; overflow-wrap: anywhere; }
.rx-bubble-user { background: var(--rx-user-bg); color: var(--rx-user-ink); border-bottom-right-radius: 5px; }
.rx-bubble-bot { background: var(--rx-surface); border: 1px solid var(--rx-line); border-bottom-left-radius: 5px; }
.rx-bubble p + p, .rx-bubble p + ul, .rx-bubble ul + p { margin-top: 8px; }
.rx-bubble ul { margin: 6px 0 0; padding-left: 18px; }
.rx-bubble li { margin: 3px 0; }
.rx-bubble strong { font-weight: 600; }
.rx-bubble em { color: var(--rx-muted); font-size: 13px; }
.rx-bubble a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--rx-accent); text-decoration-thickness: 2px; }

.rx-typing { display: inline-flex; gap: 4px; align-items: center; padding: 14px 16px; }
.rx-typing span:not(.rx-sr) { width: 7px; height: 7px; border-radius: 50%; background: var(--rx-muted); opacity: .4; animation: rx-dot 1.1s infinite ease-in-out; }
.rx-typing span:nth-child(2) { animation-delay: .15s; }
.rx-typing span:nth-child(3) { animation-delay: .3s; }

/* ---------- Suggested replies ---------- */
.rx-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 4px 34px; animation: rx-fade .2s ease-out; }
.rx-chip {
  border: 1.5px solid var(--rx-line); background: var(--rx-white); color: var(--rx-ink);
  padding: 7px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 500; line-height: 1.3;
  cursor: pointer; text-align: left; transition: border-color .15s, background-color .15s;
}
.rx-chip:hover { border-color: var(--rx-accent); background: var(--rx-surface); }
/* The main next step, e.g. "Make a real enquiry" at the end of the demo */
.rx-chip-primary { background: var(--rx-accent); border-color: var(--rx-accent); color: var(--rx-accent-ink); font-weight: 600; }
.rx-chip-primary:hover { background: var(--rx-accent); border-color: var(--rx-accent-ink); }

/* ---------- Cards (form + confirmation) ---------- */
.rx-card-row { padding-left: 34px; }
.rx-card {
  width: 100%; background: var(--rx-white); border: 1px solid var(--rx-line); border-radius: 14px;
  padding: 16px; box-shadow: 0 6px 18px -12px rgba(16, 24, 39, .25);
}
.rx-card-title { font-family: var(--rx-font-head); font-weight: 700; font-size: 15px; }
.rx-form .rx-card-title { margin-bottom: 12px; }
.rx-form .rx-form-intro { font-size: 13.5px; color: var(--rx-muted); margin: -8px 0 12px; }
.rx-fields { display: block; }
.rx-optional { font-weight: 400; color: var(--rx-muted); }
.rx-field { margin-bottom: 10px; }
.rx-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.rx-field input, .rx-field textarea, .rx-field select {
  width: 100%; font: inherit; font-size: 15px; color: var(--rx-ink);
  border: 1.5px solid var(--rx-line); border-radius: 9px; background: var(--rx-white);
  padding: 9px 11px; transition: border-color .15s;
}
.rx-field textarea { resize: vertical; min-height: 70px; }
.rx-field input:focus, .rx-field textarea:focus, .rx-field select:focus { outline: none; border-color: var(--rx-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rx-accent) 20%, transparent); }
.rx-field [aria-invalid="true"] { border-color: var(--rx-error); }
.rx-err { color: var(--rx-error); font-size: 12.5px; margin-top: 4px !important; }
.rx-err:empty { display: none; }
.rx-form-note { display: flex; gap: 7px; align-items: flex-start; font-size: 12px; color: var(--rx-muted); margin: 4px 0 12px !important; }
.rx-form-note .rx-icon { width: 14px; height: 14px; margin-top: 2px; }
.rx-form-actions { display: flex; gap: 8px; }
.rx-btn {
  flex: 1; height: 42px; border: 0; border-radius: 10px; cursor: pointer;
  background: var(--rx-accent); color: var(--rx-accent-ink);
  font-family: var(--rx-font-head); font-weight: 700; font-size: 14.5px;
}
.rx-btn:disabled { opacity: .7; cursor: progress; }
.rx-btn-ghost {
  height: 42px; padding: 0 14px; border: 1.5px solid var(--rx-line); border-radius: 10px; background: var(--rx-white);
  color: var(--rx-ink); font-weight: 600; font-size: 14px; cursor: pointer;
}

.rx-confirm-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.rx-confirm-icon {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: #DCFCE7; color: #166534;
}
.rx-confirm-icon .rx-icon { width: 20px; height: 20px; stroke-width: 2.4; }
.rx-ref { font-size: 13px; color: var(--rx-muted); }
.rx-summary { margin: 0 0 10px; border-top: 1px solid var(--rx-line); }
.rx-summary div { display: grid; grid-template-columns: 76px 1fr; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--rx-line); font-size: 13.5px; }
.rx-summary dt { color: var(--rx-muted); }
.rx-summary dd { margin: 0; overflow-wrap: anywhere; }
.rx-confirm .rx-form-note { margin-bottom: 0 !important; }

/* ---------- Bottom area ---------- */
.rx-bottom { border-top: 1px solid var(--rx-line); padding: 10px 12px 8px; background: var(--rx-white); }
.rx-cta {
  display: inline-flex; align-items: center; gap: 7px; margin: 0 0 8px 2px; padding: 5px 10px;
  border: 1.5px solid var(--rx-line); border-radius: 999px; background: var(--rx-white);
  font-size: 13px; font-weight: 600; color: var(--rx-ink); cursor: pointer;
}
.rx-cta:hover { border-color: var(--rx-accent); }
.rx-cta .rx-icon { width: 15px; height: 15px; }
.rx-composer { display: flex; gap: 8px; }
.rx-input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; font: inherit; font-size: 16px; color: var(--rx-ink);
  border: 1.5px solid var(--rx-line); border-radius: 12px; background: var(--rx-surface);
}
.rx-input:focus { outline: none; border-color: var(--rx-accent); background: var(--rx-white); }
.rx-send {
  width: 46px; height: 46px; border: 0; border-radius: 12px; flex: none; cursor: pointer;
  background: var(--rx-accent); color: var(--rx-accent-ink); display: grid; place-items: center;
}
.rx-send .rx-icon { stroke-width: 2.3; }
.rx-powered { text-align: center; font-size: 11.5px; color: var(--rx-muted); margin-top: 8px !important; }
.rx-powered strong { font-family: var(--rx-font-head); font-weight: 700; color: var(--rx-ink); letter-spacing: .02em; }

/* ---------- Animations ---------- */
@keyframes rx-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rx-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes rx-dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) {
  .rx-root *, .rx-root *::before, .rx-root *::after { animation: none !important; transition: none !important; }
}

/* ---------- Mobile: full-screen chat ---------- */
@media (max-width: 520px) {
  .rx-root { right: 16px; bottom: 16px; }
  .rx-launcher-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rx-launcher { width: 56px; padding: 0; justify-content: center; }
  .rx-launcher::after { top: 10px; left: 34px; }
  .rx-teaser { display: none !important; }
  .rx-is-open .rx-launcher { display: none; }
  .rx-panel {
    position: fixed; inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0;
  }
  .rx-header { padding-top: max(14px, env(safe-area-inset-top)); }
  .rx-bottom { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}
html.rx-chat-open body { overflow: hidden; }
@media (min-width: 521px) { html.rx-chat-open body { overflow: auto; } }

/* ---------- Demo business notification (what the business would receive) ---------- */
.kn-stack {
  position: fixed; bottom: 24px; left: 24px; right: auto; top: auto; z-index: 2147483600;
  width: 340px; max-width: calc(100vw - 32px); margin: 0; padding: 0; border: 0; background: transparent; overflow: visible;
  display: flex; flex-direction: column-reverse; gap: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #FFFFFF;
}
.kn-stack:empty { display: none; }
.kn-stack[popover] { inset: auto; bottom: 24px; left: 24px; }
.kn-toast {
  background: #101827; border: 1px solid #263247; border-left: 3px solid #14B8A6; border-radius: 12px;
  padding: 14px 16px 12px; box-shadow: 0 24px 50px -20px rgba(16, 24, 39, .6);
  animation: kn-in .22s ease-out;
}
.kn-head { display: flex; align-items: center; gap: 8px; }
.kn-icon { width: 22px; height: 22px; border-radius: 6px; background: rgba(20, 184, 166, .16); display: grid; place-items: center; flex: none; }
.kn-icon svg, .kn-close svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kn-icon svg { color: #14B8A6; }
.kn-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(255, 255, 255, .3);
}
.kn-to { font-size: 12px; color: #B6C0CE; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kn-close {
  width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: #B6C0CE;
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.kn-close:hover { background: rgba(255, 255, 255, .08); color: #FFFFFF; }
.kn-close:focus-visible { outline: 2px solid #14B8A6; outline-offset: 1px; }
.kn-title { margin: 10px 0 0; font-family: "Manrope", system-ui, sans-serif; font-weight: 800; font-size: 16px; }
.kn-heading { margin: 2px 0 0; font-size: 14px; font-weight: 600; color: #E2E8F0; }
.kn-rows { margin: 8px 0 0; font-size: 13px; }
.kn-rows div { display: grid; grid-template-columns: 108px 1fr; gap: 8px; padding: 2px 0; }
.kn-rows dt { color: #B6C0CE; }
.kn-rows dd { margin: 0; color: #FFFFFF; overflow-wrap: anywhere; }
.kn-foot { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid #263247; font-size: 11.5px; line-height: 1.45; color: #B6C0CE; }
@keyframes kn-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .kn-toast { animation: none; } }
@media (max-width: 520px) {
  .kn-stack, .kn-stack[popover] { top: 12px; right: 12px; left: 12px; bottom: auto; width: auto; max-width: none; flex-direction: column; }
}
