/* ============================================================
   ComplyChat hero chat widget (.ccw) - a faithful visual replica
   of the real PWA chat screen (comply.chat.org.uk), driven by
   /chat-widget.js. Colours, metrics and markup mirror the app:
   red #b3261e chrome, cream doodle wallpaper, white/pink bubbles
   with CSS border tails, grey/blue ticks, pill composer + red FAB.
   Namespaced ccw- so it never collides with site.css chat skins.
   ============================================================ */

.ccw, .ccw * { box-sizing: border-box; }

.ccw {
  /* The app uses the system stack, not the marketing serif - key to the mimic */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
  width: 100%;
  max-width: 380px;
  height: 560px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  background: #f4f2f5;
  border: 1px solid var(--hairline-strong);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 60px -28px rgba(10, 37, 64, 0.45), 0 4px 14px -6px rgba(10, 37, 64, 0.18);
}

.ccw-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rust-deep);
  text-align: right;
  margin: 0 6px 10px 0;
}

/* ---------- header (PWA .topbar) ---------- */
.ccw-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 14px;
  background: #b3261e;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 2;
}
.ccw-avatar {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #8c1d17;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ccw-presence {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}
.ccw-head { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ccw-title {
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ccw-subrow { display: flex; align-items: baseline; gap: 10px; }
.ccw-sub { font-size: 0.74rem; opacity: 0.85; }
.ccw-sub--typing { font-style: italic; opacity: 1; }
.ccw-rec {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  opacity: 0.85;
  white-space: nowrap;
}
.ccw-recdot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
  animation: ccwRecPulse 2s ease-in-out infinite;
}
@keyframes ccwRecPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ---------- wallpaper + message list ---------- */
.ccw-wall {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #efeae1;
}
.ccw-wall::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/wallpaper-chat.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: top center;
}
.ccw-list {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: #e3e1e6 transparent;
}
/* flex spacer pins a short conversation to the bottom, like the app */
.ccw-list::before { content: ""; flex: 1 1 auto; }
/* the list is keyboard-scrollable (tabindex=0) - give it a visible focus cue */
.ccw-list:focus-visible { outline: 2px solid var(--rust); outline-offset: -2px; }

/* ---------- bubbles (PWA .msg) ---------- */
.ccw-msg {
  position: relative;
  max-width: 80%;
  margin-top: 12px;
  padding: 7px 7px 6px 9px;
  border-radius: 13px;
  font-size: 0.9375rem;
  line-height: 1.2667;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
  overflow-wrap: anywhere;
  color: #1c1b1f;
  animation: ccwReveal 0.3s ease both;
}
@keyframes ccwReveal {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.ccw-msg--grouped { margin-top: 2px; }
.ccw-msg--in {
  align-self: flex-start;
  background: #ffffff;
  border-top-left-radius: 2px;
}
.ccw-msg--out {
  align-self: flex-end;
  background: #fde7e5;
  border-top-right-radius: 2px;
}
/* tail: 7px border triangle hanging outside the top corner */
.ccw-msg--in::before,
.ccw-msg--out::before {
  content: "";
  position: absolute;
  top: 0;
  width: 0;
  height: 0;
  border: 7px solid transparent;
}
.ccw-msg--in::before {
  left: -7px;
  border-top-color: #ffffff;
  border-right-color: #ffffff;
}
.ccw-msg--out::before {
  right: -7px;
  border-top-color: #fde7e5;
  border-left-color: #fde7e5;
}
.ccw-msg--grouped::before { display: none; }
.ccw-msg--grouped.ccw-msg--in { border-top-left-radius: 13px; }
.ccw-msg--grouped.ccw-msg--out { border-top-right-radius: 13px; }

.ccw-sender {
  font-size: 0.76rem;
  font-weight: 700;
  margin-bottom: 1px;
  color: #b3261e;
}
.ccw-text { white-space: pre-wrap; }
.ccw-spacer { display: inline-block; height: 1px; }
.ccw-foot {
  position: absolute;
  right: 8px;
  bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  line-height: 1;
  color: #5b5960;
}
.ccw-ticks { display: inline-flex; line-height: 1; color: #8b9aa6; }
.ccw-ticks--read { color: #1f7fb8; }

/* ---------- date chip / system pill ---------- */
.ccw-chip {
  align-self: center;
  margin-top: 12px;
  max-width: 88%;
  padding: 5px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  font-size: 0.74rem;
  line-height: 1.35;
  color: #5b5960;
  text-align: center;
  animation: ccwReveal 0.3s ease both;
}
.ccw-chip--system {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-align: left;
}
.ccw-chip--system .ccw-recdot {
  flex: 0 0 auto;
  background: #b3261e;
  box-shadow: 0 0 0 3px rgba(179, 38, 30, 0.18);
}

/* ---------- typing indicator (PWA .typing-bubble) ---------- */
.ccw-typing {
  align-self: flex-start;
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 13px;
  border-top-left-radius: 2px;
  background: #fff;
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.1);
  display: inline-flex;
  gap: 4px;
  position: relative;
  animation: ccwReveal 0.2s ease both;
}
.ccw-typing::before {
  content: "";
  position: absolute;
  top: 0;
  left: -7px;
  border: 7px solid transparent;
  border-top-color: #fff;
  border-right-color: #fff;
}
.ccw-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5b5960;
  opacity: 0.35;
  animation: ccwBlink 1.2s infinite;
}
.ccw-dot:nth-child(2) { animation-delay: 0.18s; }
.ccw-dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes ccwBlink {
  0%, 60%, 100% { opacity: 0.35; transform: none; }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- suggested question chips ---------- */
.ccw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px 0;
  background: #f4f2f5;
}
.ccw-chips[hidden] { display: none; }
.ccw-qchip {
  font-family: inherit;
  font-size: 0.8rem;
  color: #b3261e;
  background: #fff;
  border: 1px solid #e3d3d1;
  border-radius: 100px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.ccw-qchip:hover { background: #fde7e5; border-color: #b3261e; }
.ccw-qchip:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

/* ---------- composer (PWA .composer) ---------- */
.ccw-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f4f2f5;
  border-top: 1px solid #e3e1e6;
}
.ccw-pill {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: #fff;
  border: 1px solid #e3e1e6;
  border-radius: 22px;
  padding: 8px 12px;
  color: #5b5960;
}
.ccw-pill svg { flex: 0 0 auto; }
.ccw-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-size: 16px; /* 16px floor stops iOS Safari auto-zoom */
  color: #1c1b1f;
}
/* focus shows on the pill, like the app - not as a ring on the bare input */
.ccw-input:focus-visible { outline: none; }
.ccw-pill:focus-within { border-color: #b3261e; box-shadow: 0 0 0 1px #b3261e; }
.ccw-input::placeholder { color: #6b6875; } /* 4.5:1 on white - AA */
.ccw-input:disabled { opacity: 0.6; }
.ccw-send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: #b3261e;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease;
}
.ccw-send:hover { background: #8c1d17; }
.ccw-send:disabled { opacity: 0.35; cursor: default; }
.ccw-send:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }

/* error bubble link */
.ccw-msg a { color: #b3261e; }

/* ---------- layout inside the hero ---------- */
@media (max-width: 900px) {
  .ccw { margin: 0 auto; max-width: 440px; }
  .ccw-eyebrow { text-align: center; margin-right: 0; }
}
@media (max-width: 560px) {
  .ccw { height: 520px; }
  .ccw-msg { max-width: 88%; }
}
