/* Unified Communications Inbox — Stage 1 (2026-09-07). Shared live-chat widget styles,
   loaded on both the public marketing site (custom CSS, no Tailwind — CLAUDE.md's own
   documented boundary) and the Tailwind-based client dashboard family. Plain CSS + inline
   styles are safe on top of Tailwind too (no conflict), so this ONE stylesheet — not a
   Tailwind-only version and a custom-CSS-only version — covers both without blurring that
   boundary: it never assumes Tailwind's reset/utilities are present, and never fights them
   when they are. Colors are this project's own locked navy/cream tokens, hardcoded here
   (not var(--primary) etc.) since the public site's own custom-CSS tokens and the dashboard
   family's Tailwind config are two separate systems with no shared CSS variable between
   them. */

#chat-widget-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#chat-widget-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-navy-ground);
  color: var(--brand-cream);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(var(--brand-navy-ground-rgb),0.35);
  transition: transform 0.15s ease;
}
#chat-widget-bubble:hover {
  transform: scale(1.06);
}
#chat-widget-bubble svg {
  width: 26px;
  height: 26px;
}

#chat-widget-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--brand-gold-ground);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

#chat-widget-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 120px);
  background: #FFFFFF;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(var(--brand-navy-ground-rgb),0.28);
  border: 1px solid var(--brand-cream-dark);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#chat-widget-panel.is-open {
  display: flex;
}

#chat-widget-header {
  background: var(--brand-navy-ground);
  color: var(--brand-cream);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#chat-widget-header .title {
  font-size: 14px;
  font-weight: 700;
  margin: 0;
}
#chat-widget-header .status {
  font-size: 11.5px;
  color: rgba(var(--brand-cream-rgb),0.65);
  margin: 2px 0 0;
}
#chat-widget-close {
  background: none;
  border: none;
  color: rgba(var(--brand-cream-rgb),0.8);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
#chat-widget-close:hover { color: var(--brand-cream); }

/* Mobile fixes, Batch 2 (2026-09-08), Finding S5: this dismiss control measured 22x24 — the
   second-smallest close button in the audit. Lives here rather than in tap-targets.css
   because the chat widget mounts on BOTH page families (the 8 public marketing pages, which
   load styles.css, and the 10 client dashboard pages, which load tap-targets.css), so this
   is the only file guaranteed to be present everywhere the control itself is. Scoped to the
   dashboard family's own `lg` breakpoint, matching tap-targets.css, so desktop is unchanged.
   The glyph stays 20px; only the tappable box grows, and the negative margin lets it expand
   into the header's own padding instead of displacing the title beside it. */
@media (max-width: 1023.98px) {
  #chat-widget-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    margin: -8px -8px -8px 0;
  }
}

#chat-widget-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #FCFBF9;
}

.chat-widget-msg-row {
  display: flex;
}
.chat-widget-msg-row.is-outbound {
  justify-content: flex-start;
}
.chat-widget-msg-row.is-inbound {
  justify-content: flex-end;
}
.chat-widget-msg-bubble {
  max-width: 80%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
}
.chat-widget-msg-row.is-inbound .chat-widget-msg-bubble {
  background: var(--brand-navy-ground);
  color: var(--brand-cream);
  border-bottom-right-radius: 4px;
}
.chat-widget-msg-row.is-outbound .chat-widget-msg-bubble {
  background: var(--brand-cream-dark);
  color: var(--brand-text);
  border-bottom-left-radius: 4px;
}
.chat-widget-system-msg {
  text-align: center;
  font-size: 11.5px;
  color: var(--brand-muted);
  font-style: italic;
  margin: 4px 0;
}

#chat-widget-precontact {
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#chat-widget-precontact p {
  font-size: 13px;
  color: var(--brand-muted);
  margin: 0 0 4px;
}
#chat-widget-precontact input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1.5px solid #DCD4C9;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}
#chat-widget-precontact input:focus {
  outline: none;
  border-color: var(--brand-navy-ground);
}
#chat-widget-precontact-error {
  display: none;
  font-size: 12px;
  color: #A22238;
}
#chat-widget-precontact-error.is-visible { display: block; }
#chat-widget-start-btn {
  background: var(--brand-navy-ground);
  color: var(--brand-cream);
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
#chat-widget-start-btn:disabled { opacity: 0.6; cursor: not-allowed; }
/* MOBILE POLISH P1 (lane 2, 2026-11-07): the pre-chat fields (40px) and Start Chat (39px) reach the 44px tap minimum. */
#chat-widget-precontact input, #chat-widget-start-btn { min-height: 44px; }

#chat-widget-footer {
  border-top: 1px solid var(--brand-cream-dark);
  padding: 10px;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
#chat-widget-input {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid #DCD4C9;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}
#chat-widget-input:focus {
  outline: none;
  border-color: var(--brand-navy-ground);
}
#chat-widget-send {
  background: var(--brand-navy-ground);
  color: var(--brand-cream);
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
#chat-widget-send:disabled { opacity: 0.6; cursor: not-allowed; }

@media (max-width: 420px) {
  #chat-widget-panel {
    width: calc(100vw - 32px);
    right: -8px;
  }
}

/* Visually-hidden but present in the accessibility tree. The three chat inputs were named
   only by their placeholder, which disappears the moment the user types — so the control
   became unnamed exactly when its value most needed explaining. Real <label> elements
   rather than aria-label: a label survives a refactor that a string attribute does not.
   NOT display:none or visibility:hidden, either of which removes the label from the tree
   entirely and would defeat the whole point. */
.cw-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Proactive chat (2026-09-13): the PM's message shown above the pre-chat form. */
#chat-widget-precontact #chat-widget-invitation { margin: 0 0 12px; }

/* A chat that cannot start (errors_v1, 2026-10-22): the shared error card, then the support address. */
#chat-widget-body .cw-err { margin: auto 0; padding: 4px 2px; }
#chat-widget-body .cw-alt { margin-top: 12px; font-size: 13px; line-height: 1.5; text-align: center; color: var(--brand-muted); }
#chat-widget-body .cw-alt b { font-weight: 600; color: var(--brand-plum-deepest); }
/* the fallback card when the shared data layer is not on the page (the public site never reaches this path) */
#chat-widget-body .cw-card { border: 1px solid rgba(var(--brand-terracotta-rgb), .3); background: var(--brand-terracotta-wash); border-radius: 12px; padding: 14px 16px; font-size: 14px; color: var(--brand-plum-deepest); }
#chat-widget-body .cw-card p:first-child { font-weight: 600; }
#chat-widget-body .cw-card p + p { margin: 4px 0 10px; }
#chat-widget-body .cw-retry { min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--brand-plum-deepest); color: var(--brand-cream); font: inherit; font-weight: 600; cursor: pointer; }

/* SAFE AREA (lane 2, 7 Nov): the chat button sits above the home indicator and clear of a side notch (the installed app sets
   its own bottom above the tab bar in app-look.css). */
#chat-widget-root { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); right: calc(24px + env(safe-area-inset-right, 0px)); }
