/* ═══════════════════════════════════════════
   BrainBuddy AI — Chatbot Styles
   chatbot.css — standalone, no conflicts with style.css
═══════════════════════════════════════════ */

/* ── Root tokens (mirrors style.css values) ── */
#bb-chat-root {
  --bb-primary:    #5b4fcf;
  --bb-primary-dk: #4338a8;
  --bb-surface:    #ffffff;
  --bb-bg:         #f7f6fe;
  --bb-text:       #20212a;
  --bb-muted:      #686a75;
  --bb-border:     #e8e6f9;
  --bb-radius:     18px;
  --bb-shadow:     0 24px 64px rgba(75,65,170,.18);

  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999;
  font-family: "DM Sans", sans-serif;
  pointer-events: none;
}

#bb-chat-bubble,
#bb-chat-window {
  pointer-events: all;
}

/* ── Floating Bubble ── */
#bb-chat-bubble {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--bb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(10, 10, 10, 0.792);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  margin-left: auto;
}

#bb-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 36px rgba(91,79,207,.50);
}

#bb-bubble-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#bb-bubble-icon img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  /*filter: brightness(0) invert(1); /* white logo — agar logo dark hai toh */
}

#bb-bubble-close {
  color: #fff;
  font-size: 18px;
  line-height: 1;
}

/* Notification badge */
#bb-chat-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
}

/* ── Chat Window ── */
#bb-chat-window {
  width: 360px;
  max-height: 520px;
  background: var(--bb-surface);
  border-radius: var(--bb-radius);
  box-shadow: var(--bb-shadow);
  border: 1px solid var(--bb-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 14px;

  /* Hidden by default */
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  visibility: hidden;
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
}

#bb-chat-window.bb-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  visibility: visible;
}

/* ── Header ── */
#bb-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bb-primary);
  flex-shrink: 0;
}

#bb-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

#bb-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

#bb-chat-avatar img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: block;
}

#bb-bubble-icon img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}

#bb-chat-header strong {
  display: block;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  font-family: "Manrope", sans-serif;
  letter-spacing: -.02em;
}

#bb-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  color: rgba(255,255,255,.75);
  font-size: 11px;
}

#bb-chat-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  animation: bb-pulse 2s infinite;
}

@keyframes bb-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

#bb-chat-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
  transition: color .15s, background .15s;
}

#bb-chat-close:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
}

/* ── Messages ── */
#bb-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#bb-chat-messages::-webkit-scrollbar {
  width: 4px;
}
#bb-chat-messages::-webkit-scrollbar-thumb {
  background: var(--bb-border);
  border-radius: 4px;
}

/* Message rows */
.bb-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.bb-msg-ai {
  flex-direction: row;
}

.bb-msg-user {
  flex-direction: row-reverse;
}

.bb-msg-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bb-bg);
  color: var(--bb-primary);
  display: grid;
  place-items: center;
  font-size: 13px;
  flex-shrink: 0;
}

.bb-msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
}

.bb-msg-ai .bb-msg-bubble {
  background: var(--bb-bg);
  color: var(--bb-text);
  border-bottom-left-radius: 4px;
}

.bb-msg-user .bb-msg-bubble {
  background: var(--bb-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.bb-typing .bb-msg-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.bb-typing .bb-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--bb-muted);
  animation: bb-bounce .9s infinite;
}

.bb-typing .bb-dot:nth-child(2) { animation-delay: .15s; }
.bb-typing .bb-dot:nth-child(3) { animation-delay: .30s; }

@keyframes bb-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* ── Quick Chips ── */
#bb-chat-chips {
  padding: 0 12px 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.bb-chip {
  background: var(--bb-bg);
  border: 1px solid var(--bb-border);
  color: var(--bb-primary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  font-family: "DM Sans", sans-serif;
}

.bb-chip:hover {
  background: var(--bb-primary);
  color: #fff;
  border-color: var(--bb-primary);
}

/* ── Input Row ── */
#bb-chat-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--bb-border);
  flex-shrink: 0;
}

#bb-chat-input {
  flex: 1;
  border: 1.5px solid var(--bb-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-family: "DM Sans", sans-serif;
  color: var(--bb-text);
  outline: none;
  background: var(--bb-bg);
  transition: border-color .2s;
}

#bb-chat-input:focus {
  border-color: var(--bb-primary);
  background: #fff;
}

#bb-chat-input::placeholder {
  color: var(--bb-muted);
}

#bb-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--bb-primary);
  border: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}

#bb-chat-send:hover {
  background: var(--bb-primary-dk);
  transform: scale(1.05);
}

#bb-chat-send:disabled {
  background: var(--bb-border);
  cursor: not-allowed;
  transform: none;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #bb-chat-root {
    bottom: 16px;
    right: 16px;
  }

  #bb-chat-window {
    width: calc(100vw - 32px);
    max-height: 75vh;
    position: fixed;
    bottom: 84px;
    right: 16px;
  }
}