/* ============================================================
   DCBL AI Chatbot
   ============================================================ */

:root {
  --dcbl-primary:       #1a3c6e;
  --dcbl-primary-dark:  #122c52;
  --dcbl-primary-light: #e8eef7;
  --dcbl-text:          #1a1a2e;
  --dcbl-muted:         #6b7280;
  --dcbl-border:        #e5e7eb;
  --dcbl-bg:            #ffffff;
  --dcbl-radius:        16px;
  --dcbl-shadow:        0 8px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
  --dcbl-font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --dcbl-z:             2147483000;
  --dcbl-width:         360px;
  --dcbl-height:        520px;
}

#dcbl-chat-root *,
#dcbl-chat-root *::before,
#dcbl-chat-root *::after {
  box-sizing: border-box;
  font-family: var(--dcbl-font);
}

#dcbl-chat-root {
  position: fixed;
  bottom: 24px;
  right:  24px;
  z-index: var(--dcbl-z);
}

/* ── Launcher ─────────────────────────────────────────────── */
#dcbl-chat-launcher {
  position: relative;
  width:  60px;
  height: 60px;
  border-radius: 50%;
  background: var(--dcbl-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  outline: none;
}
#dcbl-chat-launcher:hover  { background: var(--dcbl-primary-dark); transform: scale(1.07); box-shadow: 0 6px 22px rgba(0,0,0,.3); }
#dcbl-chat-launcher:focus-visible { outline: 3px solid var(--dcbl-primary); outline-offset: 3px; }
#dcbl-chat-launcher svg    { width: 26px; height: 26px; }

#dcbl-unread-badge {
  position: absolute;
  top: 0; right: 0;
  min-width: 20px; height: 20px;
  background: #e53e3e;
  color: #fff;
  border-radius: 10px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity .2s, transform .2s;
}
#dcbl-unread-badge.dcbl-visible { opacity: 1; transform: scale(1); }

/* ── CTA speech bubble ───────────────────────────────────── */
#dcbl-cta-bubble {
  position: absolute;
  bottom: 70px;
  right: 0;
  background: #fff;
  border-radius: 16px 16px 0 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: 12px 16px;
  width: 220px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--dcbl-text);
  animation: dcbl-fadein .3s ease;
  cursor: pointer;
}

#dcbl-cta-bubble strong {
  display: block;
  font-size: 14px;
  color: var(--dcbl-primary);
  margin-bottom: 3px;
}

#dcbl-cta-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 18px;
  border-left: 8px solid transparent;
  border-right: 0;
  border-top: 8px solid #fff;
}

#dcbl-cta-dismiss {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #9ca3af;
  line-height: 1;
  padding: 0;
}
#dcbl-cta-dismiss:hover { color: #374151; }

/* Attention pulse — plays once on the launcher to draw the eye */
@keyframes dcbl-attention {
  0%   { transform: scale(1);    box-shadow: 0 4px 16px rgba(0,0,0,.25); }
  30%  { transform: scale(1.18); box-shadow: 0 6px 28px rgba(26,60,110,.5); }
  60%  { transform: scale(0.95); box-shadow: 0 4px 16px rgba(0,0,0,.25); }
  100% { transform: scale(1);    box-shadow: 0 4px 16px rgba(0,0,0,.25); }
}
#dcbl-chat-launcher.dcbl-attention {
  animation: dcbl-attention .6s ease 1;
}

/* Persistent pulsing ring around launcher */
#dcbl-chat-launcher::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--dcbl-primary);
  opacity: 0;
  animation: dcbl-ring 2.5s ease-out infinite;
  pointer-events: none;
}
#dcbl-chat-launcher::after {
  content: '';
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--dcbl-primary);
  opacity: 0;
  animation: dcbl-ring 2.5s ease-out infinite .5s;
  pointer-events: none;
}
/* Stop ring once chat has been opened */
#dcbl-chat-launcher.dcbl-seen::before,
#dcbl-chat-launcher.dcbl-seen::after {
  animation: none;
  display: none;
}
@keyframes dcbl-ring {
  0%   { inset: -2px;  opacity: .6; }
  100% { inset: -22px; opacity: 0;  }
}

/* ── Chat window ──────────────────────────────────────────── */
#dcbl-chat-window {
  position: absolute;
  bottom: 72px;
  right:  0;
  width:  var(--dcbl-width);
  height: var(--dcbl-height);
  background: var(--dcbl-bg);
  border-radius: var(--dcbl-radius);
  box-shadow: var(--dcbl-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.175,.885,.32,1.275), opacity .2s ease;
}
#dcbl-chat-window.dcbl-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ───────────────────────────────────────────────── */
#dcbl-chat-header {
  background: var(--dcbl-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
#dcbl-chat-header-left { display: flex; align-items: center; gap: 12px; }

#dcbl-chat-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
#dcbl-chat-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

#dcbl-chat-agent-name  { font-size: 15px; font-weight: 600; line-height: 1.2; }
#dcbl-chat-status      { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 5px; margin-top: 2px; }

.dcbl-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #48bb78;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(72,187,120,.3);
  animation: dcbl-pulse 2s infinite;
}
@keyframes dcbl-pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(72,187,120,.3); }
  50%      { box-shadow: 0 0 0 5px rgba(72,187,120,.1); }
}

#dcbl-chat-header-close {
  background: rgba(255,255,255,.15);
  border: none; border-radius: 6px;
  color: #fff; cursor: pointer;
  padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
#dcbl-chat-header-close:hover { background: rgba(255,255,255,.3); }

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

.dcbl-msg {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  animation: dcbl-fadein .2s ease both;
}
@keyframes dcbl-fadein {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:translateY(0);   }
}
.dcbl-msg-bot  { justify-content: flex-start; }
.dcbl-msg-user { justify-content: flex-end; }

.dcbl-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--dcbl-primary);
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
  overflow: hidden;
}
.dcbl-msg-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.dcbl-bubble {
  max-width: 78%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dcbl-text);
}
.dcbl-msg-bot  .dcbl-bubble { background: var(--dcbl-primary-light); border-bottom-left-radius: 4px; }
.dcbl-msg-user .dcbl-bubble { background: var(--dcbl-primary); color: #fff; border-bottom-right-radius: 4px; }

.dcbl-timestamp {
  font-size: 10px;
  color: var(--dcbl-muted);
  margin-top: 2px;
  padding: 0 4px;
}
.dcbl-msg-bot  + .dcbl-timestamp { text-align: left;  padding-left: 36px; }
.dcbl-msg-user + .dcbl-timestamp { text-align: right; }

/* Typing dots */
#dcbl-typing .dcbl-bubble { display: flex; align-items: center; gap: 4px; padding: 10px 14px; }
.dcbl-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--dcbl-primary);
  opacity: .5;
  animation: dcbl-bounce 1.2s infinite;
}
.dcbl-dot:nth-child(2) { animation-delay: .2s; }
.dcbl-dot:nth-child(3) { animation-delay: .4s; }
@keyframes dcbl-bounce {
  0%,80%,100% { transform:translateY(0);    opacity:.4; }
  40%          { transform:translateY(-5px); opacity:1;  }
}

/* ── Lead confirmed banner ────────────────────────────────── */
#dcbl-lead-confirmed {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #d1fae5;
  color: #065f46;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  animation: dcbl-fadein .3s ease;
  margin: 4px 0;
}

/* ── Input bar ────────────────────────────────────────────── */
#dcbl-chat-inputbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--dcbl-border);
  background: #fff;
  flex-shrink: 0;
}
#dcbl-chat-input {
  flex: 1;
  border: 1.5px solid var(--dcbl-border);
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--dcbl-text);
  outline: none;
  transition: border-color .15s;
  background: #f9f9fb;
}
#dcbl-chat-input:focus    { border-color: var(--dcbl-primary); background: #fff; }
#dcbl-chat-input:disabled { opacity: .5; cursor: not-allowed; }

#dcbl-chat-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--dcbl-primary);
  border: none; color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
#dcbl-chat-send:hover    { background: var(--dcbl-primary-dark); }
#dcbl-chat-send:active   { transform: scale(.92); }
#dcbl-chat-send:disabled { opacity: .4; cursor: not-allowed; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  #dcbl-chat-root   { bottom: 16px; right: 16px; }
  #dcbl-chat-window { width: calc(100vw - 32px); right: 0; bottom: 68px; }
}
