/**
 * BAPU 24/7 AI Guide - NextSens Technology Ecosystem
 * Exact 1:1 Light Theme Parity with BAPU AI on open.nextsenstech.com
 */

:root {
  --bapu-primary: #243fb5;
  --bapu-primary-hover: #1b2f8a;
  --bapu-accent: #146654;
  --bapu-bg: #ffffff;
  --bapu-surface: #f8fafc;
  --bapu-border: #e2e8f0;
  --bapu-text: #0f172a;
  --bapu-muted: #64748b;
  --bapu-user-bubble: #243fb5;
  --bapu-bot-bubble: #ffffff;
  --bapu-gold: #d4af37;
  --bapu-gold-light: #f5de78;
  --bapu-blue: #243fb5;
  --bapu-blue-dark: #1b2f8a;
  --bapu-navy: #0b1120;
}

/* Floating Launcher Button */
.bapu-launcher,
.bapu-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999990;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #243fb5 0%, #172554 100%);
  color: #ffffff;
  border: 0;
  border-radius: 9999px;
  padding: 10px 18px 10px 12px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 25px -5px rgba(36, 63, 181, 0.4), 0 8px 10px -6px rgba(36, 63, 181, 0.3);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  user-select: none;
}

.bapu-launcher:hover,
.bapu-launcher-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 28px -5px rgba(36, 63, 181, 0.5), 0 10px 10px -5px rgba(36, 63, 181, 0.4);
}

.bapu-launcher-avatar-wrap,
.bapu-launcher-avatar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  max-width: 36px;
  min-height: 36px;
  max-height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 18px;
  flex-shrink: 0;
  border: 0 !important;
}

.bapu-launcher-avatar-wrap img,
.bapu-launcher-avatar img,
.bapu-avatar-img {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
  box-sizing: border-box !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
  border: 0 !important;
}

.bapu-launcher-close-icon {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.bapu-online-pulse,
.bapu-launcher-beacon {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 9px;
  height: 9px;
  background: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 4px #22c55e;
}

.bapu-launcher-label,
.bapu-launcher-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.bapu-launcher-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bapu-launcher-name,
.bapu-launcher-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.bapu-online-badge {
  display: none;
}

.bapu-launcher-sub-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}

.bapu-launcher-icon {
  display: none;
}

.bapu-launcher-tag,
.bapu-launcher-subtitle {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.9;
  color: #e0e7ff;
}

/* Chat Window Modal */
.bapu-chat-window {
  position: fixed;
  bottom: 84px;
  right: 24px;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 110px));
  z-index: 999991;
  background: var(--bapu-bg);
  border: 1px solid var(--bapu-border);
  border-radius: 16px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.25), 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Chat Header */
.bapu-header,
.bapu-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(135deg, #1e3a8a 0%, #243fb5 100%);
  color: #ffffff;
  flex-shrink: 0;
  user-select: none;
  border-bottom: 0;
}

.bapu-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bapu-header-avatar,
.bapu-header-avatar-wrap {
  position: relative;
  width: 40px;
  height: 40px;
  min-width: 40px;
  max-width: 40px;
  min-height: 40px;
  max-height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  border: 0 !important;
}

.bapu-header-avatar img,
.bapu-header-avatar-wrap img {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  min-height: 40px !important;
  max-height: 40px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
  border: 0 !important;
}

.bapu-header-info {
  line-height: 1.2;
}

.bapu-header-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bapu-header-info h2,
.bapu-header-name {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  line-height: 1.2;
}

.bapu-header-badge {
  display: none;
}

.bapu-header-info p,
.bapu-header-sub {
  font-size: 11px;
  margin: 2px 0 0;
  opacity: 0.95;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e0e7ff;
}

.bapu-header-info .dot,
.bapu-header-sub .dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  margin-right: 4px;
}

.bapu-header-actions,
.bapu-header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bapu-header-btn,
.bapu-btn-icon {
  background: rgba(255, 255, 255, 0.15);
  border: 0;
  color: #ffffff;
  border-radius: 8px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s ease;
  padding: 0;
}

.bapu-header-btn:hover,
.bapu-btn-icon:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}

/* Messages Area */
.bapu-messages,
.bapu-chat-messages {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bapu-surface);
  scroll-behavior: smooth;
}

.bapu-messages::-webkit-scrollbar,
.bapu-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.bapu-messages::-webkit-scrollbar-thumb,
.bapu-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.bapu-msg,
.bapu-msg-row {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: bapuFadeIn 0.2s ease;
  align-items: flex-start;
}

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

.bapu-msg.user,
.bapu-msg-row.bapu-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.bapu-msg.bot,
.bapu-msg-row.bapu-msg-bot {
  align-self: flex-start;
}

.bapu-msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  max-width: 28px;
  min-height: 28px;
  max-height: 28px;
  border-radius: 50%;
  background: #dbeafe;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  overflow: hidden;
  border: 0 !important;
}

.bapu-msg-avatar img {
  width: 28px !important;
  height: 28px !important;
  min-width: 28px !important;
  max-width: 28px !important;
  min-height: 28px !important;
  max-height: 28px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  display: block !important;
  border: 0 !important;
}

.bapu-bubble {
  padding: 11px 15px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--bapu-text);
  word-break: break-word;
}

.bapu-msg.user .bapu-bubble,
.bapu-msg-user .bapu-bubble {
  background: var(--bapu-user-bubble);
  color: #ffffff;
  border-bottom-right-radius: 3px;
  border: 0;
  box-shadow: 0 1px 2px rgba(36, 63, 181, 0.2);
}

.bapu-msg.bot .bapu-bubble,
.bapu-msg-bot .bapu-bubble {
  background: #ffffff;
  border: 1px solid var(--bapu-border);
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  color: var(--bapu-text);
}

.bapu-bubble p {
  margin: 0 0 8px;
}

.bapu-bubble p:last-child {
  margin-bottom: 0;
}

.bapu-bubble strong {
  color: inherit;
  font-weight: 650;
}

.bapu-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
  font-family: monospace;
  color: inherit;
}

.bapu-msg.user .bapu-bubble code,
.bapu-msg-user .bapu-bubble code {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.bapu-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}

.bapu-bubble li {
  margin-bottom: 3px;
}

/* Action Cards / Action Buttons inside Bubbles (Matching Image 1) */
.bapu-actions-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.bapu-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  width: 100%;
  box-sizing: border-box;
}

.bapu-action-btn.primary {
  background: #243fb5;
  color: #ffffff;
}

.bapu-action-btn.primary:hover {
  background: #1b2f8a;
  transform: translateY(-1px);
}

.bapu-action-btn.secondary {
  background: #ffffff;
  color: #243fb5;
  border-color: #cbd5e1;
}

.bapu-action-btn.secondary:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

/* Manual Card for Official Documentation */
.bapu-manual-card {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bapu-manual-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #243fb5;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bapu-manual-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.bapu-manual-desc {
  font-size: 11.5px;
  color: #475569;
  line-height: 1.4;
}

.bapu-manual-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.bapu-manual-btn {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.bapu-manual-btn-download {
  background: #243fb5;
  color: #ffffff;
  flex: 1;
}

.bapu-manual-btn-download:hover {
  background: #1b2f8a;
}

.bapu-manual-btn-preview {
  background: #ffffff;
  color: #243fb5;
  border: 1px solid #cbd5e1;
}

.bapu-manual-btn-preview:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

/* Store Product Cards */
.bapu-product-card {
  margin-top: 8px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.bapu-product-card-title {
  font-weight: 700;
  color: #0f172a;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bapu-product-price {
  color: #15803d;
  font-weight: 700;
}

.bapu-card-links {
  margin-top: 8px;
  display: flex;
  gap: 6px;
}

.bapu-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #f1f5f9;
  color: #243fb5;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
}

.bapu-card-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
}

/* Suggestion Chips (Matching Image 1) */
.bapu-suggestions,
.bapu-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px 6px;
  background: var(--bapu-surface);
  border-top: 1px solid var(--bapu-border);
  max-height: 96px;
  overflow-y: auto;
}

.bapu-suggestions::-webkit-scrollbar,
.bapu-chips-row::-webkit-scrollbar {
  width: 4px;
}
.bapu-suggestions::-webkit-scrollbar-thumb,
.bapu-chips-row::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 2px;
}

.bapu-chip {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 9999px;
  padding: 5px 12px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  user-select: none;
}

.bapu-chip:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
}

/* Typing / Searching Indicator */
.bapu-thinking-row,
.bapu-typing {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  align-items: center;
}

.bapu-dot-spinner,
.bapu-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.bapu-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: bapuPulse 1.2s infinite ease-in-out;
}

.bapu-dot:nth-child(2) { animation-delay: 0.2s; }
.bapu-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bapuPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; }
}

/* Input Bar & Footer (Matching Image 1) */
.bapu-input-bar,
.bapu-chat-footer {
  padding: 12px 14px 6px;
  background: #ffffff;
  border-top: 1px solid var(--bapu-border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.bapu-input-form {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.bapu-input,
.bapu-input-field {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  background: #ffffff;
  color: var(--bapu-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bapu-input:focus,
.bapu-input-field:focus {
  border-color: var(--bapu-primary);
  box-shadow: 0 0 0 3px rgba(36, 63, 181, 0.15);
}

.bapu-send-btn {
  background: var(--bapu-primary);
  color: #ffffff;
  border: 0;
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
  flex-shrink: 0;
  font-size: 15px;
}

.bapu-send-btn:hover {
  background: var(--bapu-primary-hover);
}

.bapu-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bapu-footer-branding {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9.5px;
  color: #64748b;
  padding: 0 2px 4px;
}

.bapu-footer-branding a {
  color: #243fb5;
  text-decoration: none;
}

.bapu-footer-branding a:hover {
  text-decoration: underline;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .bapu-chat-window {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: 0;
  }
  .bapu-launcher,
  .bapu-launcher-btn {
    bottom: 16px;
    right: 16px;
  }
}
