/* ============================================
   BASSLILA Chatbot Widget
   ============================================ */

/* Chat bubble trigger */
.bl-chat-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgb(98, 20, 217);
  border: none;
  cursor: pointer;
  z-index: 999990;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(98, 20, 217, 0.4);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bl-chat-bubble:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(98, 20, 217, 0.55);
}

.bl-chat-bubble svg {
  width: 26px;
  height: 26px;
  fill: #fff;
  transition: transform 0.3s ease;
}

.bl-chat-bubble.open svg.bl-icon-chat {
  display: none;
}

.bl-chat-bubble svg.bl-icon-close {
  display: none;
}

.bl-chat-bubble.open svg.bl-icon-close {
  display: block;
}

/* Chat window */
.bl-chat-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 370px;
  height: 520px;
  background: #0d0d0d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  z-index: 999991;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.bl-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Chat header */
.bl-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(20, 20, 20, 0.95);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.bl-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgb(98, 20, 217);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bl-chat-avatar svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

.bl-chat-header-info {
  flex: 1;
}

.bl-chat-header-title {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.bl-chat-header-status {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bl-chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
}

/* Chat messages area */
.bl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.bl-chat-messages::-webkit-scrollbar {
  width: 4px;
}

.bl-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Messages */
.bl-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.bl-msg-bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  border-bottom-left-radius: 4px;
}

.bl-msg-user {
  align-self: flex-end;
  background: rgb(98, 20, 217);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.bl-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}

.bl-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  animation: bl-bounce 1.2s ease-in-out infinite;
}

.bl-typing-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.bl-typing-dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes bl-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Chat input area */
.bl-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(20, 20, 20, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.bl-chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease;
}

.bl-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.bl-chat-input:focus {
  border-color: rgba(98, 20, 217, 0.5);
}

.bl-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgb(98, 20, 217);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s ease, opacity 0.2s ease;
}

.bl-chat-send:hover {
  background: rgb(118, 40, 237);
}

.bl-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.bl-chat-send svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Powered by */
.bl-chat-footer {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.25);
  background: rgba(20, 20, 20, 0.95);
}

/* Tooltip popup bubble */
.bl-chat-tooltip {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #fff;
  color: #1a1a1a;
  padding: 12px 38px 12px 16px;
  border-radius: 12px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  z-index: 999992;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px) scale(0.9);
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 240px;
}

.bl-chat-tooltip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Tooltip arrow pointing down to the bubble */
.bl-chat-tooltip::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 28px;
  width: 16px;
  height: 16px;
  background: #fff;
  transform: rotate(45deg);
  border-radius: 2px;
  box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1);
}

.bl-chat-tooltip-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: #999;
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}

.bl-chat-tooltip-close:hover {
  color: #333;
  background: rgba(0, 0, 0, 0.06);
}

/* Header close button */
.bl-chat-header-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  cursor: pointer;
  margin-left: auto;
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.bl-chat-header-close:hover {
  background: rgba(220, 38, 38, 0.9);
}

.bl-chat-header-close svg {
  width: 14px;
  height: 14px;
  fill: #fff;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .bl-chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    height: 100vh; /* fallback */
    max-height: none;
    border-radius: 0;
    border: none;
    z-index: 9999999;
  }

  /* When chat is open, lock the body */
  body.bl-chat-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    touch-action: none;
  }

  .bl-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 45px;
    height: 45px;
  }

  .bl-chat-bubble svg {
    width: 21px;
    height: 21px;
  }

  /* Hide bubble when chat is open on mobile */
  .bl-chat-bubble.open {
    display: none;
  }

  .bl-chat-tooltip {
    bottom: 82px;
    right: 16px;
    max-width: 200px;
    font-size: 13px;
  }

  .bl-chat-header {
    padding: 6px 10px;
    gap: 6px;
  }

  /* Add a close button area in header on mobile */
  .bl-chat-footer {
    display: none;
  }

  .bl-chat-header-close {
    background: rgba(220, 38, 38, 0.9);
  }

  .bl-chat-header-close svg {
    width: 14px;
    height: 14px;
    fill: #fff;
  }

  /* Compact text – WhatsApp-like sizing */
  .bl-chat-header-title {
    font-size: 13px;
  }

  .bl-chat-header-status {
    font-size: 10px;
  }

  .bl-chat-avatar {
    width: 26px;
    height: 26px;
  }

  .bl-chat-avatar svg {
    width: 13px;
    height: 13px;
  }

  .bl-chat-messages {
    padding: 11px 10px;
    gap: 8px;
  }

  .bl-msg {
    font-size: 13px;
    line-height: 1.4;
    padding: 6px 10px;
    max-width: 85%;
  }

  .bl-chat-input {
    font-size: 13px;
    padding: 6px 10px;
  }

  .bl-chat-send {
    width: 36px;
    height: 36px;
  }

  .bl-chat-send svg {
    width: 16px;
    height: 16px;
  }

  .bl-chat-input-area {
    padding: 8px 10px;
  }

  .bl-chat-footer {
    font-size: 9px;
    padding: 4px;
  }
}
