/* BrandBrahma AI Chatbot Styles */
/* Version 1.0.0 */

:root {
  --bb-accent: #7B2FBE;
  --bb-accent-dark: #5a1f94;
  --bb-accent-light: #f3e8ff;
  --bb-white: #ffffff;
  --bb-gray-50: #f9fafb;
  --bb-gray-100: #f3f4f6;
  --bb-gray-200: #e5e7eb;
  --bb-gray-400: #9ca3af;
  --bb-gray-600: #4b5563;
  --bb-gray-700: #374151;
  --bb-gray-900: #111827;
  --bb-shadow: 0 25px 60px rgba(0,0,0,0.18), 0 8px 20px rgba(123,47,190,0.12);
  --bb-radius: 20px;
  --bb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  --bb-z: 999999;
}

/* Wrapper */
#bb-chatbot-wrapper {
  position: fixed;
  bottom: 24px;
  z-index: var(--bb-z);
  font-family: var(--bb-font);
}

#bb-chatbot-wrapper.bb-position-right { right: 24px; }
#bb-chatbot-wrapper.bb-position-left  { left: 24px; }

/* =====================
   TOGGLE BUTTON
   ===================== */
#bb-chat-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bb-accent) 0%, #4A90D9 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(123,47,190,0.4), 0 2px 8px rgba(0,0,0,0.15);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  outline: none;
}

#bb-chat-toggle:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 8px 30px rgba(123,47,190,0.5), 0 4px 12px rgba(0,0,0,0.2);
}

#bb-chat-toggle:active { transform: scale(0.96); }

.bb-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  animation: bb-pulse 2s infinite;
}

@keyframes bb-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* =====================
   CHAT WINDOW
   ===================== */
#bb-chat-window {
  position: absolute;
  bottom: 76px;
  width: 380px;
  max-height: 620px;
  background: var(--bb-white);
  border-radius: var(--bb-radius);
  box-shadow: var(--bb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: bb-slide-up 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(123,47,190,0.1);
}

.bb-position-right #bb-chat-window { right: 0; }
.bb-position-left  #bb-chat-window { left: 0; }

@keyframes bb-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =====================
   HEADER
   ===================== */
.bb-chat-header {
  background: linear-gradient(135deg, var(--bb-accent) 0%, #4A90D9 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.bb-bot-avatar {
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.4);
  overflow: hidden;
  padding: 4px;
}

.bb-bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: brightness(0) invert(1);
}

.bb-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bb-bot-name {
  color: white;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

.bb-bot-status {
  color: rgba(255,255,255,0.85);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.bb-status-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  animation: bb-blink 2s infinite;
}

@keyframes bb-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.bb-header-actions {
  display: flex;
  gap: 6px;
}

.bb-header-actions button {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  outline: none;
}

.bb-header-actions button:hover { background: rgba(255,255,255,0.28); }

/* =====================
   QUICK BAR
   ===================== */
.bb-quick-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bb-gray-50);
  border-bottom: 1px solid var(--bb-gray-200);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.bb-quick-bar::-webkit-scrollbar { display: none; }

.bb-quick-btn {
  background: white;
  border: 1px solid var(--bb-gray-200);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--bb-gray-700);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  font-family: var(--bb-font);
  outline: none;
}

.bb-quick-btn:hover {
  background: var(--bb-accent-light);
  border-color: var(--bb-accent);
  color: var(--bb-accent);
}

/* =====================
   MESSAGES AREA
   ===================== */
.bb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 200px;
  max-height: 350px;
  scroll-behavior: smooth;
}

.bb-messages::-webkit-scrollbar { width: 4px; }
.bb-messages::-webkit-scrollbar-track { background: transparent; }
.bb-messages::-webkit-scrollbar-thumb { background: var(--bb-gray-200); border-radius: 4px; }

/* Message bubbles */
.bb-msg {
  display: flex;
  gap: 8px;
  max-width: 100%;
  animation: bb-msg-in 0.25s ease-out;
}

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

.bb-msg.bb-user {
  flex-direction: row-reverse;
}

.bb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bb-accent), #4A90D9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  margin-top: 2px;
}

.bb-msg.bb-user .bb-msg-avatar {
  background: var(--bb-gray-400);
}

.bb-msg-bubble {
  max-width: calc(100% - 44px);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--bb-gray-900);
}

.bb-msg.bb-bot .bb-msg-bubble {
  background: var(--bb-gray-100);
  border-bottom-left-radius: 4px;
}

.bb-msg.bb-user .bb-msg-bubble {
  background: linear-gradient(135deg, var(--bb-accent), #4A90D9);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Links inside bot messages */
.bb-msg.bb-bot .bb-msg-bubble a {
  color: var(--bb-accent);
  text-decoration: underline;
  font-weight: 500;
}

/* Markdown-like formatting */
.bb-msg-bubble strong { font-weight: 700; }
.bb-msg-bubble em { font-style: italic; }
.bb-msg-bubble ul, .bb-msg-bubble ol {
  margin: 6px 0 4px 16px;
  padding: 0;
}
.bb-msg-bubble li { margin: 3px 0; }
.bb-msg-bubble p { margin: 0 0 6px; }
.bb-msg-bubble p:last-child { margin-bottom: 0; }

/* Timestamp */
.bb-msg-time {
  font-size: 10px;
  color: var(--bb-gray-400);
  margin-top: 3px;
  padding: 0 6px;
}

.bb-msg.bb-user .bb-msg-time { text-align: right; }

/* =====================
   TYPING INDICATOR
   ===================== */
.bb-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px 8px;
  flex-shrink: 0;
}

.bb-typing-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bb-accent), #4A90D9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.bb-typing-dots {
  background: var(--bb-gray-100);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.bb-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--bb-gray-400);
  border-radius: 50%;
  animation: bb-dot-bounce 1.2s infinite;
}

.bb-typing-dots span:nth-child(1) { animation-delay: 0s; }
.bb-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.bb-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bb-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* =====================
   SUGGESTIONS
   ===================== */
.bb-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--bb-gray-200);
  flex-shrink: 0;
}

.bb-suggestion {
  background: white;
  border: 1px solid var(--bb-gray-200);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  color: var(--bb-accent);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--bb-font);
  outline: none;
  font-weight: 500;
}

.bb-suggestion:hover {
  background: var(--bb-accent);
  color: white;
  border-color: var(--bb-accent);
}

/* =====================
   INPUT AREA
   ===================== */
.bb-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--bb-gray-200);
  background: white;
  flex-shrink: 0;
}

#bb-user-input {
  flex: 1;
  border: 1.5px solid var(--bb-gray-200);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: var(--bb-font);
  color: var(--bb-gray-900);
  resize: none;
  outline: none;
  transition: border 0.2s;
  background: var(--bb-gray-50);
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
}

#bb-user-input:focus {
  border-color: var(--bb-accent);
  background: white;
}

#bb-user-input::placeholder { color: var(--bb-gray-400); }

#bb-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--bb-accent), #4A90D9);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  outline: none;
  flex-shrink: 0;
}

#bb-send-btn:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 4px 12px rgba(123,47,190,0.4); }
#bb-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* =====================
   FOOTER
   ===================== */
.bb-chat-footer {
  text-align: center;
  font-size: 10.5px;
  color: var(--bb-gray-400);
  padding: 6px 12px 8px;
  background: var(--bb-gray-50);
  border-top: 1px solid var(--bb-gray-100);
  flex-shrink: 0;
}

.bb-chat-footer a {
  color: var(--bb-accent);
  text-decoration: none;
  font-weight: 600;
}

/* =====================
   EMPTY STATE
   ===================== */
.bb-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
  color: var(--bb-gray-400);
  gap: 10px;
}

.bb-empty-state svg { opacity: 0.3; }
.bb-empty-state p { font-size: 13px; margin: 0; }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 480px) {
  #bb-chat-window {
    width: calc(100vw - 24px);
    max-height: 80vh;
    bottom: 72px;
  }

  .bb-position-right #bb-chat-window { right: 0; }
  .bb-position-left  #bb-chat-window { left: 0; }

  #bb-chatbot-wrapper {
    bottom: 16px;
  }
  .bb-position-right #bb-chatbot-wrapper,
  #bb-chatbot-wrapper.bb-position-right { right: 16px; }
  .bb-position-left  #bb-chatbot-wrapper,
  #bb-chatbot-wrapper.bb-position-left  { left: 16px; }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  #bb-chat-window {
    background: #1f2937;
    border-color: rgba(255,255,255,0.08);
  }
  .bb-msg.bb-bot .bb-msg-bubble {
    background: #374151;
    color: #f9fafb;
  }
  .bb-msg.bb-bot .bb-msg-bubble a { color: #a78bfa; }
  #bb-user-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  #bb-user-input:focus { border-color: var(--bb-accent); background: #374151; }
  #bb-user-input::placeholder { color: #9ca3af; }
  .bb-quick-bar { background: #374151; border-color: #4b5563; }
  .bb-quick-btn { background: #4b5563; border-color: #6b7280; color: #d1d5db; }
  .bb-input-area { background: #1f2937; border-color: #374151; }
  .bb-chat-footer { background: #111827; border-color: #374151; color: #6b7280; }
  .bb-suggestions { border-color: #374151; }
  .bb-suggestion { background: #374151; border-color: #4b5563; }
  .bb-quick-bar { border-color: #374151; }
  .bb-typing-dots { background: #374151; }
}

/* =====================
   BRAHMA LOGO AVATAR
   ===================== */
.bb-msg-avatar-logo {
  background: white !important;
  border: 2px solid var(--bb-gray-200) !important;
  padding: 2px !important;
  overflow: hidden;
}

.bb-msg-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: none;
}

/* Toggle button - no logo, clean style */
#bb-chat-toggle img {
  pointer-events: none;
}
