/**
 * Presbot embedded chat iframe styles.
 * All rules are scoped under .pb-embed-root to avoid leaking into host pages.
 */

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

html {
  height: 100%;
}

.pb-embed-body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: #0f172a;
  background: #f8fafc;
  -webkit-font-smoothing: antialiased;
}

.pb-embed-root {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  width: 100%;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
}

.pb-embed-root.pb-invert {
  filter: invert(1);
}

.pb-embed-root.pb-invert .pb-embed-header,
.pb-embed-root.pb-invert .pb-embed-footer {
  filter: invert(1);
}

/* Branded header */
.pb-embed-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
}

.pb-embed-header__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pb-embed-header__avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  object-fit: cover;
}

.pb-embed-header__avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pb-accent, #2563eb);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}

.pb-embed-header__text {
  min-width: 0;
}

.pb-embed-header__name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-embed-header__subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: #64748b;
}

.pb-embed-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pb-embed-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.pb-embed-icon-btn svg {
  width: 18px;
  height: 18px;
}

.pb-embed-icon-btn:hover,
.pb-embed-icon-btn:focus-visible {
  background: #f1f5f9;
  color: #334155;
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
}

.pb-embed-restart-btn,
.pb-embed-close-btn {
  color: #64748b;
}

/* Messages */
.pb-embed-messages-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f8fafc;
}

.pb-embed-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px 8px;
  -webkit-overflow-scrolling: touch;
}

.pb-embed-messages ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.pb-embed-msg {
  display: flex;
  flex-direction: column;
  margin-bottom: 12px;
  max-width: 92%;
}

.pb-embed-msg--user {
  align-self: flex-end;
  margin-left: auto;
}

.pb-embed-msg--bot {
  align-self: flex-start;
}

.pb-embed-msg--card {
  max-width: 100%;
}

.pb-embed-msg-sender {
  margin: 0 0 4px 2px;
  font-size: 11px;
  font-weight: 500;
  color: #64748b;
}

.pb-embed-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.5;
}

.pb-embed-msg--user .pb-embed-bubble {
  background: var(--pb-accent, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.pb-embed-msg--bot .pb-embed-bubble {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pb-embed-msg--bot .pb-embed-bubble strong {
  font-weight: 600;
  color: #0f172a;
}

.pb-embed-bubble-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  max-width: 100%;
}

.pb-lead-progress-badge {
  display: inline-block;
  max-width: 100%;
  margin-bottom: 8px;
  padding: 2px 8px;
  border-radius: 9999px;
  border: none;
  background: #000;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.pb-rich-response {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pb-rich-response > :first-child {
  margin-top: 0;
}

.pb-rich-response > :last-child {
  margin-bottom: 0;
}

.pb-rich-response p {
  margin: 0.35em 0;
}

.pb-rich-response ul,
.pb-rich-response ol {
  margin: 0.35em 0;
  padding-left: 1.25rem;
}

.pb-rich-response li {
  margin: 0.15em 0;
}

.pb-rich-response h3,
.pb-rich-response h4 {
  font-size: 1em;
  font-weight: 600;
  margin: 0.4em 0 0.2em;
}

.pb-rich-response code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
  background: #f1f5f9;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.pb-rich-response a {
  color: var(--pb-accent, #2563eb);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.pb-rich-response a:hover {
  color: #1d4ed8;
}

.pb-rich-response a:focus-visible {
  outline: 2px solid var(--pb-accent, #2563eb);
  outline-offset: 2px;
}

.pb-embed-bubble--typing::after {
  content: '';
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: #94a3b8;
  animation: pb-caret 0.9s step-end infinite;
}

@keyframes pb-caret {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.pb-embed-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}

.pb-embed-typing span {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #94a3b8;
  animation: pb-typing 1.2s infinite ease-in-out;
}

.pb-embed-typing span:nth-child(2) { animation-delay: 0.15s; }
.pb-embed-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pb-typing {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Quick topics action deck */
.pb-embed-action-deck {
  flex-shrink: 0;
  padding: 4px 14px 2px;
  background: #f8fafc;
  border-top: none;
}

.pb-embed-action-deck__label {
  display: none;
}

.pb-embed-action-deck__buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.pb-embed-deck-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  max-width: 100%;
}

.pb-embed-deck-btn:hover,
.pb-embed-deck-btn:focus-visible {
  background: #f8fafc;
  border-color: #94a3b8;
  outline: none;
  box-shadow: 0 0 0 2px #bfdbfe;
}

.pb-embed-deck-btn--topic {
  color: #1e40af;
  border-color: #bfdbfe;
}

.pb-embed-deck-btn--topic:hover,
.pb-embed-deck-btn--topic:focus-visible {
  background: #eff6ff;
  border-color: #93c5fd;
}

.pb-embed-deck-btn--lead {
  color: #334155;
  border-color: #cbd5e1;
}

.pb-embed-deck-btn--more {
  color: #64748b;
  border-style: dashed;
}

.pb-embed-deck-btn--soft {
  color: #475569;
  background: #f8fafc;
  border-color: #e2e8f0;
}

.pb-embed-deck-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Lead confirmation card */
.pb-embed-confirm-card {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.pb-embed-confirm-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
}

.pb-embed-confirm-card__body {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: #334155;
}

.pb-embed-completion-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.pb-embed-deck-btn--primary {
  color: #fff;
  background: var(--pb-accent, #2563eb);
  border-color: var(--pb-accent, #2563eb);
}

.pb-embed-deck-btn--primary:hover,
.pb-embed-deck-btn--primary:focus-visible {
  background: #1d4ed8;
  border-color: #1d4ed8;
  color: #fff;
}

.pb-embed-confirm-card__summary {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
  font-size: 13px;
  color: #475569;
}

.pb-embed-confirm-card__summary-title {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}

.pb-embed-confirm-card__summary p {
  margin: 4px 0;
}

.pb-embed-confirm-card__summary span {
  color: #64748b;
}

/* Legacy chips (newsletter/promo yes-no) */
.pb-embed-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--pb-accent, #2563eb);
  background: #fff;
  border: 1px solid #bfdbfe;
  border-radius: 9999px;
  cursor: pointer;
}

.pb-embed-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* Composer */
.pb-embed-composer {
  flex-shrink: 0;
  padding: 8px 14px 10px;
  background: #fff;
  border-top: 1px solid #f1f5f9;
  position: relative;
  z-index: 2;
}

.pb-embed-composer-toggle {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  text-align: center;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 9999px;
  cursor: pointer;
}

.pb-embed-composer-toggle:hover,
.pb-embed-composer-toggle:focus-visible {
  background: #f1f5f9;
  outline: 2px solid #93c5fd;
}

.pb-embed-composer-panel--collapsed {
  display: none;
}

.pb-embed-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pb-embed-input-row textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  background: #f8fafc;
  color: #0f172a;
}

.pb-embed-input-row textarea:focus {
  outline: 2px solid #93c5fd;
  border-color: #2563eb;
  background: #fff;
}

.pb-embed-input-row textarea:disabled {
  background: #f1f5f9;
  color: #64748b;
}

.pb-embed-send {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: none;
  border-radius: 9999px;
  background: var(--pb-accent, #2563eb);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.pb-embed-send:hover:not(:disabled) {
  transform: scale(1.04);
}

.pb-embed-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.pb-embed-send svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.pb-embed-footer {
  flex-shrink: 0;
  padding: 4px 12px 8px;
  text-align: center;
  font-size: 10px;
  line-height: 1.4;
  color: #64748b;
  background: #fff;
}

.pb-embed-footer__inner {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  gap: 0;
}

.pb-embed-footer__sep {
  color: #94a3b8;
  white-space: pre;
}

.pb-embed-footer a {
  color: #2563eb;
  text-decoration: none;
}

.pb-embed-footer a:hover {
  text-decoration: underline;
}

.pb-embed-footer__privacy {
  font: inherit;
  font-size: inherit;
  line-height: inherit;
  color: #2563eb;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.pb-embed-footer__privacy:hover {
  text-decoration: underline;
}

.pb-embed-footer__privacy:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 2px;
}

.pb-embed-dialog--privacy {
  max-width: min(320px, calc(100vw - 32px));
}

.pb-embed-privacy-body p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
}

.pb-embed-privacy-body p + p {
  margin-top: 12px;
}

.pb-embed-privacy-link-wrap a {
  font-size: 13px;
  font-weight: 500;
  color: #2563eb;
  text-decoration: none;
}

.pb-embed-privacy-link-wrap a:hover {
  text-decoration: underline;
}

.pb-embed-privacy-link-wrap a:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
  border-radius: 2px;
}

.pb-embed-root--lead-mode .pb-embed-action-deck {
  display: none !important;
}

/* Inline lead contact forms (Request a follow-up flow) */
.pb-embed-lead-form {
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.pb-embed-lead-form__label {
  display: block;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.pb-embed-lead-form__input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.4;
  color: #0f172a;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.pb-embed-lead-form__input:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.pb-embed-lead-form__input::placeholder {
  color: #94a3b8;
}

.pb-embed-lead-form__error {
  margin: 8px 0 0;
  font-size: 13px;
  color: #b91c1c;
}

.pb-embed-lead-form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pb-embed-lead-form .pb-btn-primary,
.pb-embed-lead-form .pb-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.pb-embed-lead-form .pb-btn-primary {
  color: #fff;
  background: var(--pb-accent, #2563eb);
  border-color: var(--pb-accent, #2563eb);
}

.pb-embed-lead-form .pb-btn-primary:hover,
.pb-embed-lead-form .pb-btn-primary:focus-visible {
  background: #1d4ed8;
  border-color: #1d4ed8;
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.pb-embed-lead-form .pb-btn-secondary {
  color: #475569;
  background: #fff;
  border-color: #cbd5e1;
}

.pb-embed-lead-form .pb-btn-secondary:hover,
.pb-embed-lead-form .pb-btn-secondary:focus-visible {
  background: #f8fafc;
  border-color: #94a3b8;
  outline: none;
  box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.25);
}

/* FAQ dialog overlay (legacy) */
.pb-embed-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
}

.pb-embed-overlay.pb-open {
  display: flex;
}

.pb-embed-dialog {
  width: 100%;
  max-width: 340px;
  max-height: min(70vh, 420px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

.pb-embed-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #f1f5f9;
}

.pb-embed-dialog-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.pb-embed-empty-faq {
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.pb-embed-dialog-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.pb-embed-dialog-body ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pb-embed-dialog-body li {
  margin-bottom: 8px;
}

.pb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .pb-embed-bubble--typing::after,
  .pb-embed-typing span {
    animation: none !important;
  }

  .pb-embed-send:hover:not(:disabled) {
    transform: none;
  }
}

.pb-embed-bubble {
  word-break: break-word;
  overflow-wrap: anywhere;
}

.pb-embed-status-text {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  color: #64748b;
}

.pb-embed-lead-form__helper {
  margin: 4px 0 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #64748b;
}

.pb-embed-lead-form__optional {
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
}

.pb-embed-send {
  min-width: 44px;
  min-height: 44px;
  gap: 4px;
  padding: 0 10px;
}

.pb-embed-send__label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.pb-embed-send--processing {
  min-width: 72px;
  padding: 0 12px;
}

.pb-embed-send--processing svg {
  display: none;
}

.pb-embed-send--processing .pb-embed-send__label {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  clip: auto;
  overflow: visible;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .pb-embed-root {
    border-radius: 0;
    border: none;
    max-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .pb-embed-messages {
    padding: 12px 12px 6px;
  }

  .pb-embed-action-deck {
    padding: 4px 12px 2px;
  }

  .pb-embed-deck-btn {
    min-height: 44px;
    font-size: 14px;
  }

  .pb-embed-input-row textarea {
    font-size: 16px;
  }

  .pb-embed-lead-form__input {
    font-size: 16px;
  }

  .pb-embed-icon-btn {
    width: 44px;
    height: 44px;
  }

  .pb-embed-composer {
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0));
  }
}

/* Shared monogram avatar (widget host pages load presbot-embed.css) */
.pb-bot-avatar {
  flex-shrink: 0;
  border-radius: 9999px;
}

.pb-bot-avatar--img {
  object-fit: cover;
  display: block;
}

.pb-bot-avatar--monogram,
.pb-embed-header__avatar--fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--pb-avatar-accent, var(--pb-accent, #2563eb));
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
}

.pb-embed-header__avatar.pb-bot-avatar--img,
.pb-embed-header__avatar.pb-bot-avatar--monogram,
.pb-embed-header__avatar--fallback {
  width: 40px;
  height: 40px;
}
