/* Live chat widget.
 *
 * Self-contained and namespaced under .pfxchat so it can drop onto DFDC,
 * Netrouting and LSIX without colliding with their stylesheets. The single
 * brand hook is --pfxchat-accent, set from config by the JS.
 */

.pfxchat {
  --pfxchat-accent: #96DB45;
  --pfxchat-tick: #2E99FF;
  --pfxchat-bg: #0c0f15;
  --pfxchat-surface: #11141c;
  --pfxchat-border: rgba(170, 180, 195, 0.16);
  --pfxchat-text: #e8ecf3;
  --pfxchat-muted: #8b94a5;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000; /* above cookie banners, below nothing */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Arial, sans-serif;
}

/* ── launcher ─────────────────────────────────────────── */
.pfxchat-launcher {
  position: relative;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: #E8ECF3;
  color: #0a0d13;              /* the mark's bubble stroke inherits this */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
.pfxchat-launcher-icon { display: flex; }
.pfxchat-mark { display: block; overflow: visible; }

/* Header mark sits on the dark panel, so its bubble stroke is chrome. */
.pfxchat-avatar { display: flex; color: #E8ECF3; margin-right: 2px; }

/* The nodes double as a typing indicator. Idle they sit still; while an agent
   reply is in flight they pulse in sequence — the logo's own motif doing the
   job of three bouncing dots. */
@keyframes pfxchat-pulse {
  0%, 70%, 100% { opacity: 1; transform: translateY(0); }
  35%           { opacity: .45; transform: translateY(-2.5px); }
}
.pfxchat-typing .pfxchat-dot { animation: pfxchat-pulse 1.25s ease-in-out infinite; transform-origin: center; }
.pfxchat-typing .pfxchat-dot-2 { animation-delay: .18s; }
.pfxchat-typing .pfxchat-dot-3 { animation-delay: .36s; }
.pfxchat-launcher:hover { transform: scale(1.06); }
.pfxchat-launcher:focus-visible { outline: 3px solid var(--pfxchat-accent); outline-offset: 3px; }

.pfxchat-badge {
  position: absolute;
  top: -2px; right: -2px;
  min-width: 20px; height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #e0483d;
  color: #fff;
  font-size: 11px; font-weight: 700;
  line-height: 20px;
}

/* ── panel ────────────────────────────────────────────── */
.pfxchat-panel {
  position: absolute;
  right: 0; bottom: 70px;
  width: 360px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--pfxchat-bg);
  border: 1px solid var(--pfxchat-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

/* An author `display` beats the UA stylesheet's `[hidden] { display: none }`,
   so `panel.hidden = true` alone left the panel on screen — close and the
   launcher toggle both looked dead. Any element that sets display AND is
   toggled via .hidden needs this. */
.pfxchat-panel[hidden] { display: none; }

.pfxchat-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  background: var(--pfxchat-surface);
  border-bottom: 1px solid var(--pfxchat-border);
  color: var(--pfxchat-text);
  border-top: 2px solid var(--pfxchat-accent);
}
.pfxchat-sub { font-size: 12px; color: var(--pfxchat-muted); margin-top: 2px; }
.pfxchat-close {
  border: 0; background: none; color: var(--pfxchat-muted);
  font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.pfxchat-close:hover { color: var(--pfxchat-text); }

.pfxchat-log {
  flex: 1 1 auto;
  min-height: 200px;
  overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* ── messages ─────────────────────────────────────────── */
.pfxchat-msg { display: flex; flex-direction: column; max-width: 85%; }
.pfxchat-visitor { align-self: flex-end; align-items: flex-end; }
.pfxchat-agent, .pfxchat-system { align-self: flex-start; }

.pfxchat-bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.pfxchat-visitor .pfxchat-bubble {
  background: var(--pfxchat-accent);
  color: #0a0d13;
  border-bottom-right-radius: 3px;
}
.pfxchat-agent .pfxchat-bubble {
  background: var(--pfxchat-surface);
  color: var(--pfxchat-text);
  border: 1px solid var(--pfxchat-border);
  border-bottom-left-radius: 3px;
}
.pfxchat-system .pfxchat-bubble {
  background: transparent;
  color: var(--pfxchat-muted);
  border: 1px dashed var(--pfxchat-border);
  font-size: 13px;
}
.pfxchat-who {
  font-size: 11px; color: var(--pfxchat-muted);
  margin: 0 0 3px 3px; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ── composer ─────────────────────────────────────────── */
.pfxchat-form {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px; border-top: 1px solid var(--pfxchat-border);
  background: var(--pfxchat-surface);
}
.pfxchat-input {
  flex: 1 1 auto;
  resize: none;
  border: 1px solid var(--pfxchat-border);
  border-radius: 8px;
  background: var(--pfxchat-bg);
  color: var(--pfxchat-text);
  padding: 9px 11px;
  font: inherit; font-size: 14px; line-height: 1.4;
  max-height: 120px;
}
.pfxchat-input:focus { outline: none; border-color: var(--pfxchat-accent); }
.pfxchat-input::placeholder { color: var(--pfxchat-muted); }

.pfxchat-send {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  border: 0; border-radius: 8px;
  background: var(--pfxchat-accent);
  color: #0a0d13;
  font-size: 17px; font-weight: 700;
  cursor: pointer;
}
.pfxchat-send:hover { filter: brightness(1.08); }

/* ── responsive: full-screen sheet on phones ──────────── */
@media (max-width: 480px) {
  .pfxchat { right: 14px; bottom: 14px; }
  .pfxchat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  .pfxchat-launcher { transition: none; }
  .pfxchat-launcher:hover { transform: none; }
  /* The pulsing nodes are decorative — the unread badge still conveys the
     same state, so removing the motion loses no information. */
  .pfxchat-typing .pfxchat-dot { animation: none; }
}
