/* Member chat widget. Own tokens so it matches public pages and the dashboard. */
.pf-chat [hidden] {
  display: none !important;
}

.pf-chat {
  --pf-chat-bg: #ffffff;
  --pf-chat-bg-2: #f4f7fb;
  --pf-chat-ink: #142033;
  --pf-chat-muted: #5c6b80;
  --pf-chat-line: #d7deea;
  --pf-chat-accent: #1d4ed8;
  --pf-chat-accent-ink: #ffffff;
  --pf-chat-mine: #1d4ed8;
  --pf-chat-mine-ink: #ffffff;
  --pf-chat-theirs: #eef3f9;
  --pf-chat-danger: #9f1239;
  --pf-chat-avatar-bg: #e8eef6;
  --pf-chat-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  font-family: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--pf-chat-ink);
  font-size: 15px;
  line-height: 1.45;
}

html[data-theme="dark"] .pf-chat {
  --pf-chat-bg: #112240;
  --pf-chat-bg-2: #0c1a33;
  --pf-chat-ink: #f4f7fb;
  --pf-chat-muted: #c5d0e0;
  --pf-chat-line: rgba(148, 163, 184, 0.35);
  --pf-chat-accent: #93c5fd;
  --pf-chat-accent-ink: #0b1b33;
  --pf-chat-mine: #2563eb;
  --pf-chat-mine-ink: #ffffff;
  --pf-chat-theirs: #1c3558;
  --pf-chat-danger: #fecdd3;
  --pf-chat-avatar-bg: #0c1a33;
  --pf-chat-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .pf-chat {
    --pf-chat-bg: #112240;
    --pf-chat-bg-2: #0c1a33;
    --pf-chat-ink: #f4f7fb;
    --pf-chat-muted: #c5d0e0;
    --pf-chat-line: rgba(148, 163, 184, 0.35);
    --pf-chat-accent: #93c5fd;
    --pf-chat-accent-ink: #0b1b33;
    --pf-chat-mine: #2563eb;
    --pf-chat-mine-ink: #ffffff;
    --pf-chat-theirs: #1c3558;
    --pf-chat-danger: #fecdd3;
    --pf-chat-avatar-bg: #0c1a33;
    --pf-chat-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
  }
}

.pf-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--pf-chat-banner-lift, 0px));
  z-index: 13000;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 999px;
  background: var(--pf-chat-accent);
  color: var(--pf-chat-accent-ink);
  box-shadow: var(--pf-chat-shadow);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pf-chat-launcher:focus-visible,
.pf-chat-panel :focus-visible {
  outline: 2px solid var(--pf-chat-accent);
  outline-offset: 2px;
}

.pf-chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #be123c;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 20px;
}

/* Phones and the installed app: sit above the 56px bottom nav, not under it. */
body.pf-v5-shell .pf-chat-launcher {
  bottom: calc(var(--pf-v5-nav-h, 56px) + env(safe-area-inset-bottom, 0px) + 16px + var(--pf-chat-banner-lift, 0px));
}

@media (min-width: 768px) {
  body.pf-v5-shell .pf-chat-launcher {
    bottom: calc(20px + var(--pf-chat-banner-lift, 0px));
  }
}

@media (display-mode: standalone) and (max-width: 799px) {
  body.pf-v5-shell .pf-chat-launcher {
    bottom: calc(var(--pf-v5-nav-h, 56px) + env(safe-area-inset-bottom, 0px) + 16px + var(--pf-chat-banner-lift, 0px));
  }
}

.pf-chat-panel {
  position: fixed;
  right: 20px;
  bottom: calc(88px + var(--pf-chat-banner-lift, 0px));
  z-index: 13000;
  display: none;
  flex-direction: column;
  width: min(400px, calc(100vw - 24px));
  height: min(600px, calc(100dvh - 120px));
  background: var(--pf-chat-bg);
  color: var(--pf-chat-ink);
  border: 1px solid var(--pf-chat-line);
  border-radius: 16px;
  box-shadow: var(--pf-chat-shadow);
  overflow: hidden;
}

.pf-chat-panel.is-open {
  display: flex;
}

.pf-chat-panel.is-gate {
  height: auto;
  max-height: calc(100dvh - 120px);
}

.pf-chat-panel.is-admin:not(.is-compact) {
  width: min(960px, calc(100vw - 24px));
  height: min(740px, calc(100dvh - 110px));
}

.pf-chat-panel.is-compact {
  width: min(400px, calc(100vw - 24px));
  height: min(600px, calc(100dvh - 120px));
}

.pf-chat--page .pf-chat-panel {
  position: relative;
  right: auto;
  bottom: auto;
  display: flex;
  width: 100%;
  height: min(820px, calc(100dvh - 180px));
  max-width: none;
}

.pf-chat-head,
.pf-chat-tabs,
.pf-chat-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-bg);
}

.pf-chat-head {
  position: relative;
}

.pf-chat-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  flex: 1 1 auto;
  min-width: 0;
  color: var(--pf-chat-ink);
}

.pf-chat-brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.pf-chat-mark {
  display: block;
  height: 30px;
  width: auto;
  flex: 0 0 auto;
}

.pf-chat-menu-pop {
  position: absolute;
  top: 48px;
  right: 12px;
  z-index: 4;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--pf-chat-line);
  border-radius: 12px;
  background: var(--pf-chat-bg);
  box-shadow: var(--pf-chat-shadow);
}

.pf-chat-delete,
.pf-chat-confirm-cancel,
.pf-chat-confirm-delete {
  min-height: 44px;
  border-radius: 10px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.pf-chat-delete {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--pf-chat-danger);
  text-align: left;
  padding: 0 10px;
}

.pf-chat-icon-btn,
.pf-chat-send,
.pf-chat-tab,
.pf-chat-chip,
.pf-chat-gate a,
.pf-chat-back {
  min-height: 44px;
  min-width: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.pf-chat-icon-btn {
  font-size: 22px;
  line-height: 1;
}

.pf-chat-tabs {
  margin: 10px 12px 0;
  padding: 3px;
  gap: 0;
  border: 1px solid var(--pf-chat-line);
  border-radius: 10px;
  background: var(--pf-chat-bg-2);
}

.pf-chat-tab {
  min-height: 40px;
  border-color: transparent;
  background: transparent;
  border-radius: 8px;
  font-size: 13px;
  padding: 0 8px;
}

.pf-chat-panel:not(.is-admin) .pf-chat-thread-bar {
  display: none;
}

.pf-chat-inbox-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 13px;
  font-weight: 650;
  color: var(--pf-chat-accent);
  text-decoration: underline;
  white-space: nowrap;
}

.pf-chat-tab,
.pf-chat-chip {
  border-color: var(--pf-chat-line);
  background: var(--pf-chat-bg-2);
  color: var(--pf-chat-ink);
  flex: 1 1 0;
}

.pf-chat-chip {
  flex: 0 0 auto;
  white-space: nowrap;
}

.pf-chat-tab[aria-selected="true"],
.pf-chat-chip[aria-pressed="true"] {
  background: var(--pf-chat-accent);
  color: var(--pf-chat-accent-ink);
  border-color: var(--pf-chat-accent);
}

.pf-chat-tab-count {
  margin-left: 6px;
  font-size: 12px;
}

.pf-chat-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.pf-chat-list,
.pf-chat-customer {
  display: none;
}

.pf-chat-panel.is-admin:not(.is-compact) .pf-chat-list {
  display: flex;
  flex-direction: column;
  width: 280px;
  min-width: 0;
  border-right: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-bg-2);
}

.pf-chat-panel.is-compact .pf-chat-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  border-right: 0;
  background: var(--pf-chat-bg);
}

.pf-chat-panel.is-compact:not(.is-thread) .pf-chat-thread,
.pf-chat-panel.is-compact .pf-chat-customer {
  display: none;
}

.pf-chat-panel.is-compact.is-thread .pf-chat-list {
  display: none;
}

.pf-chat-panel.is-compact.is-thread .pf-chat-thread {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.pf-chat-panel.is-admin:not(.is-compact) .pf-chat-customer {
  display: flex;
  flex-direction: column;
  width: 240px;
  min-width: 0;
  border-left: 1px solid var(--pf-chat-line);
  overflow: auto;
  padding: 12px;
  gap: 8px;
}

.pf-chat-filters {
  flex-wrap: wrap;
}

.pf-chat-filters input[type="search"] {
  flex: 1 1 140px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-bg);
  color: var(--pf-chat-ink);
  padding: 0 10px;
  font: inherit;
}

.pf-chat-thread-list {
  overflow: auto;
  flex: 1 1 auto;
}

.pf-chat-thread-btn {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--pf-chat-line);
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 12px;
  cursor: pointer;
  min-height: 44px;
}

.pf-chat-thread-btn.is-active {
  background: var(--pf-chat-bg);
}

.pf-chat-thread-btn strong {
  display: block;
  font-size: 14px;
}

.pf-chat-thread-btn span,
.pf-chat-muted,
.pf-chat-customer p {
  color: var(--pf-chat-muted);
  font-size: 13px;
}

.pf-chat-thread-btn > span {
  display: block;
}

.pf-chat-unread-dot {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: #be123c;
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.pf-chat-thread {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.pf-chat-thread-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--pf-chat-line);
}

.pf-chat-thread-bar p {
  margin: 0;
  flex: 1 1 auto;
  font-weight: 700;
}

.pf-chat-messages {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--pf-chat-bg);
}

.pf-chat-bubble {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pf-chat-bubble.is-mine {
  align-self: flex-end;
  background: var(--pf-chat-mine);
  color: var(--pf-chat-mine-ink);
}

.pf-chat-bubble.is-theirs {
  align-self: flex-start;
  background: var(--pf-chat-theirs);
}

.pf-chat-bubble time,
.pf-chat-card time {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--pf-chat-muted);
}

.pf-chat-bubble.is-mine time {
  color: #ffffff;
}

.pf-chat-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}

.pf-chat-row.is-mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.pf-chat-row.is-theirs {
  align-self: flex-start;
}

.pf-chat-row .pf-chat-bubble {
  align-self: auto;
}

.pf-chat-avatar {
  box-sizing: border-box;
  width: 32px;
  height: 32px;
  padding: 3px;
  border-radius: 50%;
  border: 1px solid var(--pf-chat-line);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--pf-chat-avatar-bg);
}

.pf-chat-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.pf-chat-stack {
  min-width: 0;
}

.pf-chat-sender {
  margin: 0 0 3px 2px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  color: var(--pf-chat-muted);
}

.pf-chat-welcome {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
}

.pf-chat-welcome .pf-chat-stack > p:last-child {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--pf-chat-theirs);
  color: var(--pf-chat-ink);
}

.pf-chat-copy {
  display: inline;
  min-height: 32px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--pf-chat-accent);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.pf-chat-email-line,
.pf-chat-deleted-label,
.pf-chat-thread-email {
  display: block;
  margin: 0;
}

.pf-chat-deleted-label {
  color: var(--pf-chat-danger);
  font-size: 12px;
  font-weight: 700;
}

.pf-chat-thread-heading {
  flex: 1 1 auto;
  min-width: 0;
}

.pf-chat-confirm {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 18, 34, 0.55);
}

.pf-chat-confirm-card {
  width: min(360px, 100%);
  padding: 16px;
  border-radius: 14px;
  background: var(--pf-chat-bg);
  color: var(--pf-chat-ink);
  border: 1px solid var(--pf-chat-line);
}

.pf-chat-confirm-card p {
  margin: 0 0 14px;
}

.pf-chat-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.pf-chat-confirm-cancel {
  border: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-bg);
  color: var(--pf-chat-ink);
  padding: 0 14px;
}

.pf-chat-confirm-delete {
  border: 0;
  background: #9f1239;
  color: #ffffff;
  padding: 0 14px;
}

.pf-chat-composer textarea::placeholder {
  color: var(--pf-chat-muted);
  opacity: 1;
}

.pf-chat-system {
  align-self: center;
  color: var(--pf-chat-muted);
  font-size: 13px;
  text-align: center;
}

.pf-chat-card {
  align-self: stretch;
  border: 1px solid var(--pf-chat-line);
  border-radius: 14px;
  padding: 12px;
  background: var(--pf-chat-bg-2);
}

.pf-chat-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.pf-chat-card p {
  margin: 0 0 4px;
}

.pf-chat-notice,
.pf-chat-error,
.pf-chat-closed {
  margin: 8px 12px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--pf-chat-bg-2);
  color: var(--pf-chat-ink);
  font-size: 14px;
}

.pf-chat-error {
  color: var(--pf-chat-danger);
}

.pf-chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-bg);
}

.pf-chat-composer textarea {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 44px;
  max-height: calc(1.4em * 4 + 22px);
  line-height: 1.4;
  resize: none;
  overflow-y: hidden;
  border-radius: 10px;
  border: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-bg);
  color: var(--pf-chat-ink);
  padding: 10px;
  font: inherit;
}

.pf-chat-send {
  background: var(--pf-chat-accent);
  color: var(--pf-chat-accent-ink);
}

.pf-chat-send:disabled {
  background: var(--pf-chat-bg-2);
  color: var(--pf-chat-muted);
  border-color: var(--pf-chat-line);
  opacity: 1;
  cursor: default;
}

.pf-chat-gate {
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pf-chat-gate h3 {
  margin: 0;
  font-size: 20px;
}

.pf-chat-gate p {
  margin: 0;
  color: var(--pf-chat-muted);
}

.pf-chat-gate a {
  background: var(--pf-chat-accent);
  color: var(--pf-chat-accent-ink);
}

.pf-chat-gate a.pf-chat-mail {
  display: inline;
  min-height: 0;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--pf-chat-accent);
  font-weight: 650;
  text-decoration: underline;
}

.pf-chat-gate a.pf-chat-gate-secondary {
  background: transparent;
  color: var(--pf-chat-ink);
  border-color: var(--pf-chat-line);
}

.pf-chat-customer h3 {
  margin: 0;
  font-size: 15px;
}

.pf-chat-customer a {
  color: inherit;
}

.pf-chat-request {
  margin: 0;
  padding: 0;
  list-style: none;
}

.pf-chat-request li {
  margin: 0 0 8px;
  font-size: 13px;
}

.pf-chat-empty {
  margin: auto;
  color: var(--pf-chat-muted);
  text-align: center;
  padding: 16px;
}

@media (max-width: 799px) {
  .pf-chat-panel.is-open:not(.is-gate) {
    inset: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .pf-chat-panel.is-open.is-gate {
    left: 12px;
    right: 12px;
    width: auto;
    height: auto;
    bottom: calc(88px + var(--pf-chat-banner-lift, 0px));
  }

  .pf-chat--page .pf-chat-panel {
    position: relative;
    inset: auto;
    width: 100%;
    border-radius: 16px;
  }

  .pf-chat--page .pf-chat-panel {
    height: calc(100dvh - 150px);
  }

  .pf-chat-panel.is-admin:not(.is-compact) .pf-chat-list,
  .pf-chat-panel.is-admin:not(.is-compact) .pf-chat-customer,
  .pf-chat-panel.is-admin:not(.is-compact) .pf-chat-thread {
    width: 100%;
  }

  .pf-chat-panel.is-admin:not(.is-compact):not(.is-thread) .pf-chat-thread,
  .pf-chat-panel.is-admin:not(.is-compact):not(.is-thread) .pf-chat-customer {
    display: none;
  }

  .pf-chat-panel.is-admin:not(.is-compact).is-thread .pf-chat-body {
    flex-direction: column;
  }

  .pf-chat-panel.is-admin:not(.is-compact).is-thread .pf-chat-list {
    display: none;
  }

  .pf-chat-panel.is-admin:not(.is-compact).is-thread .pf-chat-thread {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
  }

  .pf-chat-panel.is-admin:not(.is-compact).is-thread .pf-chat-customer {
    display: flex;
    width: 100%;
    border-left: 0;
    border-top: 1px solid var(--pf-chat-line);
    max-height: 180px;
  }
}
