/**
 * Barista2Go Chatbot — Widget Styles
 * Pairs with chatbot.js v6.0.0
 * Brand variables: --bg #fff, --bgs #fbf6ee, --h #9C3A0F, --ac #B14312, --acs #d96838
 */

#b2g-chatbot-root,
#b2g-chatbot-root *,
#b2g-chatbot-root *::before,
#b2g-chatbot-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ═══════════════════════ Launcher button ═══════════════════════ */

#b2g-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 8px 28px rgba(40, 30, 20, 0.18), 0 4px 12px rgba(177, 67, 18, 0.15);
  cursor: pointer;
  z-index: 999998;
  padding: 0;
  overflow: hidden;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s;
}

#b2g-launcher:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 12px 36px rgba(40, 30, 20, 0.25), 0 6px 16px rgba(177, 67, 18, 0.25);
}

#b2g-launcher:active {
  transform: translateY(-1px) scale(1.02);
}

#b2g-launcher-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.b2g-launcher-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  background: #B14312;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  border: 2px solid #fff;
  pointer-events: none;
}

/* ═══════════════════════ Chat window ═══════════════════════ */

#b2g-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(40, 30, 20, 0.22), 0 8px 24px rgba(177, 67, 18, 0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999999;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s, transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#b2g-chat-window.b2g-open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (max-width: 480px) {
  #b2g-chat-window {
    bottom: 90px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 110px);
  }
  #b2g-launcher {
    bottom: 16px;
    right: 16px;
  }
}

/* ═══════════════════════ Header ═══════════════════════ */

#b2g-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #9C3A0F 0%, #B14312 100%);
  color: #fff;
  flex-shrink: 0;
}

#b2g-chat-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

#b2g-chat-header > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

#b2g-chat-header strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.b2g-status {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  gap: 6px;
}

.b2g-status::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
}

#b2g-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

#b2g-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* ═══════════════════════ Messages area ═══════════════════════ */

#b2g-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: #fbf6ee;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#b2g-messages::-webkit-scrollbar {
  width: 6px;
}

#b2g-messages::-webkit-scrollbar-thumb {
  background: rgba(177, 67, 18, 0.25);
  border-radius: 3px;
}

.b2g-msg {
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: b2g-msg-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

.b2g-msg-user {
  align-self: flex-end;
  background: #B14312;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.b2g-msg-assistant {
  align-self: flex-start;
  background: #fff;
  color: #334155;
  border: 1px solid #e6dcc8;
  border-bottom-left-radius: 4px;
}

/* Thinking indicator */
.b2g-thinking {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 14px 16px !important;
}

.b2g-thinking span {
  width: 7px;
  height: 7px;
  background: #c4a265;
  border-radius: 50%;
  animation: b2g-pulse 1.2s infinite ease-in-out;
}

.b2g-thinking span:nth-child(2) { animation-delay: 0.2s; }
.b2g-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes b2g-pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* ═══════════════════════ Input form ═══════════════════════ */

#b2g-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid #e6dcc8;
  flex-shrink: 0;
}

#b2g-input {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid #e6dcc8;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  background: #fbf6ee;
  color: #334155;
  transition: border-color 0.2s, background 0.2s;
}

#b2g-input:focus {
  border-color: #B14312;
  background: #fff;
}

#b2g-input::placeholder {
  color: #8a7a6c;
}

#b2g-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #B14312;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  flex-shrink: 0;
}

#b2g-send:hover:not(:disabled) {
  background: #c95520;
  transform: scale(1.05);
}

#b2g-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#b2g-send svg {
  margin-left: -2px; /* Optical centering for the send arrow */
}