/* ============================================================
   BDC – Chatbot Widget
   ============================================================ */

/* ── Toggle Button ─────────────────────────────────────────── */
#chatbot-toggle {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 20px rgba(27,58,138,.40);
  transition: background .2s, transform .2s, box-shadow .2s;
  outline: none;
}
#chatbot-toggle:hover {
  background: var(--primary-lt);
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(27,58,138,.50);
}
#chatbot-toggle .cb-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--accent);
  color: var(--primary-dk);
  font-size: .6rem;
  font-weight: 700;
  font-family: var(--font-head);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  transition: opacity .2s;
}
#chatbot-toggle .cb-badge.hidden { opacity: 0; pointer-events: none; }

/* ── Window ────────────────────────────────────────────────── */
#chatbot-window {
  position: fixed;
  bottom: 148px;
  right: 24px;
  z-index: 9001;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 48px rgba(27,58,138,.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* hidden by default */
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(.97);
  transition: opacity .22s ease, transform .22s ease;
  max-height: 520px;
}
#chatbot-window.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Header ────────────────────────────────────────────────── */
.cb-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.cb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--primary-dk);
  flex-shrink: 0;
}
.cb-header-info { flex: 1; min-width: 0; }
.cb-header-info strong {
  display: block;
  font-family: var(--font-head);
  font-size: .88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cb-header-info span {
  font-size: .72rem;
  opacity: .8;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cb-header-info span::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}
.cb-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 6px;
  transition: color .15s, background .15s;
  line-height: 1;
}
.cb-close:hover { color: #fff; background: rgba(255,255,255,.15); }

/* ── Messages ──────────────────────────────────────────────── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f6faff;
  scroll-behavior: smooth;
}
.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.cb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 88%;
  animation: cbFadeIn .2s ease;
}
@keyframes cbFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cb-msg.bot  { align-self: flex-start; }
.cb-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.cb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  color: var(--primary-dk);
  flex-shrink: 0;
}

.cb-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.5;
  font-family: var(--font-body);
  word-break: break-word;
}
.cb-msg.bot  .cb-bubble {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(27,58,138,.07);
}
.cb-msg.user .cb-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ──────────────────────────────────────── */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
}
.cb-typing span {
  width: 7px;
  height: 7px;
  background: var(--primary-lt);
  border-radius: 50%;
  display: inline-block;
  animation: cbBounce 1.2s infinite;
  opacity: .6;
}
.cb-typing span:nth-child(2) { animation-delay: .2s; }
.cb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cbBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* ── Input bar ─────────────────────────────────────────────── */
.cb-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
#chatbot-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: .84rem;
  font-family: var(--font-body);
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  resize: none;
  background: #f6faff;
}
#chatbot-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,196,223,.15);
}
#chatbot-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  transition: background .2s, transform .15s;
  flex-shrink: 0;
}
#chatbot-send:hover  { background: var(--primary-lt); }
#chatbot-send:active { transform: scale(.93); }
#chatbot-send:disabled { background: var(--border); cursor: not-allowed; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #chatbot-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 75vh;
  }
  #chatbot-toggle {
    bottom: 74px;
    right: 16px;
  }
}
