/* ================================================
   Mobile Menu Responsive Styles
   Fix for mobile menu disappearing at certain resolutions
   ================================================ */

/* ================================================
   Desktop Styles (≥992px)
   ================================================ */
@media (min-width: 992px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-nav {
        display: none !important;
    }
    
    .mobile-overlay {
        display: none !important;
    }
    
    .it-solution_menu {
        display: block !important;
    }
}

/* ================================================
   Mobile & Tablet Styles (<992px)
   ================================================ */
@media (max-width: 991px) {
    /* Force layout for mobile header */
    .it-solution_nav_manu {
        position: relative !important;
    }
    
    .it-solution_nav_manu .container {
        position: relative !important;
    }
    
    .it-solution_nav_manu .row {
        display: flex !important;
        align-items: center !important;
        position: relative !important;
    }
    
    .it-solution_nav_manu .col-lg-2 {
        flex: 0 0 auto !important;
        width: auto !important;
        max-width: 200px !important;
    }
    
    .it-solution_nav_manu .col-lg-10 {
        flex: 1 1 auto !important;
        width: auto !important;
        position: relative !important;
        min-height: 60px !important; /* Ensure height for absolute positioning */
    }
    
    /* Hide desktop navigation */
    .it-solution_menu {
        display: none !important;
    }
    
    /* Show mobile menu toggle button */
    .mobile-menu-toggle {
        display: flex !important;
        flex-direction: column;
        justify-content: space-around;
        width: 40px !important; /* Larger click area */
        height: 40px !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
        padding: 8px !important;
        z-index: 10000 !important; /* Higher than mobile nav (9999) */
        position: absolute !important;
        right: 10px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
        pointer-events: auto !important; /* Ensure clickable */
        outline: none !important;
    }
    
    /* Mobile menu toggle button lines */
    .mobile-menu-toggle span {
        display: block;
        width: 100%;
        height: 3px;
        background-color: #333;
        transition: all 0.3s ease;
        border-radius: 2px;
    }
    
    /* Dark theme support for toggle button */
    .dark-theme .mobile-menu-toggle span {
        background-color: #fff;
    }
    
    /* Animated hamburger to X transformation */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }
    
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }
    
    /* Mobile navigation panel */
    .mobile-nav {
        position: fixed !important;
        top: 0 !important;
        right: -100% !important;
        width: 300px !important;
        height: 100vh !important;
        background: #ffffff !important;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1) !important;
        transition: right 0.3s ease !important;
        z-index: 1500 !important; /* Higher than toggle button */
        padding-top: 80px !important;
        overflow-y: auto !important;
        display: block !important; /* Force display */
    }
    
    /* Dark theme support for mobile nav */
    .dark-theme .mobile-nav {
        background: #2c2c2c;
        color: #ffffff;
    }
    
    /* Mobile nav active state */
    .mobile-nav.active {
        right: 0 !important;
        transform: translateX(0) !important; /* Ensure visible */
    }
    
    /* Mobile nav list styles */
    .mobile-nav ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .mobile-nav ul li {
        margin: 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }
    
    /* Dark theme border */
    .dark-theme .mobile-nav ul li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .mobile-nav ul li a {
        display: block;
        padding: 15px 20px;
        color: #333;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    /* Dark theme link colors */
    .dark-theme .mobile-nav ul li a {
        color: #ffffff;
    }
    
    .mobile-nav ul li a:hover {
        background-color: rgba(0, 0, 0, 0.05);
        color: #667eea;
        padding-left: 25px;
    }
    
    /* Dark theme hover */
    .dark-theme .mobile-nav ul li a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Theme toggle in mobile menu */
    .mobile-nav .theme-toggle {
        display: block;
        padding: 15px 20px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
        cursor: pointer;
        color: #333;
        font-size: 16px;
        font-weight: 500;
        transition: all 0.3s ease;
    }
    
    .dark-theme .mobile-nav .theme-toggle {
        color: #ffffff;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .mobile-nav .theme-toggle:hover {
        background-color: rgba(0, 0, 0, 0.05);
        color: #667eea;
        padding-left: 25px;
    }
    
    .dark-theme .mobile-nav .theme-toggle:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    /* Show overlay when mobile nav is active */
    .mobile-overlay {
        display: none !important;
    }
    
    .mobile-nav.active ~ .mobile-overlay,
    .mobile-nav.active + .mobile-overlay {
        display: block !important;
        opacity: 1;
    }
}

/* ================================================
   Specific Mobile Breakpoints for Fine-tuning
   ================================================ */

/* Large Mobile Devices (≤768px) */
@media (max-width: 768px) {
    .mobile-nav {
        width: 280px;
    }
    
    .mobile-menu-toggle {
        width: 28px;
        height: 28px;
    }
}

/* Small Mobile Devices (≤480px) */
@media (max-width: 480px) {
    .mobile-nav {
        width: 260px;
    }
    
    .mobile-nav ul li a {
        font-size: 15px;
        padding: 12px 20px;
    }
    
    .mobile-nav .theme-toggle {
        font-size: 15px;
        padding: 12px 20px;
    }
}

/* Extra Small Mobile Devices (≤360px) */
@media (max-width: 360px) {
    .mobile-nav {
        width: 240px;
    }
    
    .mobile-nav ul li a {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .mobile-nav .theme-toggle {
        font-size: 14px;
        padding: 10px 15px;
    }
}

/* ================================================
   Animation and Accessibility Enhancements
   ================================================ */

/* Reduce animations for users with motion preferences */
@media (prefers-reduced-motion: reduce) {
    .mobile-menu-toggle span,
    .mobile-nav,
    .mobile-overlay,
    .mobile-nav ul li a,
    .mobile-nav .theme-toggle {
        transition: none !important;
    }
}

/* Focus states for accessibility */
.mobile-menu-toggle:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.mobile-nav ul li a:focus,
.mobile-nav .theme-toggle:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-menu-toggle span {
        background-color: #000;
    }
    
    .dark-theme .mobile-menu-toggle span {
        background-color: #fff;
    }
    
    .mobile-nav {
        border: 2px solid #000;
    }
    
    .dark-theme .mobile-nav {
        border: 2px solid #fff;
    }
}