/* ===============================================
   MOBILE NAVBAR FIX - PROFESSIONAL LAYOUT
   Fixes overlapping issues on mobile/tablet
   =============================================== */

/* ================= TOP BAR - MOBILE OPTIMIZATION ================= */
@media (max-width: 768px) {
    .top-bar {
        padding: 8px 0;
        font-size: 12px;
    }

    .top-flex {
        display: flex;
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
        padding: 5px 0;
    }

    .top-flex span {
        display: inline-flex;
        align-items: center;
        font-size: 12px;
    }

    .top-bar i {
        font-size: 12px;
        margin-right: 5px;
    }
}

/* ================= NAVBAR - MOBILE FIXES ================= */
@media (max-width: 768px) {
    /* Ensure navbar doesn't overlap */
    .navbar {
        position: sticky;
        top: 0;
        z-index: 1000;
        background: #ffffff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* Navbar flex adjustments */
    .nav-flex {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 10px 0;
        height: auto;
        min-height: 60px;
    }

    /* Logo sizing and positioning */
    .logo {
        flex: 0 0 auto;
        max-width: 50%;
    }

    .logo img {
        height: 45px;
        width: auto;
        max-width: 100%;
    }

    .logo a {
        display: block;
    }

    /* Mobile menu toggle positioning */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        font-size: 1.5rem;
        color: #0b2c4f;
        cursor: pointer;
        padding: 10px;
        margin-left: auto;
        z-index: 1001;
        min-width: 44px;
        min-height: 44px;
    }

    /* Hide desktop navigation on mobile */
    nav {
        display: block;
    }

    .nav-links {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        background: #ffffff;
        flex-direction: column;
        gap: 0;
        padding: 80px 0 20px;
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.2);
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-links.active {
        left: 0;
    }

    /* Navigation items */
    .nav-links li {
        width: 100%;
        border-bottom: 1px solid #e9ecef;
        margin: 0;
    }

    .nav-links > li > a {
        display: block;
        padding: 16px 20px;
        width: 100%;
        color: #0b2c4f !important;
        text-shadow: none !important;
        font-weight: 600;
        text-decoration: none;
        transition: background 0.2s ease;
    }

    .nav-links > li > a:hover,
    .nav-links > li > a.active {
        background: #f8f9fa;
        color: #ff8c42 !important;
    }

    /* Remove underline animation on mobile */
    .nav-links a::after {
        display: none !important;
    }

    /* Dropdown styling for mobile */
    .dropdown {
        position: relative;
    }

    .dropdown > a {
        position: relative;
        padding-right: 45px !important;
    }

    .dropdown > a::before {
        content: "▼";
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.75rem;
        transition: transform 0.3s ease;
        color: #666;
    }

    .dropdown.active > a::before {
        transform: translateY(-50%) rotate(180deg);
    }

    .dropdown-menu {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        background: #f8f9fa;
        margin: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
        border-radius: 0;
    }

    .dropdown.active .dropdown-menu {
        max-height: 500px;
    }

    .dropdown-menu li {
        border-bottom: 1px solid #e0e0e0;
    }

    .dropdown-menu li:last-child {
        border-bottom: none;
    }

    .dropdown-menu a {
        padding: 14px 20px 14px 40px !important;
        background: #f8f9fa;
        color: #555 !important;
        font-weight: 500;
        font-size: 0.95rem;
        position: relative;
    }

    /* Add arrow icon to each service item */
    .dropdown-menu a::before {
        content: "→";
        position: absolute;
        left: 15px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 1rem;
        color: #ff8c42;
        font-weight: bold;
    }

    .dropdown-menu a:hover {
        background: #e9ecef;
        color: #ff8c42 !important;
        padding-left: 45px !important;
    }

    .dropdown-menu a:hover::before {
        left: 20px;
    }

    /* Contact button in mobile menu */
    .nav-btn {
        background: #ff8c42 !important;
        color: #ffffff !important;
        margin: 10px 20px;
        padding: 12px 20px !important;
        border-radius: 5px;
        text-align: center;
        display: block;
        width: calc(100% - 40px);
    }

    .nav-btn:hover {
        background: #ff6b1a !important;
    }

    /* Overlay when menu is open */
    .nav-links.active::after {
        content: '';
        position: fixed;
        top: 0;
        left: 280px;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: -1;
    }

    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
    }
}

/* ================= TABLET ADJUSTMENTS (768px - 991px) ================= */
@media (min-width: 769px) and (max-width: 991px) {
    .logo img {
        height: 55px;
    }

    .nav-links {
        gap: 20px;
    }

    .nav-links a {
        font-size: 0.9rem;
        padding: 8px 12px;
    }

    .nav-btn {
        padding: 8px 15px !important;
        font-size: 0.9rem;
    }
}

/* ================= HERO SECTION ADJUSTMENTS ================= */
@media (max-width: 768px) {
    /* Account for sticky navbar */
    .hero-fullscreen,
    .about-hero,
    .works-hero {
        margin-top: 0;
        padding-top: 80px;
    }

    .hero-fullscreen .navbar-transparent {
        position: absolute;
        background: transparent !important;
        box-shadow: none;
    }

    .navbar-transparent .mobile-menu-toggle {
        color: #ffffff;
    }

    .navbar-transparent .logo img {
        filter: brightness(1.3) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    }
}

/* ================= ENSURE NO OVERLAP ================= */
@media (max-width: 768px) {
    /* Clear spacing for content */
    main {
        margin-top: 0;
        padding-top: 0;
    }

    /* Ensure sections don't overlap navbar */
    section:first-of-type {
        margin-top: 0;
    }

    /* Fix for transparent navbar on homepage */
    .hero-fullscreen {
        position: relative;
    }
}

/* ================= SMALL PHONES (< 375px) ================= */
@media (max-width: 374px) {
    .logo img {
        height: 40px;
    }

    .mobile-menu-toggle {
        font-size: 1.3rem;
        padding: 8px;
    }

    .nav-links {
        width: 260px;
    }

    .top-flex {
        font-size: 11px;
    }

    .top-bar i {
        font-size: 11px;
    }
}

/* ================= LANDSCAPE MODE ON MOBILE ================= */
@media (max-width: 768px) and (orientation: landscape) {
    .nav-flex {
        min-height: 50px;
    }

    .logo img {
        height: 40px;
    }

    .nav-links {
        padding: 60px 0 20px;
    }

    .nav-links li a {
        padding: 12px 20px;
    }
}

/* ================= IPHONE SAFE AREAS ================= */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .navbar {
            padding-left: max(15px, env(safe-area-inset-left));
            padding-right: max(15px, env(safe-area-inset-right));
        }

        .nav-links {
            padding-bottom: max(20px, env(safe-area-inset-bottom));
        }

        .nav-links.active::after {
            left: max(280px, calc(280px + env(safe-area-inset-left)));
        }
    }
}

/* ================= PREVENT FLICKERING ================= */
.nav-links {
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* ================= IMPROVE TOUCH RESPONSE ================= */
@media (max-width: 768px) {
      /* Navigation links - subtle orange tap feedback */
    .nav-links a {
        -webkit-tap-highlight-color: rgba(255, 140, 66, 0.1);
    }

    /* Dropdown menu items */
    .dropdown-menu a {
        -webkit-tap-highlight-color: rgba(255, 140, 66, 0.1);
    }

    /* Mobile menu toggle - no highlight */
    .mobile-menu-toggle {
        -webkit-tap-highlight-color: transparent;
    }

    /* Buttons */
    .btn-primary,
    .btn-secondary,
    .nav-btn {
        -webkit-tap-highlight-color: rgba(255, 140, 66, 0.1);
    }

    /* Filter buttons */
    .filter-btn {
        -webkit-tap-highlight-color: rgba(255, 140, 66, 0.1);
    }

    /* Project cards */
    .project-card {
        -webkit-tap-highlight-color: rgba(255, 140, 66, 0.08);
    }

    /* Scroll to top button */
    .scroll-to-top {
        -webkit-tap-highlight-color: transparent;
    }

    /* Remove from non-interactive elements */
    body,
    div:not([class]),
    section,
    p,
    h1, h2, h3, h4, h5, h6 {
        -webkit-tap-highlight-color: transparent;
    }
}