/* ============================================
   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: 10000000;
  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: 10000001;
  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: 20px;
  height: 20px;
  fill: #fff;
}

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

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

.bl-chat-header-status {
  font-size: 12px;
  color: #4ade80;
  line-height: 1.3;
}

.bl-chat-header-close {
  background: #e53e3e;
  border: none;
  cursor: pointer;
  padding: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.bl-chat-header-close:hover {
  background: #c53030;
}

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

.bl-chat-header-close:hover svg {
  fill: #fff;
}

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

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

.bl-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

/* Message bubbles */
.bl-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: blMsgIn 0.3s ease;
}

.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;
}

@keyframes blMsgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Typing indicator */
.bl-typing {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

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

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

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

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

/* Input area */
.bl-chat-input-area {
  display: flex;
  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-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

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

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

.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, transform 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.bl-chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

/* Footer */
.bl-chat-footer {
  text-align: center;
  padding: 8px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.25);
  flex-shrink: 0;
}

/* Tooltip */
.bl-chat-tooltip {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #1a1a1a;
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  z-index: 9999999;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 220px;
  cursor: pointer;
}

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

.bl-chat-tooltip-close {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #333;
  border: none;
  color: #fff;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}

/* Body lock when chat is open on mobile */
body.bl-chat-open {
  overflow: hidden !important;
  position: fixed !important;
  width: 100% !important;
  height: 100% !important;
}

/* ============================================
   Mobile responsive
   ============================================ */
@media (max-width: 480px) {
  .bl-chat-bubble {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }

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

  .bl-chat-window {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }

  /* Push header below notch / status bar */
  .bl-chat-header {
    padding-top: calc(env(safe-area-inset-top, 0px) + 18px);
    padding-bottom: 12px;
    z-index: 10;
  }

  .bl-chat-header-close svg {
    width: 26px;
    height: 26px;
  }

  /* Hide powered-by footer on mobile */
  .bl-chat-footer {
    display: none;
  }

  /* Reduce all fonts by 20% */
  .bl-chat-header-title {
    font-size: 11px;
  }

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

  .bl-msg {
    font-size: 11px;
    padding: 8px 11px;
    border-radius: 13px;
  }

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

  .bl-chat-input-area {
    padding: 7px 10px;
    gap: 6px;
  }

  .bl-chat-send {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

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

  .bl-chat-messages {
    padding: 12px 12px 6px;
    gap: 8px;
  }

  .bl-chat-tooltip {
    bottom: 78px;
    right: 16px;
    max-width: 200px;
    font-size: 13px;
    padding: 10px 14px;
  }

  .bl-typing {
    padding: 8px 12px;
    border-radius: 12px;
  }

  .bl-typing-dot {
    width: 5px;
    height: 5px;
  }
}
