/* Mobile Navigation and Chat Positioning Fixes */

/* Ensure mobile menu doesn't interfere with chat */
.mobile-menu {
    position: fixed !important;
    top: 0 !important;
    left: -100% !important;
    width: 280px !important;
    height: 100vh !important;
    background: white !important;
    z-index: 99999 !important; /* Increased to be above everything except chat */
    transition: left 0.3s ease !important;
    padding-top: 80px !important;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
    overflow-y: auto !important;
}

.mobile-menu.active {
    left: 0 !important;
}

.mobile-menu a {
    display: block !important;
    padding: 15px 25px !important;
    color: #333 !important;
    text-decoration: none !important;
    border-bottom: 1px solid #eee !important;
    transition: background 0.2s ease !important;
}

.mobile-menu a:hover,
.mobile-menu a.active {
    background: #f5f5f5 !important;
    color: #667eea !important;
}

/* Mobile menu overlay */
.mobile-menu-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 99998 !important; /* Below menu, above content */
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease, visibility 0.3s ease !important;
}

.mobile-menu-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Chat button positioning fixes - ALWAYS VISIBLE AND FIXED - HIGHEST Z-INDEX */
.smart-chat-btn {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 999999 !important; /* Highest z-index - above everything including mobile menu */
    display: flex !important; /* Use flexbox for perfect icon centering */
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateZ(0) !important; /* Force GPU acceleration for fixed positioning */
    -webkit-transform: translateZ(0) !important;
}

/* Ensure chat icon is perfectly centered - DESKTOP AND MOBILE */
.smart-chat-btn .chat-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    text-align: center !important;
    line-height: 1 !important;
}

/* Safari specific positioning */
@supports (-webkit-appearance: none) {
    .smart-chat-btn {
        bottom: 20px !important;
        right: 20px !important;
    }
}

/* Chrome specific positioning */
@supports (not (-webkit-appearance: none)) and (not (-moz-appearance: none)) {
    .smart-chat-btn {
        bottom: 20px !important;
        right: 20px !important;
    }
}

/* Mobile responsive adjustments - FIXED responsive display */
@media (max-width: 768px) {
    /* Mobile menu button ALWAYS visible on mobile/narrow screens */
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* Hide desktop nav on mobile/narrow screens */
    #mainNav {
        display: none !important;
    }
    
    /* Show mobile menu structure */
    .mobile-menu {
        display: block !important;
    }
    
    /* Chat button mobile sizing - NO z-index override */
    .smart-chat-btn {
        width: 50px !important;
        height: 50px !important;
        /* z-index stays at 999999 from main rule */
    }
    
    /* Ensure chat doesn't interfere with mobile menu */
    .mobile-menu.active ~ .smart-chat-btn {
        right: 300px !important; /* Move chat when menu is open */
        transition: right 0.3s ease !important;
    }
}

/* Desktop view - ensure hamburger is hidden and nav is visible */
@media (min-width: 769px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-menu {
        display: none !important;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
    
    #mainNav {
        display: flex !important;
    }
    
    /* Reset any mobile-specific chat positioning */
    .smart-chat-btn {
        bottom: 20px !important;
        right: 20px !important;
        z-index: 999999 !important;
        position: fixed !important;
    }
}

/* Overlay for mobile menu */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Hamburger lines styling - WHITE lines for visibility on gradient background */
.hamburger-line {
    width: 22px !important;
    height: 3px !important;
    background: #ffffff !important;
    transition: all 0.3s ease !important;
    margin: 2px 0 !important;
    border-radius: 2px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
}

/* Active state - X animation */
.mobile-menu-toggle.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px) !important;
    background: #ffffff !important;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
    opacity: 0 !important;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px) !important;
    background: #ffffff !important;
}

/* Hide chat button when splash screen is visible */
#welcome-screen ~ * .smart-chat-btn,
#welcome-screen ~ * #unified-chat-button,
body:has(#welcome-screen:not([style*="display: none"])) .smart-chat-btn,
body:has(#welcome-screen:not([style*="display: none"])) #unified-chat-button {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* Show chat after splash is dismissed */
body:not(:has(#welcome-screen)) .smart-chat-btn,
body:not(:has(#welcome-screen)) #unified-chat-button,
#welcome-screen[style*="display: none"] ~ * .smart-chat-btn,
#welcome-screen[style*="display: none"] ~ * #unified-chat-button {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: all !important;
}

/* Hamburger menu - FORCED VISIBILITY on ALL pages - ABOVE MENU */
.mobile-menu-toggle,
button.mobile-menu-toggle,
#mobileMenuToggle {
    position: fixed !important;
    top: 20px !important;
    right: var(--spacing-3xl, 3rem) !important;
    z-index: 100000 !important; /* Above mobile menu (99999) so it's always clickable */
    display: none !important; /* Hidden by default on desktop */
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    width: 40px !important;
    height: 40px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    padding: 8px !important;
    box-shadow: 0 3px 12px rgba(102, 126, 234, 0.4) !important;
    transition: all 0.3s ease !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Mobile view - ALWAYS show hamburger */
@media (max-width: 768px) {
    .mobile-menu-toggle,
    button.mobile-menu-toggle,
    #mobileMenuToggle {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
        /* Align with header padding on mobile */
        top: 20px !important;
        right: 1.5rem !important;
    }
}

/* Hamburger lines - HIGH CONTRAST white lines */
.hamburger-line,
.mobile-menu-toggle .hamburger-line,
#mobileMenuToggle .hamburger-line {
    width: 22px !important;
    height: 3px !important;
    background: #ffffff !important;
    transition: all 0.3s ease !important;
    margin: 2px 0 !important;
    border-radius: 2px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    display: block !important;
    opacity: 1 !important;
}