/**
 * GBC AI Solutions - AI Chatbot Stylesheet (css/chatbot.css)
 * Modern, glassmorphism floating AI conversational assistant.
 */

:root {
  --cb-navy: #0B0C45;
  --cb-navy-dark: #060726;
  --cb-blue: #2B3B94;
  --cb-cyan: #00D2FF;
  --cb-cyan-dark: #00A6CC;
  --cb-bg: #FFFFFF;
  --cb-surface: #F8FAFC;
  --cb-border: #E2E8F0;
  --cb-text: #0F172A;
  --cb-text-muted: #64748B;
  --cb-user-bubble: linear-gradient(135deg, #0B0C45 0%, #2B3B94 100%);
  --cb-bot-bubble: #F1F5F9;
  --cb-shadow: 0 20px 48px -8px rgba(11, 12, 69, 0.28), 0 8px 20px -4px rgba(11, 12, 69, 0.12);
  --cb-font: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================================================
   1. FLOATING LAUNCHER & TOOLTIP
   ========================================================================== */

#gbc-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  outline: none;
  font-family: var(--cb-font);
}

.chat-launcher-btn {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0B0C45 0%, #2B3B94 70%, #00D2FF 100%);
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 10px 28px rgba(11, 12, 69, 0.35), 0 0 0 1px rgba(0, 210, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
}

.chat-launcher-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 34px rgba(11, 12, 69, 0.45), 0 0 20px rgba(0, 210, 255, 0.6);
}

.chat-launcher-btn:active {
  transform: scale(0.96);
}

/* Glowing pulse ring */
.chat-launcher-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(0, 210, 255, 0.6);
  animation: cbPulse 2.4s cubic-bezier(0.25, 1, 0.5, 1) infinite;
  pointer-events: none;
}

@keyframes cbPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.chat-launcher-icon-open,
.chat-launcher-icon-close {
  position: absolute;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.chat-launcher-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.7);
}

#gbc-chatbot-widget.is-open ~ #gbc-chat-launcher .chat-launcher-icon-open,
body.chat-active #gbc-chat-launcher .chat-launcher-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.7);
}

#gbc-chatbot-widget.is-open ~ #gbc-chat-launcher .chat-launcher-icon-close,
body.chat-active #gbc-chat-launcher .chat-launcher-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Unread Badge */
.chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #EF4444;
  color: #FFF;
  font-size: 11px;
  font-weight: 700;
  height: 20px;
  min-width: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #FFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  animation: cbBounce 0.5s ease;
}

@keyframes cbBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Floating Greeting Pill */
.chat-launcher-pill {
  position: absolute;
  right: 74px;
  bottom: 8px;
  background: #FFFFFF;
  color: var(--cb-navy);
  border: 1px solid var(--cb-border);
  box-shadow: 0 8px 24px rgba(11, 12, 69, 0.18);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateX(10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-launcher-pill.is-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.chat-launcher-pill::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 12px;
  height: 12px;
  background: #FFF;
  border-right: 1px solid var(--cb-border);
  border-top: 1px solid var(--cb-border);
}

.chat-pill-spark {
  display: inline-flex;
  color: #00D2FF;
}

.chat-pill-close {
  border: none;
  background: none;
  color: var(--cb-text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 4px;
  line-height: 1;
}

.chat-pill-close:hover {
  color: var(--cb-navy);
}

/* ==========================================================================
   2. MAIN CHATBOT WINDOW
   ========================================================================== */

#gbc-chatbot-widget {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 390px;
  height: 610px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: var(--cb-bg);
  border-radius: 20px;
  box-shadow: var(--cb-shadow);
  border: 1px solid rgba(226, 232, 240, 0.9);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99991;
  font-family: var(--cb-font);
  opacity: 0;
  transform: translateY(24px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

#gbc-chatbot-widget.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ==========================================================================
   3. CHATBOT HEADER
   ========================================================================== */

.chatbot-header {
  background: linear-gradient(135deg, #0B0C45 0%, #171E5A 60%, #2B3B94 100%);
  color: #FFFFFF;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

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

.chatbot-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(0, 210, 255, 0.3));
  border: 1.5px solid rgba(0, 210, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #00D2FF;
}

.chatbot-online-dot {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  background: #10B981;
  border: 2px solid #0B0C45;
  border-radius: 50%;
}

.chatbot-header-info h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.2;
}

.chatbot-badge {
  background: rgba(0, 210, 255, 0.2);
  color: #00D2FF;
  border: 1px solid rgba(0, 210, 255, 0.4);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chatbot-header-info p {
  margin: 2px 0 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

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

.chatbot-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.chatbot-icon-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #FFFFFF;
}

/* ==========================================================================
   4. MESSAGE STREAM
   ========================================================================== */

.chatbot-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--cb-surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chatbot-body::-webkit-scrollbar {
  width: 5px;
}
.chatbot-body::-webkit-scrollbar-thumb {
  background: rgba(11, 12, 69, 0.18);
  border-radius: 4px;
}
.chatbot-body::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-date-divider {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--cb-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 4px 0;
  position: relative;
}

.chatbot-date-divider::before,
.chatbot-date-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 35%;
  height: 1px;
  background: var(--cb-border);
}
.chatbot-date-divider::before { left: 0; }
.chatbot-date-divider::after { right: 0; }

.chatbot-msg-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: cbSlideUp 0.24s ease forwards;
}

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

.chatbot-msg-row.user {
  flex-direction: row-reverse;
}

.chatbot-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #0B0C45, #2B3B94);
  color: #00D2FF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(11, 12, 69, 0.15);
}

.chatbot-msg-bubble {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.chatbot-msg-row.bot .chatbot-msg-bubble {
  background: #FFFFFF;
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(11, 12, 69, 0.05);
}

.chatbot-msg-row.user .chatbot-msg-bubble {
  background: var(--cb-user-bubble);
  color: #FFFFFF;
  border-top-right-radius: 4px;
  box-shadow: 0 3px 12px rgba(11, 12, 69, 0.2);
}

.chatbot-msg-bubble p {
  margin: 0 0 8px;
}
.chatbot-msg-bubble p:last-child {
  margin-bottom: 0;
}
.chatbot-msg-bubble ul {
  margin: 6px 0;
  padding-left: 20px;
}
.chatbot-msg-bubble li {
  margin-bottom: 4px;
}
.chatbot-msg-bubble strong {
  color: #0B0C45;
  font-weight: 700;
}
.chatbot-msg-row.user .chatbot-msg-bubble strong {
  color: #FFFFFF;
}

.chatbot-msg-bubble a {
  color: #2B3B94;
  text-decoration: underline;
  font-weight: 600;
}
.chatbot-msg-row.user .chatbot-msg-bubble a {
  color: #00D2FF;
}

.chatbot-msg-time {
  font-size: 10.5px;
  color: var(--cb-text-muted);
  margin-top: 4px;
  display: block;
}
.chatbot-msg-row.user .chatbot-msg-time {
  text-align: right;
  color: rgba(255, 255, 255, 0.7);
}

/* Action CTA inside bot messages */
.chatbot-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #0B0C45, #2B3B94);
  color: #FFFFFF !important;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none !important;
  box-shadow: 0 3px 8px rgba(11, 12, 69, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chatbot-action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(11, 12, 69, 0.3);
}

/* ==========================================================================
   5. SUGGESTION CHIPS
   ========================================================================== */

.chatbot-suggestions-container {
  padding: 0 16px 10px;
  background: var(--cb-surface);
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex-shrink: 0;
}

.chatbot-chip {
  background: #FFFFFF;
  color: var(--cb-navy);
  border: 1px solid var(--cb-border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.chatbot-chip:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
  color: #2B3B94;
  transform: translateY(-1px);
}

.chatbot-chip:active {
  transform: scale(0.97);
}

/* ==========================================================================
   6. TYPING INDICATOR
   ========================================================================== */

.chatbot-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #FFFFFF;
  border: 1px solid var(--cb-border);
  border-radius: 16px;
  border-top-left-radius: 4px;
  width: fit-content;
}

.chatbot-typing-dot {
  width: 6px;
  height: 6px;
  background: #94A3B8;
  border-radius: 50%;
  animation: cbDotPulse 1.4s infinite ease-in-out both;
}

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

@keyframes cbDotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; background: #2B3B94; }
}

/* ==========================================================================
   7. INPUT BAR & FOOTER
   ========================================================================== */

.chatbot-footer {
  padding: 12px 14px 8px;
  background: #FFFFFF;
  border-top: 1px solid var(--cb-border);
  flex-shrink: 0;
}

.chatbot-input-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F8FAFC;
  border: 1.5px solid var(--cb-border);
  border-radius: 14px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-input-form:focus-within {
  border-color: #2B3B94;
  box-shadow: 0 0 0 3px rgba(43, 59, 148, 0.12);
  background: #FFFFFF;
}

.chatbot-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--cb-text);
  padding: 8px 0;
}

.chatbot-input::placeholder {
  color: #94A3B8;
}

.chatbot-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #0B0C45, #2B3B94);
  color: #FFFFFF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
  flex-shrink: 0;
}

.chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  background: linear-gradient(135deg, #171E5A, #3B4CCA);
}

.chatbot-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chatbot-branding {
  text-align: center;
  font-size: 11px;
  color: var(--cb-text-muted);
  margin-top: 6px;
}

.chatbot-branding a {
  color: var(--cb-navy);
  text-decoration: none;
  font-weight: 600;
}

/* ==========================================================================
   8. WHATSAPP FLOATING BUTTON COORDINATION
   ========================================================================== */

/* Adjust .wa position so it does not collide with the AI chatbot */
.wa {
  position: fixed !important;
  right: 96px !important;
  bottom: 24px !important;
  z-index: 99980 !important;
  box-shadow: 0 10px 24px -10px rgba(11, 12, 69, 0.35) !important;
  transition: transform 0.2s ease, right 0.2s ease !important;
}

.wa.btn-wa-circle {
  width: 56px !important;
  height: 56px !important;
  min-width: 56px !important;
  min-height: 56px !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 50% !important;
  background: #25D366 !important;
  color: #ffffff !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15) !important;
  animation: waFloatPulse 2.8s infinite !important;
}

.wa.btn-wa-circle:hover {
  background: #20BA5A !important;
  color: #ffffff !important;
  transform: translateY(-3px) scale(1.08) !important;
  animation: none !important;
}

.wa.btn-wa-circle svg {
  width: 28px !important;
  height: 28px !important;
  display: block !important;
  fill: currentColor !important;
}

.wa:not(.btn-wa-circle):hover {
  transform: translateY(-2px) !important;
}

/* ==========================================================================
   9. MOBILE & TABLET RESPONSIVENESS
   ========================================================================== */

@media (max-width: 640px) {
  #gbc-chat-launcher {
    right: 16px;
    bottom: 16px;
  }

  .chat-launcher-btn {
    width: 54px;
    height: 54px;
  }

  .wa {
    right: 80px !important;
    bottom: 16px !important;
    padding: 8px 13px !important;
    font-size: 13.5px !important;
  }

  .chat-launcher-pill {
    display: none; /* Hide greeting pill on small mobile screens */
  }

  #gbc-chatbot-widget {
    right: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
    height: calc(100vh - 100px);
    max-height: 580px;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  #gbc-chatbot-widget {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border: none;
  }

  .chatbot-header {
    padding: 14px 16px;
  }

  .chatbot-body {
    padding: 14px;
  }

  .chatbot-footer {
    padding: 10px 12px 14px;
  }

  .wa {
    /* Stack WhatsApp button above launcher on narrow screens */
    right: 16px !important;
    bottom: 80px !important;
  }
}
