/* Conversational chat-funnel widget.
 * Ported from the standalone PHP funnel's chat.css. Every selector is scoped
 * under #cf-root and uses cf- prefixed classes so it can't bleed into the rest
 * of the site (no global html/body rules — this is a docked widget). */

#cf-root {
  --cf-brand: #1f6feb;
  --cf-brand-dark: #1858c4;
  --cf-bot-bg: #f1f3f5;
  --cf-bot-text: #1d2127;
  --cf-user-bg: #1f6feb;
  --cf-user-text: #ffffff;
  --cf-radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#cf-root *,
#cf-root *::before,
#cf-root *::after { box-sizing: border-box; }

/* ---- Floating launcher bubble ---- */
#cf-root .cf-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: var(--cf-brand);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 20px rgba(31, 111, 235, 0.45);
  z-index: 2147483000;
  transition: transform 0.15s, background 0.15s;
}
#cf-root .cf-launcher:hover { transform: scale(1.06); background: var(--cf-brand-dark); }
#cf-root .cf-launcher .cf-launcher-close { display: none; }
/* When the widget is open, the launcher becomes an X */
#cf-root.cf-open .cf-launcher .cf-launcher-open { display: none; }
#cf-root.cf-open .cf-launcher .cf-launcher-close { display: block; }
/* Gentle attention pulse until first opened */
#cf-root .cf-launcher.cf-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(31, 111, 235, 0.5);
  animation: cf-pulse 2s infinite;
}
@keyframes cf-pulse {
  70%  { box-shadow: 0 0 0 14px rgba(31, 111, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(31, 111, 235, 0); }
}

/* ---- Teaser popup ---- */
#cf-root .cf-teaser {
  position: fixed;
  right: 20px;
  bottom: 92px;
  /* Size to the message so it stays on one line, but never wider than the
     viewport (small phones fall back to wrapping via the media query below). */
  width: max-content;
  max-width: calc(100vw - 40px);
  background: #fff;
  border-radius: 16px;
  padding: 16px 16px 14px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.20);
  z-index: 2147482999;
  animation: cf-pop 0.2s ease-out;
}
#cf-root .cf-teaser[hidden] { display: none; }
#cf-root .cf-teaser-badge {
  position: absolute;
  top: -8px; left: -8px;
  min-width: 22px; height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #e8413c;
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
#cf-root .cf-teaser-text {
  font-size: 15px;
  line-height: 1.4;
  color: var(--cf-bot-text);
  margin-bottom: 12px;
  white-space: nowrap;   /* keep the question on a single line */
  padding-right: 14px;   /* clear the close (×) button */
}
/* On narrow phones let it wrap again so it can't overflow the screen. */
@media (max-width: 380px) {
  #cf-root .cf-teaser-text { white-space: normal; padding-right: 0; }
}
#cf-root .cf-teaser-close {
  position: absolute;
  top: 8px; right: 10px;
  border: none; background: none;
  font-size: 18px; line-height: 1;
  color: #9aa3ad; cursor: pointer;
}
#cf-root .cf-teaser-actions { display: flex; gap: 8px; }
/* No quick-reply buttons: drop the empty actions row and the gap above it so
   the teaser is a tidy single-line nudge. */
#cf-root .cf-teaser-actions:empty { display: none; }
#cf-root .cf-teaser:has(.cf-teaser-actions:empty) .cf-teaser-text { margin-bottom: 0; }
#cf-root .cf-teaser-btn {
  flex: 1 1 0;
  appearance: none;
  border: 1.5px solid var(--cf-brand);
  background: #fff;
  color: var(--cf-brand);
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
#cf-root .cf-teaser-btn:hover { background: var(--cf-brand); color: #fff; }

/* ---- Chat widget shell — docked bottom-right, hidden until opened ---- */
#cf-root .cf-app {
  position: fixed;
  right: 20px;
  bottom: 92px;
  display: flex;
  flex-direction: column;
  width: 380px;
  height: min(620px, calc(100dvh - 112px));
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
  z-index: 2147483001;
  transform-origin: bottom right;
  animation: cf-slideUp 0.22s ease-out;
}
#cf-root .cf-app[hidden] { display: none; }
@keyframes cf-slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* On phones, the open chat takes the full screen */
@media (max-width: 480px) {
  #cf-root .cf-app {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; height: 100dvh;
    border-radius: 0;
  }
}

/* Header */
#cf-root .cf-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--cf-brand);
  color: #fff;
  flex: 0 0 auto;
}
#cf-root .cf-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
#cf-root .cf-header-text { display: flex; flex-direction: column; line-height: 1.3; flex: 1 1 auto; }
#cf-root .cf-min {
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 50%;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
#cf-root .cf-min:hover { background: rgba(255, 255, 255, 0.3); }
#cf-root .cf-title { font-weight: 600; font-size: 15px; }
#cf-root .cf-status { font-size: 12px; opacity: 0.9; display: flex; align-items: center; gap: 5px; }
#cf-root .cf-status .cf-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80; display: inline-block;
}

/* Message area */
#cf-root .cf-window {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* Message bubbles */
#cf-root .cf-msg {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: var(--cf-radius);
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  animation: cf-pop 0.18s ease-out;
}
@keyframes cf-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#cf-root .cf-msg.cf-bot {
  align-self: flex-start;
  background: var(--cf-bot-bg);
  color: var(--cf-bot-text);
  border-bottom-left-radius: 5px;
}
#cf-root .cf-msg.cf-user {
  align-self: flex-end;
  background: var(--cf-user-bg);
  color: var(--cf-user-text);
  border-bottom-right-radius: 5px;
}

/* Typing indicator */
#cf-root .cf-typing {
  align-self: flex-start;
  background: var(--cf-bot-bg);
  border-radius: var(--cf-radius);
  border-bottom-left-radius: 5px;
  padding: 12px 16px;
  display: inline-flex;
  gap: 4px;
}
#cf-root .cf-typing span {
  width: 7px; height: 7px;
  background: #9aa3ad;
  border-radius: 50%;
  animation: cf-blink 1.2s infinite ease-in-out both;
}
#cf-root .cf-typing span:nth-child(2) { animation-delay: 0.2s; }
#cf-root .cf-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cf-blink {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* Input bar */
#cf-root .cf-input-bar {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid #e6e9ee;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Button choices */
#cf-root .cf-choices { display: flex; flex-direction: column; gap: 8px; }
#cf-root .cf-choice-btn {
  appearance: none;
  border: 1.5px solid var(--cf-brand);
  background: #fff;
  color: var(--cf-brand);
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.05s, box-shadow 0.15s;
}
#cf-root .cf-choice-btn:hover { background: var(--cf-brand); color: #fff; box-shadow: 0 4px 12px rgba(31, 111, 235, 0.28); }
#cf-root .cf-choice-btn:active { transform: scale(0.98); }
#cf-root .cf-choice-btn:disabled { opacity: 0.45; cursor: default; background: #fff; color: var(--cf-brand); }

/* Text input row */
#cf-root .cf-text-row { display: flex; gap: 8px; }
#cf-root .cf-text-row input {
  flex: 1 1 auto;
  padding: 12px 14px;
  border: 1.5px solid #d4d9e0;
  border-radius: 12px;
  font-size: 16px; /* 16px avoids iOS zoom-on-focus */
  outline: none;
}
#cf-root .cf-text-row input:focus { border-color: var(--cf-brand); }
#cf-root .cf-text-row button {
  flex: 0 0 auto;
  border: none;
  background: var(--cf-brand);
  color: #fff;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
}
#cf-root .cf-text-row button:hover { background: var(--cf-brand-dark); }
#cf-root .cf-text-row button:disabled { opacity: 0.5; cursor: default; }

#cf-root .cf-field-error { color: #d23b3b; font-size: 13px; padding-left: 4px; }

/* TCPA / SMS consent opt-in */
#cf-root .cf-consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f7f9fc;
  border: 1px solid #e2e8f2;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
#cf-root .cf-consent-check {
  margin-top: 2px;
  width: 18px; height: 18px;
  flex: 0 0 auto;
  accent-color: var(--cf-brand);
  cursor: pointer;
}
#cf-root .cf-consent-text { font-size: 11.5px; line-height: 1.45; color: #51606e; }

/* Final call-to-action link, styled like a primary button */
#cf-root .cf-cta-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--cf-brand);
  color: #fff;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
}
#cf-root .cf-cta-btn:hover { background: var(--cf-brand-dark); }

/* "Captured lead" card shown in print-only mode (no save endpoint) */
#cf-root .cf-summary {
  align-self: stretch;
  background: #fbfdff;
  border: 1px solid #d7e3f3;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  animation: cf-pop 0.18s ease-out;
}
#cf-root .cf-summary-title {
  font-weight: 700;
  color: var(--cf-brand);
  margin-bottom: 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#cf-root .cf-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid #eef2f7;
}
#cf-root .cf-summary-row:last-child { border-bottom: none; }
#cf-root .cf-summary-key { color: #6b7480; }
#cf-root .cf-summary-val { color: #1d2127; font-weight: 600; text-align: right; word-break: break-word; }
