/**
 * Mobile Navigation Fix - BE-COM E-commerce
 * Senior Tech Lead Solution
 */

/* TOP BAR MOBILE */
@media (max-width: 767.98px) {
    .top-bar {
        padding: 5px 0 !important;
        font-size: 10px !important;
    }
    
    .top-bar-left { display: none !important; }
    
    .top-bar-right {
        width: 100%;
        justify-content: center !important;
    }
    
    .promo-text {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 5px;
        text-align: center;
        width: 100%;
        padding: 0 !important;
    }
    
    .promo-text span,
    .signup-link {
        font-size: 10px !important;
        line-height: 1.2 !important;
    }
}

/* MAIN HEADER MOBILE */
@media (max-width: 767.98px) {
    .main-header {
        padding: 10px 0 !important;
    }
    
    .main-header .container {
        padding: 0 8px;
    }
    
    .main-header .row > * {
        padding: 0 4px;
    }
    
    /* LOGO */
    .logo a {
        gap: 6px !important;
    }
    
    .logo-image {
        height: 32px !important;
        width: auto !important;
    }
    
    .logo-text {
        font-size: 18px !important;
        font-weight: 700 !important;
    }
    
    /* HEADER ACTIONS */
    .header-actions {
        display: flex !important;
        gap: 6px !important;
        justify-content: flex-end !important;
        flex-wrap: nowrap !important;
    }
    
    .search-toggle {
        display: none !important;
    }
    
    .header-action-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        min-height: 38px !important;
        border-radius: 50% !important;
        flex-shrink: 0;
        padding: 0 !important;
        background: rgba(44, 95, 45, 0.08) !important;
    }
    
    .header-action-btn i {
        font-size: 16px !important;
    }
    
    .badge-count,
    .cart-count,
    .wishlist-count {
        position: absolute !important;
        top: -4px !important;
        right: -4px !important;
        min-width: 18px !important;
        height: 18px !important;
        font-size: 10px !important;
        line-height: 18px !important;
        border: 2px solid white;
    }
    
    .dropdown-toggle-icon {
        display: none !important;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
    }
}

/* MOBILE NAV DRAWER */
@media (max-width: 991.98px) {
    .mobile-nav {
        position: fixed;
        top: 0;
        left: -320px;
        width: 320px;
        height: 100vh;
        background: white;
        z-index: 9999;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transition: left 0.3s ease;
    }
    
    .mobile-nav.active {
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    
    .mobile-nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 9998;
    }
    
    .mobile-nav-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* CRITICAL FIX: Show main navigation inside mobile menu */
    .mobile-nav .main-navigation {
        display: block !important;
    }
    
    .mobile-nav .main-navigation .nav-menu {
        display: flex !important;
        flex-direction: column;
    }
    
    /* Mobile dropdown toggle icons */
    .mobile-nav .dropdown-toggle {
        position: relative;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }
    
    .mobile-nav .dropdown-toggle-icon {
        margin-left: auto;
        padding: 10px;
        font-size: 16px;
        color: var(--primary-color, #2C5F2D);
        transition: transform 0.3s ease, color 0.2s ease;
        background: rgba(44, 95, 45, 0.08);
        border-radius: 4px;
        min-width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }
    
    .mobile-nav .dropdown-toggle-icon:active {
        background: rgba(44, 95, 45, 0.15);
    }
    
    .mobile-nav .dropdown-toggle.active .dropdown-toggle-icon {
        transform: rotate(180deg);
        color: var(--primary-color, #2C5F2D);
        background: rgba(44, 95, 45, 0.12);
    }
    
    /* Make dropdown menus visible by default on mobile */
    .mobile-nav .dropdown-menu {
        display: block;
        position: static;
        opacity: 1;
        visibility: visible;
        background: rgba(44, 95, 45, 0.03);
        border: none;
        box-shadow: none;
        margin: 0;
        padding: 0;
        max-height: 500px;
    }
    
    .mobile-nav .dropdown-item {
        padding: 14px 20px 14px 56px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    }
    
    .mobile-nav .dropdown-item:last-child {
        border-bottom: none;
    }
}

/* EXTRA SMALL DEVICES */
@media (max-width: 374.98px) {
    .promo-text span,
    .signup-link {
        font-size: 9px !important;
    }
    
    .logo-image {
        height: 28px !important;
    }
    
    .logo-text {
        font-size: 16px !important;
    }
    
    .header-actions {
        gap: 4px !important;
    }
    
    .header-action-btn {
        width: 36px !important;
        height: 36px !important;
    }
}

/* LANDSCAPE MODE */
@media (max-height: 500px) and (orientation: landscape) {
    .top-bar,
    .news-ticker-bar {
        display: none !important;
    }
    
    .main-header {
        padding: 8px 0 !important;
    }
}

/* TOUCH FEEDBACK */
@media (max-width: 991.98px) {
    .touch-active,
    .btn.touch-active,
    .header-action-btn.touch-active {
        opacity: 0.7 !important;
        transform: scale(0.95);
    }
    
    /* Improve tap highlighting */
    .btn,
    .header-action-btn,
    .nav-link,
    .product-action-btn {
        -webkit-tap-highlight-color: rgba(44, 95, 45, 0.15);
        tap-highlight-color: rgba(44, 95, 45, 0.15);
    }
    
    /* Remove default focus outline on touch devices */
    .is-mobile *:focus {
        outline: none;
    }
    
    /* Add custom focus for accessibility */
    .is-mobile *:focus-visible {
        outline: 2px solid var(--primary-color);
        outline-offset: 2px;
    }
}

/* MOBILE BODY CLASS OPTIMIZATIONS */
body.is-mobile {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

body.is-mobile img {
    -webkit-user-drag: none;
    user-select: none;
}

body.is-mobile .user-select-none {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
