/* ---------------------------------------------------------------------
   Dependency Series chat widget
   Reuses the site's existing design tokens (--color-primary, --color-accent,
   --color-bg, --font-display, --font-body, etc. from style.css).
--------------------------------------------------------------------- */

#ds-chat-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 500;
  font-family: var(--font-body);
}

.ds-chat-bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--color-primary-fill);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 76, 79, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ds-chat-bubble:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(15, 76, 79, 0.4); }
.ds-chat-bubble svg { width: 26px; height: 26px; }
.ds-chat-bubble .ds-chat-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--color-accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  border: 2px solid var(--color-bg);
}

.ds-chat-teaser {
  position: absolute;
  bottom: 8px;
  right: 70px;
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--color-surface, #fff);
  color: var(--color-text, #23231f);
  border: 1px solid var(--color-divider);
  border-radius: 999px;
  padding: 10px 10px 10px 16px;
  box-shadow: 0 8px 24px rgba(20, 20, 20, 0.16);
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 600;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.ds-chat-teaser.is-visible { display: flex; opacity: 1; transform: translateX(0); }
.ds-chat-teaser-dismiss {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ds-chat-teaser-dismiss:hover { background: var(--color-bg); }
@media (max-width: 480px) {
  .ds-chat-teaser { right: 66px; font-size: 0.86rem; padding: 8px 8px 8px 14px; }
}

.ds-chat-panel {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: min(380px, calc(100vw - 40px));
  max-height: min(600px, calc(100vh - 120px));
  background: var(--color-surface, #fff);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 20px 50px rgba(20, 20, 20, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--color-divider);
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
.ds-chat-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.ds-chat-header {
  background: var(--color-primary-fill);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ds-chat-header-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0; }
.ds-chat-header-sub { font-size: 12px; opacity: 0.85; margin: 2px 0 0; }
.ds-chat-close {
  background: transparent; border: none; color: #fff; opacity: 0.85; cursor: pointer;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px;
}
.ds-chat-close:hover { opacity: 1; background: rgba(255,255,255,0.12); }

.ds-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-bg);
}

.ds-chat-msg { max-width: 88%; font-size: 13.5px; line-height: 1.5; padding: 9px 12px; border-radius: 12px; }
.ds-chat-msg.assistant { align-self: flex-start; background: #fff; color: var(--color-text); border: 1px solid var(--color-divider); border-bottom-left-radius: 4px; }
.ds-chat-msg.user { align-self: flex-end; background: var(--color-primary); color: #fff; border-bottom-right-radius: 4px; }
.ds-chat-msg a { color: inherit; text-decoration: underline; }
.ds-chat-msg.assistant a { color: var(--color-primary); }
.ds-chat-msg.typing { display: flex; gap: 4px; align-items: center; padding: 12px 14px; }
.ds-chat-msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--color-text-muted); opacity: 0.5; animation: ds-chat-bounce 1.1s infinite ease-in-out; }
.ds-chat-msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.ds-chat-msg.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ds-chat-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.4; } 40% { transform: translateY(-4px); opacity: 1; } }

.ds-chat-starters { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; }
.ds-chat-chip {
  background: #fff; border: 1px solid var(--color-primary); color: var(--color-primary);
  font-size: 12px; padding: 6px 10px; border-radius: 999px; cursor: pointer; text-align: left;
}
.ds-chat-chip:hover { background: var(--color-primary); color: #fff; }

/* Inline optional opt-in card */
.ds-chat-card {
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--color-divider);
  border-radius: 10px;
  padding: 12px;
  font-size: 13px;
}
.ds-chat-card p { margin: 0 0 8px; color: var(--color-text); }
.ds-chat-card-row { display: flex; gap: 6px; }
.ds-chat-card input[type="email"], .ds-chat-card input[type="text"], .ds-chat-card input[type="tel"] {
  flex: 1; font-size: 13px; padding: 7px 9px; border: 1px solid var(--color-divider); border-radius: 6px; font-family: var(--font-body);
}
.ds-chat-card-actions { display: flex; gap: 6px; margin-top: 8px; }
.ds-chat-btn {
  font-size: 12.5px; padding: 7px 12px; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; font-family: var(--font-body);
}
.ds-chat-btn.primary { background: var(--color-accent); color: #fff; }
.ds-chat-btn.primary:hover { filter: brightness(1.05); }
.ds-chat-btn.ghost { background: transparent; color: var(--color-text-muted); }
.ds-chat-btn.ghost:hover { color: var(--color-text); }
.ds-chat-card-note { font-size: 11px; color: var(--color-text-muted); margin-top: 6px; }

.ds-chat-consult-banner {
  align-self: stretch;
  background: #fff;
  border: 1px solid var(--color-accent);
  border-radius: 10px;
  padding: 12px;
}
.ds-chat-consult-banner h4 { margin: 0 0 4px; font-family: var(--font-display); font-size: 13.5px; color: var(--color-primary); }
.ds-chat-consult-banner p { margin: 0 0 8px; font-size: 12.5px; color: var(--color-text-muted); }

.ds-chat-footer {
  border-top: 1px solid var(--color-divider);
  padding: 10px 12px;
  background: #fff;
  flex-shrink: 0;
}
.ds-chat-footer-link { display: block; font-size: 11.5px; color: var(--color-text-muted); text-align: center; margin-bottom: 8px; cursor: pointer; text-decoration: underline; background: none; border: none; width: 100%; font-family: var(--font-body); }
.ds-chat-footer-link:hover { color: var(--color-primary); }
.ds-chat-input-row { display: flex; gap: 8px; }
.ds-chat-input-row textarea {
  flex: 1; resize: none; border: 1px solid var(--color-divider); border-radius: 8px; padding: 8px 10px;
  font-family: var(--font-body); font-size: 13.5px; max-height: 80px; min-height: 38px;
}
.ds-chat-send {
  background: var(--color-primary); color: #fff; border: none; border-radius: 8px; width: 38px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.ds-chat-send:disabled { opacity: 0.5; cursor: not-allowed; }
.ds-chat-disclaimer { font-size: 10.5px; color: var(--color-text-muted); text-align: center; margin-top: 6px; }

@media (max-width: 480px) {
  .ds-chat-panel { right: -10px; }
}

[data-theme="dark"] .ds-chat-msg.assistant { background: var(--color-surface); border-color: var(--color-divider); }
[data-theme="dark"] .ds-chat-card,
[data-theme="dark"] .ds-chat-consult-banner,
[data-theme="dark"] .ds-chat-footer,
[data-theme="dark"] .ds-chat-panel { background: var(--color-surface); }
[data-theme="dark"] .ds-chat-chip { background: var(--color-surface); }
[data-theme="dark"] .ds-chat-teaser { background: var(--color-surface); color: var(--color-text); border-color: var(--color-divider); }
