/* Shared chat widget — theme via [data-chat-site] */
.chat-widget {
  --chat-accent: #c45c26;
  --chat-bg: #fff;
  --chat-text: #1a1a1a;
  --chat-muted: #5c5c5c;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 200;
  font-family: 'DM Sans', system-ui, sans-serif;
}

[data-chat-site="trade-servicez"].chat-widget {
  --chat-accent: #0b6e8c;
}

.chat-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: var(--chat-accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s, box-shadow 0.2s;
}

.chat-toggle:hover { transform: translateY(-2px); }

.chat-toggle svg { width: 22px; height: 22px; flex-shrink: 0; }

.chat-panel {
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: calc(100% + 0.75rem);
  right: 0;
  width: min(380px, calc(100vw - 2rem));
  height: min(520px, calc(100vh - 8rem));
  background: var(--chat-bg);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

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

.chat-header {
  padding: 0.9rem 1rem;
  background: var(--chat-accent);
  color: #fff;
}

.chat-header h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.15rem; }
.chat-header p { font-size: 0.78rem; margin: 0; opacity: 0.9; }

.chat-meta {
  font-size: 0.68rem;
  color: var(--chat-muted);
  margin-top: 0.45rem;
  font-style: italic;
}

.chat-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #f8f9fb;
}

.chat-msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-msg strong { font-weight: 600; }

.chat-msg.bot {
  align-self: flex-start;
  background: #fff;
  color: var(--chat-text);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--chat-accent);
  color: #fff;
}

.chat-msg.typing {
  color: var(--chat-muted);
  font-style: italic;
  background: transparent;
  border: none;
  padding: 0.25rem 0;
}

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.5rem;
  background: #f8f9fb;
}

.chat-chip {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: #fff;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--chat-text);
}

.chat-chip:hover { border-color: var(--chat-accent); color: var(--chat-accent); }

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.chat-action {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--chat-accent);
  text-decoration: none;
}

.chat-action:hover { text-decoration: underline; }

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.chat-form input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 999px;
  font: inherit;
  font-size: 0.9rem;
}

.chat-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--chat-accent) 25%, transparent);
  border-color: var(--chat-accent);
}

.chat-send {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 999px;
  background: var(--chat-accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.chat-send:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 960px) {
  :root {
    --chat-safe-bottom: 5.75rem;
  }

  body:has(#site-chat) {
    padding-bottom: calc(var(--chat-safe-bottom) + env(safe-area-inset-bottom, 0px));
  }

  .chat-widget {
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    right: max(1rem, env(safe-area-inset-right, 0px));
  }

  .chat-toggle {
    max-width: calc(100vw - 2rem);
    font-size: 0.88rem;
    padding: 0.65rem 0.95rem;
  }

  [data-chat-site="trade-servicez"].chat-widget { bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); }
}

/* Keep CTAs, forms, and cards scrollable above the chat bubble */
.cta-box,
.conversion-block,
.conversion-actions .btn,
.newsletter-form,
.resource-card,
.money-tool-card,
.start-path-card,
.calc-card,
.btn-primary,
.btn-secondary,
form.contact-form {
  scroll-margin-bottom: calc(var(--chat-safe-bottom, 5.75rem) + 1rem);
}