/* ===== CHATBOT WIDGET ===== */
/* Floating chat bubble + panel, bottom-right. Matches site palette. */

#bc-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212, 129, 58, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#bc-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(212, 129, 58, 0.55);
}

#bc-chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: transform 0.2s ease, opacity 0.15s ease;
}

#bc-chat-bubble .bc-icon-close {
  display: none;
  transform: scale(0.85);
}

#bc-chat-bubble.is-open .bc-icon-chat { display: none; }
#bc-chat-bubble.is-open .bc-icon-close { display: block; }

/* Notification dot */
#bc-chat-bubble::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2d7a5b;
  border: 2px solid #faf8f4;
  animation: bc-pulse 2s infinite;
}

#bc-chat-bubble.is-open::after,
#bc-chat-bubble.no-dot::after {
  display: none;
}

@keyframes bc-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.3); opacity: 0.7; }
}

/* ===== CHAT PANEL ===== */
#bc-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 8999;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* animate in/out */
  transform-origin: bottom right;
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1), opacity 0.18s ease;
}

#bc-chat-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Panel header */
.bc-header {
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: var(--font-display);
}

.bc-header-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bc-header-name {
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
}

.bc-header-sub {
  font-size: 0.72rem;
  opacity: 0.85;
  font-family: var(--font-body);
}

/* Messages area */
.bc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  max-height: 340px;
  background: var(--bg);
  scroll-behavior: smooth;
}

.bc-messages::-webkit-scrollbar { width: 4px; }
.bc-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Individual messages */
.bc-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  animation: bc-msg-in 0.2s ease;
}

@keyframes bc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bc-msg.bot {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.bc-msg.user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* Markdown-rendered bot messages */
.bc-msg.bot strong { font-weight: 600; }
.bc-msg.bot p { margin: 0 0 6px; }
.bc-msg.bot p:last-child { margin: 0; }
.bc-msg.bot br { line-height: 1.8; }

/* Typing indicator */
.bc-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: 54px;
}

.bc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: bc-dot 1.2s infinite ease-in-out;
}
.bc-typing span:nth-child(2) { animation-delay: 0.2s; }
.bc-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bc-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1); opacity: 1; }
}

/* Input area */
.bc-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}

#bc-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 0.875rem;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  outline: none;
  resize: none;
  line-height: 1.45;
  transition: border-color 0.15s;
}

#bc-input:focus { border-color: var(--accent); }
#bc-input::placeholder { color: var(--text-muted); }

#bc-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s;
  outline: none;
  margin-top: 1px;
}

#bc-send:hover { background: var(--accent-dark); }
#bc-send:active { transform: scale(0.93); }
#bc-send svg { width: 18px; height: 18px; fill: #fff; }
#bc-send:disabled { opacity: 0.5; cursor: default; }

/* ===== MOBILE ===== */
@media (max-width: 480px) {
  #bc-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    border-bottom: none;
  }

  #bc-chat-bubble {
    bottom: 16px;
    right: 16px;
  }

  .bc-messages {
    max-height: 45vh;
  }
}
