/**
 * Mobile Navigation & Responsive Fixes
 * Fixes overlapping, navigation menu, and mobile view issues
 * 
 * @version 1.0.0
 * @date 2026-04-15
 */

/* ===== MOBILE HEADER FIXES ===== */
@media (max-width: 768px) {
    /* Fix header overlapping content */
    .main-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: rgba(255, 255, 255, 0.98);
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        height: 70px;
    }

    .header-container {
        max-width: 100%;
        padding: 0 1rem;
        height: 70px;
        display: flex;
        align-items: center;
    }

    .main-nav {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0;
    }

    /* Logo fixes for mobile */
    .logo {
        display: flex;
        align-items: center;
        z-index: 10002;
    }

    .logo img {
        height: 40px;
        width: auto;
        max-width: 150px;
    }

    .logo-text {
        display: none; /* Hide text on mobile, show only logo */
    }

    /* Mobile menu button - Hamburger */
    .mobile-menu-button {
        display: flex !important;
        align-items: center;
        justify-content: center;
        z-index: 10002;
        width: 48px;
        height: 48px;
        min-width: 48px; /* Prevent shrinking */
        background: linear-gradient(135deg, #667eea, #764ba2);
        border: none;
        border-radius: 10px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        padding: 0;
        position: relative;
        transition: all 0.3s ease;
    }

    .mobile-menu-button:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    }

    .mobile-menu-button:active {
        transform: scale(0.95);
    }

    /* Hamburger icon lines */
    .mobile-menu-button span {
        display: block;
        width: 24px;
        height: 3px;
        background: white;
        border-radius: 2px;
        position: absolute;
        transition: all 0.3s ease;
    }

    .mobile-menu-button span:nth-child(1) {
        top: 14px;
    }

    .mobile-menu-button span:nth-child(2) {
        top: 22px;
    }

    .mobile-menu-button span:nth-child(3) {
        top: 30px;
    }

    /* Hamburger animation when active */
    .mobile-menu-button.active span:nth-child(1) {
        top: 22px;
        transform: rotate(45deg);
    }

    .mobile-menu-button.active span:nth-child(2) {
        opacity: 0;
        transform: translateX(-10px);
    }

    .mobile-menu-button.active span:nth-child(3) {
        top: 22px;
        transform: rotate(-45deg);
    }

    /* Mobile navigation panel */
    .nav-links {
        position: fixed !important;
        top: 70px !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: calc(100vh - 70px) !important;
        background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
        z-index: 10001 !important;
        padding: 1.5rem !important;
        flex-direction: column !important;
        display: flex !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
    }

    .nav-links.active {
        transform: translateX(0) !important;
    }

    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }

    /* Navigation links styling */
    .nav-links li {
        width: 100%;
        border-bottom: 1px solid #e2e8f0;
    }

    .nav-links li:last-child {
        border-bottom: none;
    }

    .nav-link {
        display: flex !important;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem 0.5rem !important;
        color: #1e293b !important;
        font-size: 1.1rem !important;
        font-weight: 600 !important;
        text-decoration: none;
        transition: all 0.2s ease;
        border-radius: 8px;
    }

    .nav-link:hover,
    .nav-link.active {
        background: rgba(102, 126, 234, 0.1);
        color: #667eea !important;
    }

    .nav-link svg {
        flex-shrink: 0;
        width: 20px;
        height: 20px;
    }

    /* Hide desktop CTA button */
    .header-cta {
        display: none !important;
    }

    /* Megamenu mobile fixes */
    .nav-item-has-megamenu {
        position: relative !important;
    }

    .megamenu {
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        max-height: 0 !important;
        overflow: hidden !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        transition: max-height 0.3s ease !important;
        background: #f8fafc !important;
        margin: 0 -0.5rem !important;
        padding: 0 !important;
    }

    .nav-item-has-megamenu.open .megamenu {
        max-height: 2000px !important;
    }

    .megamenu-container {
        padding: 1rem !important;
    }

    .megamenu-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
        padding: 1rem !important;
        margin-bottom: 1rem !important;
    }

    .megamenu-header h3 {
        font-size: 1.2rem !important;
        margin: 0 !important;
    }

    .megamenu-header p {
        font-size: 0.9rem !important;
        margin: 0 !important;
    }

    .megamenu-view-all {
        display: inline-block;
        margin-top: 0.5rem;
    }

    .megamenu-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .megamenu-column {
        margin-bottom: 1rem;
    }

    .megamenu-category {
        font-size: 1rem !important;
        padding: 0.75rem !important;
        background: white;
        border-radius: 8px;
        margin-bottom: 0.5rem;
        border: 1px solid #e2e8f0;
    }

    .megamenu-links {
        display: none;
        padding-left: 1rem;
    }

    .nav-item-has-megamenu.open .megamenu-links {
        display: block;
    }

    .megamenu-links a {
        padding: 0.5rem 0 !important;
        font-size: 0.95rem !important;
        color: #64748b;
    }

    .megamenu-links a:hover {
        color: #667eea;
        padding-left: 0.5rem;
    }

    .megamenu-cta {
        flex-direction: column !important;
        text-align: center !important;
        gap: 1rem !important;
        margin: 1rem 0 0 !important;
        padding: 1rem !important;
        background: white;
        border-radius: 8px;
    }

    /* Arrow rotation for mobile */
    .megamenu-arrow {
        margin-left: auto;
        transition: transform 0.3s ease;
    }

    .nav-item-has-megamenu.open .megamenu-arrow {
        transform: rotate(180deg);
    }
}

/* ===== SMALL MOBILE DEVICES (480px and below) ===== */
@media (max-width: 480px) {
    .main-header {
        height: 65px;
    }

    .header-container {
        height: 65px;
        padding: 0 0.75rem;
    }

    .logo img {
        height: 36px;
        max-width: 130px;
    }

    .mobile-menu-button {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }

    .mobile-menu-button span {
        width: 20px;
        height: 2.5px;
    }

    .mobile-menu-button span:nth-child(1) {
        top: 12px;
    }

    .mobile-menu-button span:nth-child(2) {
        top: 19px;
    }

    .mobile-menu-button span:nth-child(3) {
        top: 26px;
    }

    .mobile-menu-button.active span:nth-child(1),
    .mobile-menu-button.active span:nth-child(3) {
        top: 19px;
    }

    .nav-links {
        top: 65px !important;
        height: calc(100vh - 65px) !important;
        padding: 1rem !important;
    }

    .nav-link {
        padding: 0.875rem 0.5rem !important;
        font-size: 1rem !important;
    }

    .megamenu-header h3 {
        font-size: 1.1rem !important;
    }
}

/* ===== TOUCH TARGET OPTIMIZATION (Accessibility) ===== */
@media (max-width: 768px) {
    /* Ensure all touch targets are at least 44x44px */
    .nav-link,
    .mobile-menu-button,
    .megamenu-category,
    .megamenu-links a {
        min-height: 44px;
    }

    /* Improve scrolling on mobile menu */
    .nav-links {
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    .nav-links::-webkit-scrollbar {
        width: 6px;
    }

    .nav-links::-webkit-scrollbar-track {
        background: transparent;
    }

    .nav-links::-webkit-scrollbar-thumb {
        background-color: #cbd5e1;
        border-radius: 20px;
    }
}

/* ===== PAGE CONTENT SPACING FIXES ===== */
@media (max-width: 768px) {
    /* Add proper spacing for fixed header on all pages */
    main {
        padding-top: 70px !important;
    }

    /* Hero sections need less top padding on mobile */
    .hero-section,
    .contact-hero,
    .about-hero {
        padding-top: 2rem !important;
    }

    /* Ensure no horizontal overflow */
    body {
        overflow-x: hidden !important;
    }

    .header-container,
    .main-nav,
    .glossy-container {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
}

/* ===== LANDSCAPE MODE FIXES ===== */
@media (max-width: 768px) and (orientation: landscape) {
    .nav-links {
        max-height: 100vh;
        overflow-y: auto;
    }

    .nav-link {
        padding: 0.75rem 0.5rem !important;
    }
}

/* ===== ANIMATION PERFORMANCE ===== */
@media (max-width: 768px) {
    .nav-links,
    .mobile-menu-button span {
        will-change: transform;
    }

    .nav-links.active,
    .mobile-menu-button.active span {
        will-change: auto;
    }
}
