/**
 * Mobile Chat Fix - Ensures chat can be properly opened and closed on mobile
 */

@media (max-width: 900px) {
  /* Hide desktop chat completely on mobile */
  #chat-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: calc(var(--vh, 1vh) * 100) !important;
    background: rgba(10, 10, 10, 0.98) !important;
    z-index: 10000 !important;
    display: flex !important;
    flex-direction: column !important;
    /* START HIDDEN - slide in from right */
    transform: translateX(100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    pointer-events: none !important;
  }
  
  /* Chat open state */
  #chat-panel.bj-open {
    transform: translateX(0) !important;
    pointer-events: all !important;
  }
  
  /* Chat toggle button - moved to bottom right to not obstruct UI */
  .bj-chat-toggle {
    display: flex !important;
    position: fixed !important;
    bottom: 90px !important;
    right: 12px !important;
    top: auto !important;
    width: 52px !important;
    height: 52px !important;
    z-index: 10002 !important;
    background: #ffd700 !important;
    color: #000 !important;
    border: none !important;
    border-radius: 50% !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7) !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.5rem !important;
    cursor: pointer !important;
    pointer-events: all !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
  }
  
  .bj-chat-toggle:active {
    transform: scale(0.92) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5) !important;
  }
  
  .bj-chat-badge {
    position: absolute !important;
    top: -6px !important;
    right: -6px !important;
    width: 22px !important;
    height: 22px !important;
    font-size: 0.75rem !important;
    background: #ff4444 !important;
    color: #fff !important;
    border: 2px solid #ffd700 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: bold !important;
  }
  
  /* Chat header */
  .chat-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 14px !important;
    background: rgba(0, 0, 0, 0.95) !important;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3) !important;
    flex-shrink: 0 !important;
  }
  
  .chat-header h2 {
    margin: 0 !important;
    font-size: 1.1rem !important;
    color: #ffd700 !important;
  }
  
  /* Close button in chat header */
  .bj-chat-close,
  .chat-close-btn {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    border-radius: 8px !important;
    color: #fff !important;
    font-size: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    pointer-events: all !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: background 0.2s ease !important;
  }
  
  .bj-chat-close:active,
  .chat-close-btn:active {
    background: rgba(255, 255, 255, 0.2) !important;
  }
  
  /* Chat messages area */
  #chat-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 12px !important;
  }
  
  /* Chat form */
  #chat-form {
    padding: 12px !important;
    background: rgba(0, 0, 0, 0.95) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    flex-shrink: 0 !important;
  }
  
  #chat-form input {
    width: 100% !important;
    padding: 12px !important;
    font-size: 1rem !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 8px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    color: #fff !important;
  }
  
  /* Overlay behind chat when open */
  .bj-chat-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 9999 !important;
    display: none !important;
    pointer-events: none !important;
  }
  
  .bj-chat-overlay.bj-show {
    display: block !important;
    pointer-events: all !important;
    touch-action: manipulation !important;
    cursor: pointer !important;
  }
  
  
  /* Make sure toggle button is always on top */
  body.bj-mobile-chat .bj-chat-toggle {
    z-index: 10001 !important;
  }
}

