/**
 * Enhanced Mobile Navigation Styles - LostFound
 * Comprehensive mobile navigation fixes and improvements
 * Updated: August 24, 2025
 * Version: 2.0.0
 */

/* ===== MOBILE NAVIGATION BASE STYLES ===== */

@media (max-width: 768px) {
    /* Fixed navigation adjustments for mobile */
    .modern-nav {
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
        height: 64px;
    }
    
    .modern-nav .max-w-7xl {
        padding: 0 16px;
    }
    
    .modern-nav .flex.justify-between {
        height: 64px;
    }
    
    /* Mobile logo adjustments */
    .nav-brand {
        font-size: 18px !important;
    }
    
    .nav-brand .text-2xl {
        font-size: 18px !important;
        line-height: 1.2;
    }
    
    .nav-brand .text-xs {
        font-size: 10px !important;
        margin-top: -2px;
        display: block;
    }
    
    /* Home button mobile optimization */
    .nav-link.compact {
        padding: 8px 10px;
        margin-right: 12px;
    }
}

/* ===== MOBILE MENU BUTTON ENHANCEMENTS ===== */

@media (max-width: 768px) {
    .mobile-menu-btn {
        padding: 12px;
        background: rgba(59, 130, 246, 0.1);
        border-radius: 12px;
        transition: all 0.3s ease;
        position: relative;
        z-index: 1001;
        border: 1px solid rgba(59, 130, 246, 0.2);
    }
    
    .mobile-menu-btn:hover,
    .mobile-menu-btn:focus {
        background: rgba(59, 130, 246, 0.15);
        transform: scale(1.05);
        border-color: rgba(59, 130, 246, 0.3);
    }
    
    .mobile-menu-btn:active {
        transform: scale(0.95);
    }
    
    /* Hamburger animation improvements */
    .mobile-menu-btn .w-6 {
        width: 24px;
        height: 24px;
    }
    
    .mobile-menu-btn span {
        background: #374151;
        border-radius: 2px;
        transform-origin: center;
    }
    
    /* Menu open state styling */
    .mobile-menu-btn.menu-open {
        background: rgba(239, 68, 68, 0.1);
        border-color: rgba(239, 68, 68, 0.3);
    }
    
    .mobile-menu-btn.menu-open span {
        background: #ef4444;
    }
}

/* ===== MOBILE MENU OVERLAY IMPROVEMENTS ===== */

@media (max-width: 768px) {
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        z-index: 999;
        touch-action: none; /* Prevent scroll through overlay */
    }
}

/* ===== ENHANCED MOBILE MENU CONTAINER ===== */

@media (max-width: 768px) {
    .mobile-menu-container {
        position: fixed;
        top: 0;
        right: 0;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        background: white;
        z-index: 1000;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
        display: flex;
        flex-direction: column;
    }
    
    /* Smaller screens get full width menu */
    @media (max-width: 480px) {
        .mobile-menu-container {
            width: 100vw;
            max-width: 100vw;
        }
    }
}

/* ===== MOBILE MENU HEADER IMPROVEMENTS ===== */

@media (max-width: 768px) {
    .mobile-menu-container .bg-gradient-to-r {
        padding: 20px;
        background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-menu-container h3 {
        font-size: 24px;
        font-weight: 700;
        margin-bottom: 4px;
    }
    
    .mobile-menu-container p {
        font-size: 14px;
        opacity: 0.9;
        margin-bottom: 16px;
    }
    
    /* User avatar section in mobile menu */
    .mobile-menu-container .flex.items-center.space-x-3 {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        padding: 12px;
        margin-top: 16px;
        backdrop-filter: blur(10px);
    }
    
    .mobile-menu-container .w-12 {
        width: 48px;
        height: 48px;
        border: 2px solid rgba(255, 255, 255, 0.3);
    }
    
    .mobile-menu-container .text-white.font-semibold {
        font-size: 16px;
        margin-bottom: 2px;
    }
    
    .mobile-menu-container .text-blue-100 {
        font-size: 12px;
        opacity: 0.8;
    }
}

/* ===== MOBILE NAVIGATION ITEMS ENHANCEMENT ===== */

@media (max-width: 768px) {
    .mobile-nav-item-enhanced {
        display: flex;
        align-items: center;
        padding: 16px 20px;
        color: #374151;
        text-decoration: none;
        transition: all 0.3s ease;
        font-weight: 500;
        font-size: 16px;
        border-radius: 8px;
        margin: 2px 12px;
        position: relative;
        overflow: hidden;
    }
    
    .mobile-nav-item-enhanced::before {
        content: '';
        position: absolute;
        left: -100%;
        top: 0;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.1), transparent);
        transition: left 0.4s ease;
    }
    
    .mobile-nav-item-enhanced:hover::before,
    .mobile-nav-item-enhanced:active::before {
        left: 100%;
    }
    
    .mobile-nav-item-enhanced:hover,
    .mobile-nav-item-enhanced:active {
        background: rgba(59, 130, 246, 0.08);
        color: #1e40af;
        transform: translateX(4px);
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
    }
    
    .mobile-nav-item-enhanced i {
        font-size: 20px;
        width: 24px;
        text-align: center;
        margin-right: 16px;
        flex-shrink: 0;
    }
    
    .mobile-nav-item-enhanced span {
        flex-grow: 1;
    }
    
    /* Active state for current page */
    .mobile-nav-item-enhanced.active {
        background: rgba(59, 130, 246, 0.12);
        color: #1e40af;
        font-weight: 600;
        border-left: 4px solid #3b82f6;
    }
    
    /* Badge styles for notifications in mobile menu */
    .mobile-nav-item-enhanced .ml-auto {
        margin-left: auto;
        font-size: 11px;
        font-weight: 700;
        min-width: 24px;
        height: 24px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    }
}

/* ===== MOBILE MENU SECTION HEADERS ===== */

@media (max-width: 768px) {
    .mobile-menu-container h4 {
        font-size: 12px;
        font-weight: 700;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 12px;
        padding: 0 20px;
    }
    
    .mobile-menu-container .px-4 {
        padding: 0 8px;
    }
    
    .mobile-menu-container .mb-6 {
        margin-bottom: 24px;
        padding-bottom: 16px;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .mobile-menu-container .mb-6:last-child {
        border-bottom: none;
        margin-bottom: 16px;
    }
}

/* ===== MOBILE MENU FOOTER IMPROVEMENTS ===== */

@media (max-width: 768px) {
    .mobile-menu-container .mt-auto {
        margin-top: auto;
        padding: 16px 20px;
        background: #f9fafb;
        border-top: 1px solid #e5e7eb;
        text-align: center;
    }
    
    .mobile-menu-container .text-xs.text-gray-500 {
        font-size: 11px;
        color: #9ca3af;
        line-height: 1.4;
    }
}

/* ===== MOBILE MENU CLOSE BUTTON ===== */

@media (max-width: 768px) {
    .mobile-menu-container button[class*="text-white"] {
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        border: none;
        backdrop-filter: blur(10px);
    }
    
    .mobile-menu-container button[class*="text-white"]:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.1);
    }
    
    .mobile-menu-container button[class*="text-white"]:active {
        transform: scale(0.95);
    }
}

/* ===== MOBILE FORM BUTTONS IN MENU ===== */

@media (max-width: 768px) {
    .mobile-menu-container form {
        margin: 0;
        padding: 0;
    }
    
    .mobile-menu-container form button {
        width: 100%;
        text-align: left;
        border: none;
        background: none;
        font-family: inherit;
        font-size: 16px;
    }
    
    .mobile-menu-container form button:hover {
        background: rgba(239, 68, 68, 0.08);
        color: #dc2626;
    }
}

/* ===== MOBILE MENU SCROLL IMPROVEMENTS ===== */

@media (max-width: 768px) {
    .mobile-menu-container {
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }
    
    .mobile-menu-container::-webkit-scrollbar {
        width: 6px;
    }
    
    .mobile-menu-container::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .mobile-menu-container::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 3px;
    }
    
    .mobile-menu-container::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
}

/* ===== MOBILE SAFE AREA SUPPORT ===== */

@media (max-width: 768px) {
    /* Handle notched devices */
    .modern-nav {
        padding-top: env(safe-area-inset-top);
        height: calc(64px + env(safe-area-inset-top));
    }
    
    .mobile-menu-container {
        padding-top: env(safe-area-inset-top);
    }
    
    .mobile-menu-container .bg-gradient-to-r {
        padding-top: calc(20px + env(safe-area-inset-top));
    }
}

/* ===== MOBILE ACCESSIBILITY IMPROVEMENTS ===== */

@media (max-width: 768px) {
    /* Better focus indicators */
    .mobile-nav-item-enhanced:focus,
    .mobile-menu-btn:focus {
        outline: 2px solid #3b82f6;
        outline-offset: 2px;
    }
    
    /* High contrast support */
    @media (prefers-contrast: high) {
        .mobile-nav-item-enhanced {
            border: 1px solid transparent;
        }
        
        .mobile-nav-item-enhanced:hover,
        .mobile-nav-item-enhanced.active {
            border-color: #3b82f6;
            background: rgba(59, 130, 246, 0.1);
        }
    }
    
    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        .mobile-nav-item-enhanced,
        .mobile-nav-item-enhanced::before,
        .mobile-menu-btn {
            transition: none;
        }
        
        .mobile-nav-item-enhanced:hover {
            transform: none;
        }
    }
}

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

@media (max-width: 768px) {
    /* GPU acceleration for smooth animations */
    .mobile-menu-container {
        transform: translateZ(0);
        will-change: transform;
    }
    
    .mobile-nav-item-enhanced {
        transform: translateZ(0);
        will-change: transform, background-color;
    }
    
    /* Optimize touch scrolling */
    .mobile-menu-container {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
}

/* ===== MOBILE SPECIFIC UTILITIES ===== */

@media (max-width: 768px) {
    /* Hide desktop elements in mobile menu */
    .mobile-hidden {
        display: none !important;
    }
    
    /* Show only on mobile */
    .mobile-only {
        display: block !important;
    }
    
    /* Mobile-specific spacing */
    .mobile-spacing {
        padding: 16px !important;
        margin-bottom: 8px !important;
    }
    
    /* Touch-friendly sizing */
    .touch-friendly {
        min-height: 44px !important;
        min-width: 44px !important;
    }
}

/* ===== LANDSCAPE MOBILE ADJUSTMENTS ===== */

@media (max-width: 768px) and (orientation: landscape) {
    .mobile-menu-container {
        width: 380px;
        max-width: 70vw;
    }
    
    .mobile-nav-item-enhanced {
        padding: 12px 20px;
        font-size: 15px;
    }
    
    .mobile-menu-container .bg-gradient-to-r {
        padding: 16px 20px;
    }
    
    .mobile-menu-container h3 {
        font-size: 20px;
    }
    
    .mobile-menu-container .w-12 {
        width: 40px;
        height: 40px;
    }
}

/* ===== VERY SMALL SCREENS (320px and below) ===== */

@media (max-width: 320px) {
    .mobile-menu-container {
        width: 100vw;
        max-width: 100vw;
    }
    
    .nav-brand .text-2xl {
        font-size: 16px !important;
    }
    
    .nav-brand .text-xs {
        font-size: 9px !important;
    }
    
    .mobile-nav-item-enhanced {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    .mobile-nav-item-enhanced i {
        font-size: 18px;
        margin-right: 12px;
    }
}
