/* =============================================
   BULKIE AI CHAT WIDGET
   ============================================= */

/* Floating Button */
#bulkie-chat-btn {
  position: fixed;
  bottom: 28px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  right: 28px;
  z-index: 10000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366, #1aaa50);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(37, 213, 102, 0.45);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: bulkie-pulse-ring 3s ease-out infinite;
}

#bulkie-chat-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 6px 32px rgba(37, 213, 102, 0.6);
}

#bulkie-chat-btn.open {
  background: linear-gradient(135deg, #4a5568, #2d3748);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: none;
}

@keyframes bulkie-pulse-ring {
  0%   { box-shadow: 0 4px 24px rgba(37,213,102,0.45), 0 0 0 0 rgba(37,213,102,0.4); }
  70%  { box-shadow: 0 4px 24px rgba(37,213,102,0.45), 0 0 0 14px rgba(37,213,102,0); }
  100% { box-shadow: 0 4px 24px rgba(37,213,102,0.45), 0 0 0 0 rgba(37,213,102,0); }
}

/* Notification badge */
#bulkie-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  font-size: 10px;
  color: #fff;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #12151c;
}

/* Chat Window */
#bulkie-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 10001;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 130px);
  /* Always dark — never inherits page theme */
  background: #12151c;
  border: 1px solid rgba(34, 197, 94, 0.18);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: bottom right;
  color: #e6edf3;
}

#bulkie-chat-window.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#bulkie-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(99,102,241,0.08));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.bulkie-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366, #1aaa50);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  position: relative;
}

.bulkie-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #25D366;
  border-radius: 50%;
  border: 2px solid #12151c;
}

.bulkie-header-info h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #e6edf3;
  margin: 0;
  line-height: 1.2;
}

.bulkie-header-info span {
  font-size: 0.72rem;
  color: #4ade80;
  font-weight: 500;
}

#bulkie-close-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#bulkie-close-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #e6edf3;
}

/* Messages Area */
#bulkie-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  background: #0d1117;
}

#bulkie-messages::-webkit-scrollbar { width: 4px; }
#bulkie-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* Message Bubbles */
.bulkie-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: bulkie-msg-in 0.25s ease;
}

@keyframes bulkie-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bulkie-msg.user { align-self: flex-end; align-items: flex-end; }
.bulkie-msg.bot  { align-self: flex-start; align-items: flex-start; }

.bulkie-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.bulkie-msg.user .bulkie-bubble {
  background: linear-gradient(135deg, #25D366, #1aaa50);
  color: #000;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.bulkie-msg.bot .bulkie-bubble {
  background: #1c2333;
  color: #e6edf3;
  border: 1px solid rgba(255,255,255,0.07);
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.bulkie-typing .bulkie-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.bulkie-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6b7280;
  animation: bulkie-bounce 1.2s ease-in-out infinite;
}

.bulkie-dot:nth-child(2) { animation-delay: 0.2s; }
.bulkie-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bulkie-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* Quick Replies */
#bulkie-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 16px 8px;
  flex-shrink: 0;
}

.bulkie-qr {
  background: transparent;
  border: 1px solid rgba(37,213,102,0.3);
  color: #25D366;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.bulkie-qr:hover {
  background: rgba(37,213,102,0.1);
  border-color: #25D366;
}

/* Input Area */
#bulkie-input-area {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: #12151c;
  flex-shrink: 0;
}

#bulkie-input {
  flex: 1;
  background: #1c2333;
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 16px;
  color: #e6edf3;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 1.5;
  transition: border-color 0.2s;
}

#bulkie-input:focus {
  border-color: rgba(34,197,94,0.45);
  background: #161b27;
}

#bulkie-input::placeholder {
  color: #4b5563;
}

#bulkie-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #25D366, #1aaa50);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  flex-shrink: 0;
  transition: all 0.2s;
}

#bulkie-send-btn:hover { background: #1db954; transform: scale(1.05); }
#bulkie-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Markdown-like formatting */
.bulkie-bubble strong { font-weight: 700; }
.bulkie-bubble em     { font-style: italic; }
.bulkie-bubble code   {
  background: rgba(34,197,94,0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8em;
  color: #4ade80;
}
.bulkie-bubble ul { padding-left: 1.2em; margin: 6px 0; }
.bulkie-bubble li { margin-bottom: 3px; }

/* Light mode overrides — no longer needed, widget is always light */
/* (kept as empty block to avoid breaking any future references) */

/* Mobile */
@media (max-width: 480px) {
  #bulkie-chat-btn {
    right: 16px;
    bottom: 20px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    width: 52px;
    height: 52px;
  }
  #bulkie-chat-window {
    left: 12px;
    right: 12px;
    bottom: 84px;
    bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
    height: calc(100vh - 110px);
    height: calc(100vh - 110px - env(safe-area-inset-bottom, 0px));
    max-height: calc(100vh - 110px);
    max-height: calc(100vh - 110px - env(safe-area-inset-bottom, 0px));
    transform-origin: bottom right;
  }
}
