/* ── Be There Support Chat Widget ── */

/* Toggle button */
#bethere-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dark, #7C3AED), var(--primary, #8B5CF6));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(var(--glow-rgb, 139,92,246), 0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

#bethere-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(var(--glow-rgb, 139,92,246), 0.55);
}

#bethere-chat-btn .bt-btn-icon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#bethere-chat-btn .bt-btn-icon svg {
  width: 22px;
  height: 22px;
}

#bethere-chat-btn .bt-icon-chat   { opacity: 1; transform: scale(1); }
#bethere-chat-btn .bt-icon-close  { opacity: 0; transform: scale(0.5) rotate(-45deg); }

#bethere-chat-btn.open .bt-icon-chat  { opacity: 0; transform: scale(0.5) rotate(45deg); }
#bethere-chat-btn.open .bt-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* Panel */
#bethere-chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9998;
  width: 360px;
  max-height: 540px;
  background: var(--bg, #06060b);
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 20px;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.5),
    0 0 0 1px var(--glass-border, rgba(255,255,255,0.07)),
    0 0 40px rgba(var(--glow-rgb, 139,92,246), 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.26s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
}

#bethere-chat-panel.hidden {
  transform: scale(0.88) translateY(12px);
  opacity: 0;
  pointer-events: none;
}

/* Header */
.bt-chat-header {
  padding: 14px 18px;
  background: linear-gradient(135deg, rgba(var(--glow-rgb, 139,92,246), 0.1), transparent);
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.06));
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.bt-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dark, #7C3AED), var(--accent, #EC4899));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(var(--glow-rgb, 139,92,246), 0.25);
}

.bt-header-info { flex: 1; }
.bt-header-info h4 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1, #f5f5f7);
  letter-spacing: -0.01em;
}

.bt-header-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-3, rgba(255,255,255,0.3));
}

.bt-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34,197,94,0.6);
  animation: bt-pulse-green 2.5s infinite;
}

@keyframes bt-pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Messages */
.bt-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.bt-messages::-webkit-scrollbar { width: 3px; }
.bt-messages::-webkit-scrollbar-track { background: transparent; }
.bt-messages::-webkit-scrollbar-thumb {
  background: var(--border, rgba(255,255,255,0.06));
  border-radius: 99px;
}

/* Message rows */
.bt-msg {
  display: flex;
  flex-direction: column;
  max-width: 83%;
  animation: bt-slide-in 0.2s ease;
}

@keyframes bt-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.bt-msg-user  { align-self: flex-end;  align-items: flex-end; }
.bt-msg-bot   { align-self: flex-start; align-items: flex-start; }
.bt-msg-error { align-self: flex-start; align-items: flex-start; }

.bt-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.52;
  white-space: pre-wrap;
  word-break: break-word;
}

.bt-msg-user .bt-bubble {
  background: linear-gradient(135deg, var(--primary-dark, #7C3AED), var(--primary, #8B5CF6));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.bt-msg-bot .bt-bubble {
  background: var(--glass, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  color: var(--text-1, #f5f5f7);
  border-bottom-left-radius: 4px;
}

.bt-msg-error .bt-bubble {
  background: rgba(239,68,68,0.07);
  border: 1px solid rgba(239,68,68,0.18);
  color: #fca5a5;
  border-bottom-left-radius: 4px;
  font-size: 13px;
}

/* Typing dots */
.bt-typing {
  align-self: flex-start;
  animation: bt-slide-in 0.2s ease;
}

.bt-typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 11px 14px;
  background: var(--glass, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.bt-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-3, rgba(255,255,255,0.3));
  animation: bt-bounce 1.3s infinite;
}
.bt-dot:nth-child(2) { animation-delay: 0.18s; }
.bt-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes bt-bounce {
  0%, 55%, 100% { transform: translateY(0); opacity: 0.45; }
  27%            { transform: translateY(-5px); opacity: 1; }
}

/* Input footer */
.bt-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.06));
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.bt-input {
  flex: 1;
  padding: 9px 13px;
  background: var(--glass, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.06));
  border-radius: 12px;
  color: var(--text-1, #f5f5f7);
  font-size: 13.5px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.45;
  max-height: 112px;
  overflow-y: auto;
  transition: border-color 0.15s;
}

.bt-input::placeholder { color: var(--text-3, rgba(255,255,255,0.3)); }
.bt-input:focus { border-color: var(--border-hover, rgba(139,92,246,0.35)); }
.bt-input:disabled { opacity: 0.5; }

.bt-send {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary-dark, #7C3AED), var(--primary, #8B5CF6));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: opacity 0.15s, transform 0.15s;
}

.bt-send svg { width: 15px; height: 15px; }
.bt-send:disabled { opacity: 0.38; cursor: default; }
.bt-send:not(:disabled):hover { transform: scale(1.07); }

/* Minimal theme (light) overrides */
[data-theme="minimal"] #bethere-chat-panel {
  background: #ffffff;
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.05);
}

[data-theme="minimal"] .bt-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.08);
}

[data-theme="minimal"] .bt-input {
  background: rgba(0,0,0,0.02);
  border-color: rgba(0,0,0,0.08);
  color: #18181b;
}

[data-theme="minimal"] .bt-input::placeholder { color: rgba(0,0,0,0.3); }
[data-theme="minimal"] .bt-input:focus { border-color: rgba(139,92,246,0.3); }

[data-theme="minimal"] .bt-msg-bot .bt-bubble {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.07);
  color: #18181b;
}

[data-theme="minimal"] .bt-header-status { color: rgba(0,0,0,0.4); }
[data-theme="minimal"] .bt-dot { background: rgba(0,0,0,0.25); }

[data-theme="minimal"] .bt-typing-bubble {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.07);
}

/* Mobile */
@media (max-width: 480px) {
  #bethere-chat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 72vh;
    border-radius: 20px 20px 0 0;
  }
  #bethere-chat-btn {
    bottom: 16px;
    right: 16px;
  }
}
