/* MGC Safety Nets - Menu Stylesheet - 4 LEVELS FIXED */

.main-nav {
    position: relative;
}

.mobile-menu-toggle {
    display: none;
    font-size: 28px;
    cursor: pointer;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    transition: all 0.3s ease;
    z-index: 1001;
    position: relative;
    pointer-events: auto;
}

.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 5px;
    margin: 0;
    padding: 0;
}

.nav-menu > li {
    position: relative;
}

.nav-menu > li > a {
    display: block;
    padding: 15px 20px;
    color: #1a1a2e;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-radius: 5px;
}

.nav-menu > li > a:hover,
.nav-menu > li > a.active {
    background: rgba(0, 0, 0, 0.05);
    color: #0066cc;
}

/* Dropdown Styles */
.dropdown {
    position: relative;
}

/* Extend hover area downward to bridge gap with level 1 */
.dropdown::before {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    right: 0;
    height: 5px;
    display: block;
}

.dropbtn {
    cursor: pointer;
}

.arrow {
    font-size: 12px;
    margin-left: 5px;
    transition: transform 0.3s ease;
}

.dropdown:hover > .dropbtn .arrow {
    transform: rotate(180deg);
}

.arrow-right {
    float: right;
    margin-left: 10px;
}

/* Dropdown Content - Base Styles */
.dropdown-content {
    display: none;
    position: absolute;
    background: #ffffff;
    min-width: 220px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    z-index: 1000;
    padding: 10px 0;
}

/* Level 1 Dropdown - Main Services Menu */
.dropdown-content.level-1 {
    top: 100%;
    left: 0;
    margin-top: -2px;
}

.dropdown-content a {
    color: #1a1a2e;
    padding: 12px 20px;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
    border-radius: 5px;
    margin: 0 10px;
}

.dropdown-content a:hover {
    background: rgba(0, 0, 0, 0.05);
    padding-left: 25px;
    color: #0066cc;
}

/* Dropdown Item Container */
.dropdown-item {
    /* Remove position: relative so child dropdowns position relative to .dropdown-content */
}

/* Extend hover area to bridge gap */
.dropdown-item::after {
    content: '';
    position: absolute;
    top: 0;
    right: -5px;
    bottom: 0;
    width: 5px;
    display: block;
    pointer-events: auto;
}

.dropdown-item > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Level 2 Dropdown - City Names - Aligned to top */
.dropdown-item > .dropdown-content.level-2 {
    position: absolute;
    left: 100%;
    top: 10px;
    margin-left: -2px;
}

/* Level 3 Dropdown - Service Types - Aligned to top */
.dropdown-item .dropdown-item > .dropdown-content.level-3 {
    position: absolute;
    left: 100%;
    top: 10px;
    margin-left: -2px;
    max-height: 400px;
    overflow-y: auto;
}

/* Level 4 Dropdown - Area Names - Aligned to top */
.dropdown-item .dropdown-item .dropdown-item > .dropdown-content.level-4 {
    position: absolute;
    left: 100%;
    top: 10px;
    margin-left: -2px;
    max-height: 400px;
    overflow-y: auto;
}

/* Custom Scrollbar for Level 3 and 4 */
.dropdown-content.level-3::-webkit-scrollbar,
.dropdown-content.level-4::-webkit-scrollbar {
    width: 8px;
}

.dropdown-content.level-3::-webkit-scrollbar-track,
.dropdown-content.level-4::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.dropdown-content.level-3::-webkit-scrollbar-thumb,
.dropdown-content.level-4::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 10px;
}

.dropdown-content.level-3::-webkit-scrollbar-thumb:hover,
.dropdown-content.level-4::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.7);
}

/* CRITICAL: Show all 4 levels on hover - Desktop Only */
@media (min-width: 1025px) {
    /* Level 1 - Show when hovering main dropdown */
    .dropdown:hover > .dropdown-content.level-1 {
        display: block;
    }
    
    /* Level 2 - Show when hovering dropdown item */
    .dropdown-item:hover > .dropdown-content.level-2 {
        display: block;
    }
    
    /* Level 3 - Show when hovering nested dropdown item */
    .dropdown-item .dropdown-item:hover > .dropdown-content.level-3 {
        display: block;
    }
    
    /* Level 4 - Show when hovering deeply nested dropdown item */
    .dropdown-item .dropdown-item .dropdown-item:hover > .dropdown-content.level-4 {
        display: block;
    }
}

/* Mobile Responsive - CLICK BEHAVIOR */
/* Mobile menu backdrop */
body.menu-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
    animation: fadeIn 0.3s ease;
    pointer-events: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: -100%;
        width: 100%;
        max-width: 100vw;
        height: 100vh;
        background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
        padding: 80px 15px 20px 15px;
        box-shadow: -5px 0 30px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
        overflow-x: hidden;
        transition: right 0.3s ease;
        z-index: 1002;
        -webkit-overflow-scrolling: touch;
        pointer-events: auto;
    }
    
    /* Custom scrollbar for mobile menu */
    .nav-menu::-webkit-scrollbar {
        width: 6px;
    }
    
    .nav-menu::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
    }
    
    .nav-menu::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.5);
        border-radius: 3px;
    }
    
    .nav-menu::-webkit-scrollbar-thumb:hover {
        background: rgba(102, 126, 234, 0.7);
    }
    
    .nav-menu.active {
        display: flex;
        right: 0;
    }
    
    /* Mobile Menu Close Button */
    .nav-menu.active::before {
        content: '✕';
        position: absolute;
        top: 20px;
        right: 20px;
        font-size: 30px;
        color: white;
        cursor: pointer;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.1);
        border-radius: 50%;
        z-index: 10001;
    }
    
    .nav-menu > li {
        width: 100%;
    }
    
    .nav-menu > li > a {
        padding: 15px;
    }
    
    /* Mobile Dropdown Adjustments - All Levels */
    .dropdown-content {
        position: static !important;
        display: none;
        margin: 5px 0;
        border-radius: 8px;
        box-shadow: none;
        left: auto !important;
        right: auto !important;
        top: auto !important;
        padding: 8px;
        width: 100%;
    }
    
    /* Level 1 - Services Dropdown (Purple) */
    .dropdown-content.level-1 {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
        border-left: 4px solid #667eea;
        padding-left: 12px;
    }
    
    .dropdown.active > .dropdown-content.level-1 {
        display: block;
    }
    
    /* Level 2 - Cities (Green) */
    .dropdown-item > .dropdown-content.level-2 {
        background: linear-gradient(135deg, rgba(72, 187, 120, 0.15) 0%, rgba(56, 178, 172, 0.15) 100%);
        border-left: 4px solid #48bb78;
        margin: 5px 0;
        display: none;
        padding-left: 12px;
    }
    
    .dropdown-item.active > .dropdown-content.level-2 {
        display: block !important;
    }
    
    /* Level 3 - Service Types (Orange) */
    .dropdown-item .dropdown-item > .dropdown-content.level-3 {
        background: linear-gradient(135deg, rgba(237, 137, 54, 0.15) 0%, rgba(245, 101, 101, 0.15) 100%);
        border-left: 4px solid #ed8936;
        margin: 5px 0;
        max-height: none;
        display: none;
        padding-left: 12px;
    }
    
    .dropdown-item .dropdown-item.active > .dropdown-content.level-3 {
        display: block !important;
    }
    
    /* Mobile links styling with better colors */
    .dropdown-content.level-1 > .dropdown-item > a {
        color: #c7d2fe !important;
        padding: 12px 10px;
        display: block;
        border-radius: 6px;
        transition: all 0.3s ease;
        width: 100%;
    }
    
    .dropdown-content.level-1 > .dropdown-item > a:hover {
        background: rgba(102, 126, 234, 0.2);
        transform: translateX(3px);
    }
    
    .dropdown-content.level-2 > .dropdown-item > a,
    .dropdown-content.level-2 > a {
        color: #9ae6b4 !important;
        padding: 10px 10px;
        display: block;
        border-radius: 6px;
        transition: all 0.3s ease;
        font-size: 14px;
        width: 100%;
    }
    
    .dropdown-content.level-2 > .dropdown-item > a:hover,
    .dropdown-content.level-2 > a:hover {
        background: rgba(72, 187, 120, 0.2);
        transform: translateX(3px);
    }
    
    .dropdown-content.level-3 > a {
        color: #fbd38d !important;
        padding: 9px 10px;
        display: block;
        border-radius: 6px;
        transition: all 0.3s ease;
        font-size: 13px;
        width: 100%;
    }
    
    .dropdown-content.level-3 > a:hover {
        background: rgba(237, 137, 54, 0.2);
        transform: translateX(3px);
    }
    
    /* Mobile menu arrows - make them visible and animated */
    .nav-menu .arrow,
    .nav-menu .arrow-right {
        display: inline-block;
        margin-left: 5px;
        transition: transform 0.3s ease;
        font-size: 14px;
        opacity: 1;
        font-weight: bold;
    }
    
    /* Level 1 arrow (Services dropdown) */
    .dropdown.active > .dropbtn .arrow {
        transform: rotate(180deg);
    }
    
    /* Level 2 and 3 arrows - point right initially */
    .dropdown-content .dropdown-item > a .arrow-right {
        float: right;
        margin-right: 5px;
        display: inline-block;
        transition: transform 0.3s ease;
    }
    
    /* Rotate arrow down when active */
    .dropdown-item.active > a .arrow-right {
        transform: rotate(90deg);
    }
    
    /* Add background highlight on active items */
    .dropdown-item.active > a {
        background: rgba(255, 255, 255, 0.15) !important;
        font-weight: 600;
    }
    
    /* Make clickable areas larger on mobile */
    .nav-menu a {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
    }
    
    /* Top level menu items on mobile */
    .nav-menu > li > a {
        color: #ffffff !important;
        font-size: 16px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .nav-menu > li > a:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    
}

@media (max-width: 768px) {
    .nav-menu {
        width: 100%;
        padding: 70px 10px 20px 10px;
    }
    
    .nav-menu > li > a {
        padding: 12px 10px;
        font-size: 14px;
    }
    
    .dropdown-content a {
        padding: 10px 15px;
        font-size: 14px;
    }
}

/* Smooth Animation for All Dropdowns */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}