/* =========================================================
   BJS Construction AI Chatbot Widget Styles
   Designed for B.J.S. Construction & Suppliers Pvt. Ltd.
   Developer: Sunil Dhital
========================================================= */

/* Floating Launcher Button */
.bjs-chatbot-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a8a 0%, #0f2b5c 50%, #0a192f 100%);
  box-shadow: 0 8px 24px rgba(15, 43, 92, 0.5), 0 0 15px rgba(212, 175, 55, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d4af37;
  cursor: pointer;
  z-index: 999990;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid #d4af37;
  animation: bjs-pulse-glow 2.5s infinite;
  user-select: none;
}

.bjs-chatbot-launcher:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 12px 30px rgba(15, 43, 92, 0.7), 0 0 20px rgba(212, 175, 55, 0.6);
  border-color: #f59e0b;
  color: #ffffff;
}

.bjs-chatbot-launcher svg,
.bjs-chatbot-launcher i {
  width: 28px;
  height: 28px;
  font-size: 26px;
  transition: transform 0.3s ease;
}

.bjs-chatbot-launcher .bjs-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #10b981;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #ffffff;
}

.bjs-chatbot-tooltip {
  position: absolute;
  right: 74px;
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.bjs-chatbot-launcher:hover .bjs-chatbot-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(-4px);
}

@keyframes bjs-pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  }
  70% {
    box-shadow: 0 0 0 16px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Chatbot Window Container */
.bjs-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 390px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: #0f172a;
  color: #f8fafc;
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 999995;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92) translateY(20px);
  transform-origin: bottom right;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.bjs-chat-window.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

/* Chat Header */
.bjs-chat-header {
  background: linear-gradient(135deg, #0a192f 0%, #0f2b5c 50%, #1e3a8a 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
}

.bjs-chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bjs-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d4af37 0%, #f59e0b 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0a192f;
  font-size: 20px;
  position: relative;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.bjs-chat-avatar .bjs-avatar-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
}

.bjs-chat-header-text h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
  line-height: 1.2;
}

.bjs-chat-header-text p {
  margin: 2px 0 0 0;
  font-size: 11px;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bjs-chat-header-text .status-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
  animation: bjs-blink 1.8s infinite;
}

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

.bjs-chat-header-actions {
  display: flex;
  gap: 8px;
}

.bjs-chat-header-btn {
  background: rgba(255, 255, 255, 0.07);
  border: none;
  color: #cbd5e1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.bjs-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Quick Suggestion Chips */
.bjs-chat-chips {
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.bjs-chat-chips::-webkit-scrollbar {
  display: none;
}

.bjs-chat-chip {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  font-size: 11.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 16px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.bjs-chat-chip:hover {
  background: #f59e0b;
  color: #0f172a;
  font-weight: 600;
  transform: translateY(-1px);
}

/* Messages Body */
.bjs-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #090d16;
  scroll-behavior: smooth;
}

.bjs-chat-body::-webkit-scrollbar {
  width: 5px;
}

.bjs-chat-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

/* Message Bubble */
.bjs-message {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: bjs-fade-in 0.25s ease-out;
}

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

.bjs-message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bjs-message.assistant {
  align-self: flex-start;
}

.bjs-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 2px;
}

.bjs-msg-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.bjs-message.user .bjs-msg-content {
  background: linear-gradient(135deg, #1e3a8a 0%, #0f2b5c 100%);
  color: #ffffff;
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-bottom-right-radius: 4px;
}

.bjs-message.assistant .bjs-msg-content {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom-left-radius: 4px;
}

.bjs-msg-content strong,
.bjs-msg-content b {
  color: #fbbf24;
  font-weight: 600;
}

.bjs-msg-content a {
  color: #60a5fa;
  text-decoration: underline;
}

.bjs-msg-time {
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
  text-align: right;
}

.bjs-message.assistant .bjs-msg-time {
  text-align: left;
}

/* Typing Indicator */
.bjs-typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: #1e293b;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.bjs-typing-dot {
  width: 7px;
  height: 7px;
  background: #f59e0b;
  border-radius: 50%;
  animation: bjs-bounce 1.4s infinite ease-in-out both;
}

.bjs-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.bjs-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.bjs-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes bjs-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Footer / Input Area */
.bjs-chat-footer {
  padding: 12px 14px;
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.bjs-chat-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 25px;
  padding: 4px 6px 4px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.bjs-chat-input-form:focus-within {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.bjs-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #f8fafc;
  font-size: 13.5px;
  outline: none;
  padding: 8px 0;
}

.bjs-chat-input::placeholder {
  color: #64748b;
  font-size: 12.5px;
}

.bjs-chat-send-btn {
  background: linear-gradient(135deg, #d4af37 0%, #f59e0b 100%);
  border: none;
  color: #0a192f;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(212, 175, 55, 0.4);
}

.bjs-chat-send-btn:hover {
  transform: scale(1.06);
}

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

.bjs-chat-powered {
  margin-top: 6px;
  text-align: center;
  font-size: 10px;
  color: #64748b;
  letter-spacing: 0.2px;
}

.bjs-chat-powered span {
  color: #f59e0b;
  font-weight: 600;
}

/* Backdrop for Mobile */
.bjs-chat-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999990;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.bjs-chat-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Mobile Responsive Optimization (< 640px) */
@media (max-width: 640px) {
  .bjs-chat-window {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 85vh !important;
    height: 85dvh !important;
    max-height: 85dvh !important;
    border-radius: 22px 22px 0 0 !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.5) !important;
    transform: translateY(100%) !important;
    transform-origin: bottom center !important;
    transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 999995 !important;
  }

  .bjs-chat-window.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .bjs-chat-header {
    padding: 14px 16px !important;
    border-top-left-radius: 22px;
    border-top-right-radius: 22px;
  }

  .bjs-chat-body {
    padding: 12px 14px !important;
    gap: 12px !important;
  }

  .bjs-message {
    max-width: 92% !important;
  }

  .bjs-msg-content {
    font-size: 13px !important;
    padding: 9px 13px !important;
  }

  .bjs-chat-chips {
    padding: 8px 12px !important;
    -webkit-overflow-scrolling: touch;
  }

  .bjs-chat-chip {
    font-size: 11px !important;
    padding: 4px 10px !important;
  }

  .bjs-chat-footer {
    padding: 8px 12px max(14px, env(safe-area-inset-bottom, 14px)) !important;
  }

  .bjs-chatbot-launcher {
    bottom: max(18px, env(safe-area-inset-bottom, 18px)) !important;
    right: 18px !important;
    width: 54px !important;
    height: 54px !important;
  }

  .bjs-chatbot-tooltip {
    display: none !important;
  }

  /* Hide floating buttons when chat sheet is open on mobile */
  body.bjs-chat-opened .bjs-chatbot-launcher {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
  }

  body.bjs-chat-opened .whatsapp-float {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
  }

  .whatsapp-float {
    left: 18px !important;
    bottom: max(18px, env(safe-area-inset-bottom, 18px)) !important;
    width: 48px !important;
    height: 48px !important;
    font-size: 24px !important;
  }
}
