/* ── BCHN Chat Widget ───────────────────────────────────────────────── */

#bchn-chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: 13px 20px 13px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 4px 20px rgba(26,37,82,0.38);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
#bchn-chat-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(26,37,82,0.48);
}
#bchn-chat-toggle.bchn-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

/* ── Panel ── */
#bchn-chat-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 360px;
  height: 500px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 52px rgba(26,37,82,0.22), 0 0 0 1px rgba(26,37,82,0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
  pointer-events: none;
}
#bchn-chat-panel[hidden] { display: flex; }
#bchn-chat-panel.bchn-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
.bchn-chat-header {
  background: var(--navy-dk);
  color: #fff;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.bchn-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bchn-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.25);
}
.bchn-chat-title { font-family: var(--sans); font-weight: 600; font-size: 0.9rem; }
.bchn-chat-subtitle { font-family: var(--sans); font-size: 0.7rem; opacity: 0.65; margin-top: 1px; }
#bchn-chat-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
  line-height: 1;
}
#bchn-chat-close:hover { color: #fff; }

/* ── Messages ── */
.bchn-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cream);
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.bchn-chat-messages::-webkit-scrollbar { width: 4px; }
.bchn-chat-messages::-webkit-scrollbar-track { background: transparent; }
.bchn-chat-messages::-webkit-scrollbar-thumb { background: var(--tan-bg); border-radius: 2px; }

.bchn-msg {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}
.bchn-msg.user  { align-self: flex-end;   align-items: flex-end; }
.bchn-msg.assistant { align-self: flex-start; align-items: flex-start; }

.bchn-msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}
.bchn-msg.user .bchn-msg-bubble {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bchn-msg.assistant .bchn-msg-bubble {
  background: #fff;
  color: var(--charcoal);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(26,37,82,0.08);
}

/* ── Inline links in messages ── */
.bchn-msg.assistant .bchn-link {
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
}
.bchn-msg.assistant .bchn-link:hover { opacity: 0.75; }
.bchn-msg.user .bchn-link {
  color: rgba(255,255,255,0.85);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Typing indicator ── */
.bchn-typing-dots {
  display: flex;
  gap: 5px;
  padding: 4px 2px;
  align-items: center;
}
.bchn-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--tan);
  border-radius: 50%;
  animation: bchnBounce 1.2s ease-in-out infinite;
}
.bchn-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.bchn-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes bchnBounce {
  0%, 60%, 100% { transform: translateY(0);   opacity: 0.35; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Starter Chips ── */
.bchn-chips {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 2px;
  align-self: flex-start;
  width: 100%;
  max-width: 96%;
}
.bchn-chip {
  background: #fff;
  border: 1.5px solid var(--navy);
  border-radius: 20px;
  padding: 7px 14px;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--navy);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}
.bchn-chip:hover, .bchn-chip:active {
  background: var(--navy);
  color: #fff;
}

/* ── CTA Bar ── */
#bchn-cta-bar {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px 12px;
  background: #fff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#bchn-cta-bar.bchn-cta-visible { display: flex; }
.bchn-cta-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bchn-cta-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
#bchn-cta-dismiss {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
#bchn-cta-dismiss:hover { color: var(--charcoal); }
.bchn-cta-buttons {
  display: flex;
  gap: 8px;
}
.bchn-cta-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.bchn-cta-btn:hover { opacity: 0.82; }
.bchn-cta-call {
  background: var(--navy);
  color: #fff;
}
.bchn-cta-email {
  background: var(--cream);
  color: var(--navy);
  border: 1.5px solid var(--navy);
}

/* ── Input footer ── */
.bchn-chat-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.bchn-input-hipaa {
  width: 100%;
  font-family: var(--sans);
  font-size: 0.65rem;
  color: var(--muted);
  margin: 0 0 5px;
  text-align: center;
}

#bchn-chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 0.875rem;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 112px;
  color: var(--charcoal);
  background: var(--cream);
  transition: border-color 0.15s;
  overflow-y: auto;
}
#bchn-chat-input:focus { border-color: var(--navy); }
#bchn-chat-input::placeholder { color: var(--muted); }

#bchn-chat-send {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  flex-shrink: 0;
}
#bchn-chat-send:hover  { background: var(--navy-lt); }
#bchn-chat-send:active { transform: scale(0.9); }
#bchn-chat-send:disabled { background: var(--border); cursor: not-allowed; }

/* ── Lead Form Panel ── */
#bchn-lead-form {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#bchn-lead-form[hidden] { display: none; }
.bchn-lead-form-header {
  background: var(--navy-dk);
  color: #fff;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#bchn-lead-back {
  background: none;
  border: none;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--sans);
  font-size: 0.82rem;
  padding: 0;
  transition: color 0.15s;
}
#bchn-lead-back:hover { color: #fff; }
.bchn-lead-form-title {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.9rem;
}
.bchn-lead-form-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--cream);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.bchn-lead-form-intro {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}
.bchn-lead-row {
  display: flex;
  gap: 8px;
}
.bchn-lead-row input { flex: 1; }
.bchn-lead-form-body input,
.bchn-lead-form-body textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--charcoal);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  resize: none;
}
.bchn-lead-form-body input:focus,
.bchn-lead-form-body textarea:focus { border-color: var(--navy); }
.bchn-lead-form-body input::placeholder,
.bchn-lead-form-body textarea::placeholder { color: var(--muted); }
.bchn-lead-hipaa {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
  margin: 0;
}
#bchn-lead-submit {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  width: 100%;
}
#bchn-lead-submit:hover { background: var(--navy-lt); }
#bchn-lead-submit:disabled { background: var(--border); cursor: not-allowed; }
.bchn-lead-success-msg {
  font-family: var(--sans);
  font-size: 0.9rem;
  color: #065f46;
  background: #d1fae5;
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0;
  text-align: center;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #bchn-chat-toggle {
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
  }
  #bchn-chat-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    height: 82dvh;
    border-radius: 16px 16px 0 0;
  }
  .bchn-chat-footer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
}
