/**
 * LeadHootz AI Chat Widget Styles
 * Version: 1.0.0
 * Matches BlazorApp AI Chat Preview Styles
 * 
 * CRITICAL: Complete CSS Isolation Strategy
 * This widget must NOT affect parent page layout
 */

/* ========================================
   CRITICAL: Viewport root host (mounted on <html>)
   Escapes transformed/filtered ancestors on customer sites
   ======================================== */
#leadhootz-widget-root {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  left: auto !important;
  top: auto !important;
  inset: auto 20px 20px auto !important;
  z-index: 2147483647 !important;
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  border: 0 !important;
  background: transparent !important;
  pointer-events: none !important;
  transform: none !important;
  filter: none !important;
  contain: none !important;
  isolation: isolate !important;
}

#leadhootz-widget-root > * {
  pointer-events: auto !important;
}

/* ========================================
   CRITICAL: Widget Container Isolation
   ======================================== */

/* Widget Container - Maximum isolation from parent page */
#leadhootz-widget {
  /* Font reset - prevent inheritance */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif !important;
  -webkit-font-smoothing: antialiased !important;
  -moz-osx-font-smoothing: grayscale !important;
  
  /* ========================================
     CRITICAL POSITIONING - ABSOLUTE ISOLATION
     ======================================== */
  position: relative !important;
  bottom: auto !important;
  right: auto !important;
  inset: auto !important;
  z-index: 2147483647 !important; /* Maximum z-index */
  
  /* ========================================
     REMOVE FROM DOCUMENT FLOW COMPLETELY
  ======================================== */
  margin: 0 !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  
  /* ========================================
     PREVENT FLOAT/POSITIONING INHERITANCE
   ======================================== */
  float: none !important;
  clear: none !important;
  display: block !important;
  
  /* ========================================
     PREVENT BOX MODEL ISSUES
     ======================================== */
  box-sizing: border-box !important;
  overflow: visible !important;
  
  /* ========================================
  RESET ALL LAYOUT PROPERTIES
======================================== */
  line-height: normal !important;
  text-align: left !important;
  vertical-align: baseline !important;
  
  /* CRITICAL: Transform resets — do not use translate3d on the fixed host */
  transform: none !important;
  transform-origin: center center !important;
  transform-style: flat !important;
  perspective: none !important;
  
  /* CRITICAL: Filter resets */
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-filter: none !important;
  -webkit-backdrop-filter: none !important;
  
  /* ========================================
     PREVENT FLEX/GRID PARENT INFLUENCE
     ======================================== */
  flex: none !important;
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  flex-basis: auto !important;
  align-self: auto !important;
justify-self: auto !important;
  grid-column: auto !important;
  grid-row: auto !important;
  
  /* ========================================
     RESET SPACING THAT COULD AFFECT PARENT
     ======================================== */
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  
  /* ========================================
     INTERACTION PROPERTIES - CRITICAL FIX
     ======================================== */
  pointer-events: auto !important; /* CHANGED: Container MUST allow pointer events */
  cursor: auto !important;
  user-select: auto !important;
  
  /* ========================================
     PREVENT ANY LAYOUT SHIFTS
     ======================================== */
  /* REMOVED: contain property that breaks fixed positioning */
  isolation: isolate !important; /* Create new stacking context */
  will-change: auto !important;
  
  /* CRITICAL: Prevent parent animations from affecting widget */
  animation: none !important;
  transition: none !important;
}

/* CRITICAL FIX: Allow pointer events on children */
#leadhootz-widget > * {
  pointer-events: auto !important;
}

/* Reset all children to prevent inheritance issues */
#leadhootz-widget *,
#leadhootz-widget *::before,
#leadhootz-widget *::after {
  box-sizing: border-box !important;
}

/* ========================================
   Chat Bubble - Floating Button
   ======================================== */
#leadhootz-chat-bubble {
  /* Ensure bubble is clickable */
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  
  /* CRITICAL: Enable pointer events and ensure it's above everything */
  pointer-events: auto !important;
  z-index: 2147483647 !important; /* Maximum z-index */

  /* Visual styling */
  width: 60px !important;
  height: 60px !important;
  background-color: var(--theme-color, #9333EA) !important;
  color: #fff !important;
  border-radius: 50% !important; /* Changed from 30px to 50% for perfect circle */
  cursor: pointer !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.3s ease !important;
  border: none !important;
  outline: none !important;
  /* Remove any potential background inheritance */
  background-image: none !important;
  background-repeat: no-repeat !important;
  
  /* Prevent any transforms that might affect clickability */
  transform: none !important;
  transform-style: flat !important;
}

#leadhootz-chat-bubble:hover {
  transform: scale(1.05) !important;
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.25) !important;
}

#leadhootz-chat-bubble:active {
  transform: scale(0.95) !important;
}

#leadhootz-chat-bubble svg {
  transition: transform 0.3s ease !important;
  width: 28px !important;
  height: 28px !important;
  pointer-events: none !important; /* SVG doesn't block clicks */
  /* Ensure SVG is centered and white */
  display: block !important;
  margin: 0 auto !important;
}

#leadhootz-chat-bubble svg * {
  pointer-events: none !important; /* SVG children don't block clicks */
}

#leadhootz-chat-bubble:hover svg {
  transform: scale(1.1) !important;
}

/* Chat bubble dots animation on hover */
#leadhootz-chat-bubble:hover circle {
  animation: bubbleDots 1.4s infinite ease-in-out !important;
}

#leadhootz-chat-bubble:hover circle:nth-child(2) {
  animation-delay: 0.2s !important;
}

#leadhootz-chat-bubble:hover circle:nth-child(3) {
  animation-delay: 0.4s !important;
}

@keyframes bubbleDots {
  0%, 60%, 100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-2px);
  }
}

/* ========================================
   Chat Window - Completely Isolated
   ======================================== */
#leadhootz-chat-window {
  /* CRITICAL: Absolute positioning relative to fixed parent */
  position: absolute !important;
  bottom: 80px !important;
  right: 0 !important;
  
  /* CRITICAL: Enable pointer events */
  pointer-events: auto !important;
  
  /* Size constraints */
  width: 400px !important;
  max-width: 90vw !important;
  height: 600px !important;
  max-height: 90vh !important;
  
  /* Ensure no parent influence */
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
  
  /* Layout - HIDDEN BY DEFAULT */
  display: none !important;
  flex-direction: column !important;
  
  /* Visual */
  background-color: #fff !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
  border: 1px solid #e5e7eb !important;
  overflow: hidden !important;
  
  /* Isolation */
  z-index: 2147483647 !important;
  isolation: isolate !important;
  
  /* Ensure visibility when displayed */
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
}

/* CRITICAL: When chat window should be visible */
#leadhootz-chat-window[style*="display: flex"],
#leadhootz-chat-window[style*="display:flex"] {
  display: flex !important;
}

/* Ensure all interactive elements in chat window work */
#leadhootz-chat-window * {
  pointer-events: auto !important;
}

/* Chat Header - Matches BlazorApp Style */
.leadhootz-chat-header {
  display: flex !important;
  align-items: center !important;
  padding: 16px 24px !important;
  background: var(--theme-color, #9333EA) !important;
  color: white !important;
  gap: 12px !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  pointer-events: auto !important;
}

.leadhootz-header-avatar {
  width: 48px !important;
  height: 48px !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.2) !important;
  color: white !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: bold !important;
  font-size: 24px !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

.leadhootz-header-avatar img {
  width: 100% !important;
height: 100% !important;
  object-fit: cover !important;
}

.leadhootz-header-info {
  flex: 1 !important;
  min-width: 0 !important;
}

.leadhootz-agent-name {
  font-size: 18px !important;
  font-weight: 600 !important;
  margin: 0 !important;
  line-height: 1.3 !important;
  color: white !important;
}

.leadhootz-agent-title {
  font-size: 14px !important;
  opacity: 0.8 !important;
  margin: 2px 0 0 0 !important;
  line-height: 1.2 !important;
  color: white !important;
}

.leadhootz-header-close {
  background: transparent !important;
  border: none !important;
  color: white !important;
  font-size: 24px !important;
  cursor: pointer !important;
  padding: 4px !important;
  margin-left: 8px !important;
  opacity: 0.8 !important;
  transition: opacity 0.2s !important;
  line-height: 1 !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.leadhootz-header-close:hover {
  opacity: 1 !important;
}

/* Minimize button with chevron-down icon */
.leadhootz-header-minimize {
  background: transparent !important;
  border: none !important;
  color: white !important;
  cursor: pointer !important;
  padding: 4px !important;
  margin-left: 8px !important;
  opacity: 0.8 !important;
  transition: all 0.2s !important;
  line-height: 1 !important;
  width: 32px !important;
  height: 32px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  border-radius: 4px !important;
}

.leadhootz-header-minimize:hover {
  opacity: 1 !important;
  background: rgba(255, 255, 255, 0.1) !important;
}

.leadhootz-header-minimize svg {
  width: 20px !important;
  height: 20px !important;
}

/* Chat Messages Area - Matches BlazorApp Background */
#leadhootz-chat-messages {
  flex: 1 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 24px !important;
  background: #f9fafb !important;
  min-height: 0 !important;
  box-sizing: border-box !important;
}

/* Dark mode support for messages area */
@media (prefers-color-scheme: dark) {
  #leadhootz-chat-messages {
  background: #111827 !important;
  }
}

/* Message Container */
.leadhootz-message {
  display: flex !important;
  margin-bottom: 16px !important;
  animation: fadeIn 0.3s ease !important;
  gap: 12px !important;
  box-sizing: border-box !important;
}

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

.leadhootz-message-agent {
  justify-content: flex-start !important;
}

.leadhootz-message-user {
  justify-content: flex-end !important;
}

/* Avatar for Agent Messages - Matches BlazorApp Style */
.leadhootz-message-avatar {
  width: 40px !important;
  height: 40px !important;
  flex-shrink: 0 !important;
}

.leadhootz-avatar-small {
  width: 40px !important;
  height: 40px !important;
  border-radius: 50% !important;
  background: var(--theme-color, #9333EA) !important;
  color: white !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-weight: 600 !important;
  font-size: 14px !important;
overflow: hidden !important;
  box-sizing: border-box !important;
}

.leadhootz-avatar-small img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}

/* Message Bubbles - Matches BlazorApp Style */
.leadhootz-message-content {
  max-width: 70% !important;
  padding: 16px !important;
  border-radius: 16px !important;
  word-wrap: break-word !important;
  white-space: pre-wrap !important;
  line-height: 1.5 !important;
  font-size: 14px !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  box-sizing: border-box !important;
}

/* Links in Message Content */
.leadhootz-message-content a {
  color: #0066cc !important;
  text-decoration: underline !important;
  font-weight: 500 !important;
  transition: all 0.2s !important;
  word-break: break-word !important;
}

.leadhootz-message-content a:hover {
  color: #0052a3 !important;
  text-decoration: none !important;
}

/* Links in User Messages (white text on theme color background) */
.leadhootz-message-user .leadhootz-message-content a {
  color: #ffffff !important;
  text-decoration: underline !important;
  font-weight: 600 !important;
}

.leadhootz-message-user .leadhootz-message-content a:hover {
  color: #f0f0f0 !important;
  text-decoration: none !important;
}

/* Agent Message Bubble - White with rounded top-left corner cut */
.leadhootz-message-agent .leadhootz-message-content {
  background: white !important;
  color: #111827 !important;
  border-top-left-radius: 4px !important;
}

/* Dark mode for agent messages */
@media (prefers-color-scheme: dark) {
  .leadhootz-message-agent .leadhootz-message-content {
    background: #1f2937 !important;
    color: white !important;
  }
}

/* User Message Bubble - Theme color with rounded top-right corner cut */
.leadhootz-message-user .leadhootz-message-content {
  background: var(--theme-color, #9333EA) !important;
  color: white !important;
  border-top-right-radius: 4px !important;
  margin-left: auto !important;
}

/* Message Actions (e.g., Book Meeting Button) */
.leadhootz-message-actions {
  max-width: 70% !important;
  margin-top: 8px !important;
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  justify-content: flex-start !important;
}

/* Suggested Actions Container */
.leadhootz-suggested-actions .leadhootz-message-actions {
  max-width: 100% !important;
}

/* Book Meeting Button - Matches BlazorApp Style */
.leadhootz-book-meeting-btn {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 12px 24px !important;
  background: white !important;
  color: var(--theme-color, #9333EA) !important;
  border: 2px solid var(--theme-color, #9333EA) !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  transition: all 0.2s !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  box-sizing: border-box !important;
}

.leadhootz-book-meeting-btn:hover {
  background: rgba(147, 51, 234, 0.05) !important;
  border-color: var(--theme-color, #9333EA) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
}

/* Suggested Action Button */
.leadhootz-action-btn {
  display: inline-flex !important;
  align-items: center !important;
  padding: 10px 20px !important;
  background: white !important;
  color: var(--theme-color, #9333EA) !important;
border: 1px solid #e5e7eb !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  transition: all 0.2s !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  white-space: nowrap !important;
  box-sizing: border-box !important;
}

.leadhootz-action-btn:hover {
  background: var(--theme-color, #9333EA) !important;
  color: white !important;
border-color: var(--theme-color, #9333EA) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 2px 4px rgba(147, 51, 234, 0.2) !important;
}

.leadhootz-action-btn:active {
  transform: translateY(0) !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

/* Dark mode for book meeting button */
@media (prefers-color-scheme: dark) {
  .leadhootz-book-meeting-btn {
    background: #1f2937 !important;
  color: white !important;
  }

  .leadhootz-book-meeting-btn:hover {
    background: #374151 !important;
  }
}

.leadhootz-book-meeting-btn svg {
  width: 20px !important;
  height: 20px !important;
}

/* Typing Indicator */
.leadhootz-typing-indicator {
  display: flex !important;
  align-items: center !important;
  gap: 4px !important;
  padding: 16px !important;
  background: white !important;
  border-radius: 16px !important;
border-top-left-radius: 4px !important;
  width: fit-content !important;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
  box-sizing: border-box !important;
}

@media (prefers-color-scheme: dark) {
  .leadhootz-typing-indicator {
 background: #1f2937 !important;
  }
}

.leadhootz-typing-dot {
  width: 8px !important;
  height: 8px !important;
  background: #9ca3af !important;
  border-radius: 50% !important;
  animation: typing 1.4s infinite !important;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    opacity: 0.3;
    transform: scale(0.8);
  }
  30% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Chat Input Area */
#leadhootz-chat-input {
  display: flex !important;
  align-items: center !important;
  padding: 16px !important;
  background: white !important;
  border-top: 1px solid #e5e7eb !important;
gap: 12px !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

@media (prefers-color-scheme: dark) {
  #leadhootz-chat-input {
    background: #1f2937 !important;
 border-top-color: #374151 !important;
  }
}

#leadhootz-input-box {
  flex: 1 !important;
  border: 1px solid #d1d5db !important;
  border-radius: 24px !important;
  padding: 12px 16px !important;
  font-size: 14px !important;
outline: none !important;
  transition: all 0.2s !important;
  background: white !important;
  color: #111827 !important;
  box-sizing: border-box !important;
}

#leadhootz-input-box:focus {
  border-color: var(--theme-color, #9333EA) !important;
  box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1) !important;
}

@media (prefers-color-scheme: dark) {
  #leadhootz-input-box {
    background: #111827 !important;
    color: white !important;
    border-color: #374151 !important;
  }
}

#leadhootz-send-button {
  background: var(--theme-color, #9333EA) !important;
  color: white !important;
  border: none !important;
  border-radius: 24px !important;
  padding: 12px 24px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

#leadhootz-send-button:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3) !important;
}

#leadhootz-send-button:active {
  transform: translateY(0) !important;
}

/* Powered by Footer */
.leadhootz-powered-by {
  padding: 12px !important;
  text-align: center !important;
  background: #f3f4f6 !important;
  border-top: 1px solid #e5e7eb !important;
  font-size: 11px !important;
color: #6b7280 !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
}

@media (prefers-color-scheme: dark) {
  .leadhootz-powered-by {
    background: #111827 !important;
    border-top-color: #374151 !important;
    color: #9ca3af !important;
  }
}

.leadhootz-powered-by a {
  color: var(--theme-color, #9333EA) !important;
  text-decoration: none !important;
  font-weight: 600 !important;
}

.leadhootz-powered-by a:hover {
  text-decoration: underline !important;
}

/* Scrollbar Styling */
#leadhootz-chat-messages::-webkit-scrollbar {
  width: 6px !important;
}

#leadhootz-chat-messages::-webkit-scrollbar-track {
  background: transparent !important;
}

#leadhootz-chat-messages::-webkit-scrollbar-thumb {
  background: #d1d5db !important;
  border-radius: 3px !important;
}

#leadhootz-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #9ca3af !important;
}

/* ========================================
   Responsive Design — compact panel on small viewports
   ======================================== */
@media (max-width: 768px) {
  #leadhootz-widget-root {
    bottom: 12px !important;
    right: 12px !important;
    inset: auto 12px 12px auto !important;
  }

  #leadhootz-chat-window {
    width: calc(100vw - 24px) !important;
    max-width: 360px !important;
    height: min(70vh, 520px) !important;
    max-height: calc(100vh - 100px) !important;
    bottom: 70px !important;
    right: 0 !important;
    border-radius: 12px !important;
  }

  #leadhootz-chat-bubble {
    width: 52px !important;
    height: 52px !important;
  }

  #leadhootz-chat-bubble svg {
    width: 24px !important;
    height: 24px !important;
  }

  .leadhootz-chat-header {
    padding: 12px 16px !important;
    gap: 10px !important;
  }

  .leadhootz-header-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 18px !important;
  }

  .leadhootz-agent-name {
    font-size: 16px !important;
  }

  .leadhootz-agent-title {
    font-size: 12px !important;
  }

  #leadhootz-chat-messages {
    padding: 12px !important;
  }

  .leadhootz-message {
    margin-bottom: 12px !important;
    gap: 8px !important;
  }

  .leadhootz-message-avatar,
  .leadhootz-avatar-small {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }

  .leadhootz-message-content {
    max-width: 85% !important;
    padding: 12px !important;
    font-size: 13px !important;
  }

  #leadhootz-chat-input {
    padding: 12px !important;
    gap: 8px !important;
  }

  #leadhootz-input-box {
    padding: 10px 14px !important;
    font-size: 16px !important;
  }

  #leadhootz-send-button {
    padding: 10px 16px !important;
    font-size: 13px !important;
  }

  .leadhootz-powered-by {
    padding: 8px !important;
    font-size: 10px !important;
  }
}

@media (max-width: 400px) {
  #leadhootz-widget-root {
    bottom: 8px !important;
    right: 8px !important;
    inset: auto 8px 8px auto !important;
  }

  #leadhootz-chat-window {
    width: calc(100vw - 16px) !important;
    max-width: none !important;
    height: min(65vh, 480px) !important;
    max-height: calc(100vh - 90px) !important;
    bottom: 64px !important;
  }
}
