/**
 * PERSISTENT LAYER CHATBOT WIDGET - Global Styles
 * Maison Dalí - Maximum Priority Floating Layer
 * 
 * These styles provide additional visual enhancements
 * All critical styles are inline with !important for maximum priority
 * 
 * @version 2.0.0-PERSISTENT
 * @date 2026-01-26
 */

/* ========================================
   PERSISTENT LAYER BASE
   ======================================== */

#md-persistent-chatbot-layer {
  /* Enforced via inline styles, but declared here for completeness */
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  pointer-events: none !important;
  z-index: 2147483647 !important;
  isolation: isolate !important;
  contain: layout style !important;
}

/* ========================================
   CHATBOT WIDGET CONTAINER
   ======================================== */

#md-chatbot-widget {
  position: fixed !important;
  bottom: 20px !important;
  right: 20px !important;
  z-index: 2147483647 !important;
  pointer-events: auto !important;
  isolation: isolate !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* ========================================
   FLOATING BUTTON
   ======================================== */

#md-chatbot-button {
  border: none !important;
  padding: 0 !important;
  background: transparent !important;
  cursor: pointer !important;
  outline: none !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#md-chatbot-button:focus {
  outline: 2px solid #D4AF37 !important;
  outline-offset: 4px !important;
}

#md-chatbot-button:active {
  transform: scale(0.95) !important;
}

/* Pulse Animation */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(167, 38, 38, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(167, 38, 38, 0.5);
  }
}

/* ========================================
   CHAT PANEL
   ======================================== */

#md-chatbot-panel {
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

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

/* ========================================
   MESSAGES CONTAINER
   ======================================== */

#md-chatbot-messages {
  scrollbar-width: thin !important;
  scrollbar-color: #3a3a3a #0a0a0a !important;
}

#md-chatbot-messages::-webkit-scrollbar {
  width: 8px !important;
}

#md-chatbot-messages::-webkit-scrollbar-track {
  background: #0a0a0a !important;
}

#md-chatbot-messages::-webkit-scrollbar-thumb {
  background: #3a3a3a !important;
  border-radius: 4px !important;
}

#md-chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #4a4a4a !important;
}

/* Message animations */
#md-chatbot-messages > div {
  animation: messageIn 0.3s ease-out !important;
}

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

/* ========================================
   INPUT AREA
   ======================================== */

#md-chatbot-input {
  transition: border-color 0.2s ease !important;
}

#md-chatbot-input:focus {
  border-color: #D4AF37 !important;
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2) !important;
}

#md-chatbot-send {
  transition: all 0.2s ease !important;
}

#md-chatbot-send:hover {
  background: #8B1E1E !important;
  box-shadow: 0 2px 8px rgba(167, 38, 38, 0.4) !important;
}

#md-chatbot-send:active {
  transform: scale(0.98) !important;
}

#md-chatbot-send:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

/* ========================================
   CLOSE BUTTON
   ======================================== */

#md-chatbot-close {
  transition: all 0.2s ease !important;
  border-radius: 4px !important;
}

#md-chatbot-close:hover {
  background: rgba(255, 255, 255, 0.1) !important;
  transform: rotate(90deg) !important;
}

#md-chatbot-close:active {
  transform: rotate(90deg) scale(0.9) !important;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
  #md-chatbot-widget {
    bottom: 10px !important;
    right: 10px !important;
    left: 10px !important;
  }

  #md-chatbot-panel {
    width: 100% !important;
    height: 400px !important;
    max-height: calc(100vh - 100px) !important;
    right: 0 !important;
    left: 0 !important;
  }

  #md-chatbot-button > div {
    width: 50px !important;
    height: 50px !important;
  }

  #md-chatbot-button > div > span {
    font-size: 24px !important;
  }
}

@media (max-width: 380px) {
  #md-chatbot-panel {
    bottom: 70px !important;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus visible for keyboard navigation */
#md-chatbot-widget *:focus-visible {
  outline: 2px solid #D4AF37 !important;
  outline-offset: 2px !important;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #md-chatbot-widget *,
  #md-chatbot-widget *::before,
  #md-chatbot-widget *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  #md-chatbot-button > div {
    border-width: 4px !important;
  }

  #md-chatbot-panel {
    border-width: 3px !important;
  }
}

/* ========================================
   MODE INDICATORS
   ======================================== */

.md-mode-concierge {
  border-color: #22c55e !important;
}

.md-mode-game {
  border-color: #f97316 !important;
}

/* ========================================
   LOADING STATE
   ======================================== */

.md-loading {
  position: relative !important;
  overflow: hidden !important;
}

.md-loading::after {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(212, 175, 55, 0.1) 50%,
    transparent 100%
  ) !important;
  animation: loading 1.5s infinite !important;
}

@keyframes loading {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  #md-persistent-chatbot-layer,
  #md-chatbot-widget {
    display: none !important;
  }
}

/* ========================================
   DREAM LAYER COMPATIBILITY
   ======================================== */

/* Ensure chatbot stays above dream layer overlays */
.dali-clue-overlay {
  z-index: 999999 !important;
}

#md-persistent-chatbot-layer {
  z-index: 2147483647 !important;
}

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

#md-chatbot-widget {
  will-change: transform !important;
  transform: translateZ(0) !important;
}

#md-chatbot-messages {
  will-change: scroll-position !important;
  transform: translateZ(0) !important;
}

/* ========================================
   SAFETY OVERRIDES
   ======================================== */

/* Prevent other stylesheets from breaking the widget */
#md-persistent-chatbot-layer,
#md-persistent-chatbot-layer * {
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 0 !important;
}

#md-chatbot-widget button {
  font-family: inherit !important;
}

#md-chatbot-widget input {
  font-family: inherit !important;
  font-size: inherit !important;
}
