/* 
 * YUNet - Navigation Styles
 * Version: 2.2
 * Fixed for mobile and desktop navigation
 */

/* Navigation container */
nav {
    display: flex;
    justify-content: center;
    align-items: center;
    height: var(--header-height);
    transition: height 0.3s ease;
    position: relative;
}

#main-header.scrolled nav {
    height: var(--header-height-scrolled);
}

/* Left & Right menu containers */
.left-menu, .right-menu {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

.left-menu {
    margin-right: 20px;
}

.right-menu {
    margin-left: 20px;
}

/* Centered logo */
.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.logo img {
    height: 45px;
    transition: height 0.3s ease;
}

#main-header.scrolled .logo img {
    height: 40px;
}

/* Navigation items */
.nav-item {
    position: relative;
    margin: 0 15px;
}

.nav-link {
    color: var(--dark);
    font-weight: 500;
    display: block;
    padding: 0.5rem 0;
    position: relative;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--blue);
}

/* Animated underline effect */
.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--blue);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after,
.nav-item:hover .nav-link::after {
    width: 100%;
}

/* Submenu styles */
.submenu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    z-index: 100;
    transition: all 0.3s ease;
    pointer-events: none;
}

.submenu::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid var(--white);
    z-index: 10;
}

.nav-item:hover .submenu {
    visibility: visible;
    opacity: 1;
    max-height: 1000px;
    pointer-events: auto;
}

.submenu-content {
    padding: 1.8rem;
    position: relative;
}

.submenu-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 5px;
    height: 100%;
    background: linear-gradient(to bottom, var(--blue), var(--green));
    border-radius: 2px 0 0 2px;
}

.submenu-content h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--blue);
}

.submenu-content p {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.submenu-links {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.submenu-links a {
    font-size: 0.9rem;
    padding: 0.5rem 0;
    color: var(--dark);
    transition: all 0.2s ease;
}

.submenu-links a:hover {
    color: var(--blue);
    transform: translateX(5px);
}

/* Dropdown toggle button (for mobile) */
.dropdown-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--gray);
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 5px;
}

/* Mobile menu toggle button */
.menu-toggle {
    display: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 30px;
    height: 24px;
    position: absolute;
    right: 0;
    z-index: 1001;
}

.menu-toggle span {
    display: block;
    position: absolute;
    height: 3px;
    width: 100%;
    background: var(--dark);
    border-radius: 3px;
    left: 0;
    transition: all 0.3s ease;
}

.menu-toggle span:nth-child(1) {
    top: 0;
}

.menu-toggle span:nth-child(2) {
    top: 10px;
}

.menu-toggle span:nth-child(3) {
    top: 20px;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg);
    top: 10px;
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
    width: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg);
    top: 10px;
}

/* Get involved buttons */
.get-involved-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.get-involved-buttons .cta-button {
    flex: 1;
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
}

/* Mobile navigation wrapper (only shown on mobile) */
.nav-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* Mobile navigation fixes */

@media (max-width: 992px) {
    /* Fixed positioning for mobile menu toggle */
    .menu-toggle {
        display: block;
        position: absolute;
        right: 15px;
        top: 50%;
        transform: translateY(-50%);
        z-index: 1001;
    }
    
    /* Create a mobile nav container that slides in from right */
    .nav-wrapper {
        display: block;
        position: fixed;
        top: 0;
        right: -300px; /* Start off-screen */
        width: 280px;
        height: 100vh;
        background: var(--white);
        padding: 80px 20px 20px;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        z-index: 999;
        overflow-y: auto;
    }
    
    /* When active, slide in from right */
    .nav-wrapper.active {
        right: 0;
    }
    
    /* For compatibility with older structure - direct menu handling */
    nav > .left-menu,
    nav > .right-menu {
        position: fixed;
        top: 0;
        right: -300px;
        width: 280px;
        height: 100vh;
        background: var(--white);
        padding: 80px 20px 20px;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        transition: right 0.3s ease;
        z-index: 999;
        flex-direction: column;
        margin: 0;
    }
    
    nav > .left-menu.active,
    nav > .right-menu.active {
        right: 0;
    }
    
    /* Combined layout for menus in mobile mode */
    .left-menu, .right-menu {
        flex-direction: column;
        width: 100%;
        margin: 0;
    }
    
    .right-menu {
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid var(--light-gray);
    }
    
    /* Menu items in mobile view */
    .nav-item {
        margin: 0;
        margin-bottom: 10px;
        width: 100%;
        position: relative;
    }
    
    .nav-link {
        padding: 12px 0;
        width: calc(100% - 40px);
        font-size: 16px;
    }
    
    /* Remove hover effects for mobile */
    .nav-link::after {
        display: none;
    }
    
    /* Show dropdown toggle in mobile */
    .dropdown-toggle {
        display: block;
        width: 30px;
        height: 30px;
        font-size: 20px;
        line-height: 30px;
        text-align: center;
    }
    
    /* Mobile submenu styling */
    .submenu {
        position: static;
        transform: none;
        width: 100%;
        max-height: 0;
        box-shadow: none;
        margin-top: 0;
        border-radius: 5px;
        background-color: rgba(0, 139, 189, 0.05);
        transition: max-height 0.3s ease, opacity 0.3s ease;
        overflow: hidden;
    }
    
    .submenu::before {
        display: none;
    }
    
    /* Disable hover behavior in mobile */
    .nav-item:hover .submenu {
        visibility: hidden;
        opacity: 0;
        max-height: 0;
        pointer-events: none;
    }
    
    /* Active state for mobile dropdowns */
    .nav-item.active .submenu {
        visibility: visible;
        opacity: 1;
        max-height: 1000px;
        pointer-events: auto;
        padding: 10px 0;
    }
    
    /* Submenu content styling */
    .submenu-content {
        padding: 10px 15px;
    }
    
    .submenu-content::before {
        width: 3px;
    }
    
    .submenu-content h3 {
        font-size: 16px;
    }
    
    .submenu-content p {
        font-size: 14px;
        margin-bottom: 15px;
    }
    
    .submenu-links {
        grid-template-columns: 1fr;
    }
    
    .submenu-links a {
        padding: 8px 0;
    }
    
    /* Get involved buttons in mobile */
    .get-involved-buttons {
        flex-direction: column;
    }
    
    .get-involved-buttons .cta-button {
        margin-bottom: 10px;
    }
    
    /* Dark overlay for mobile menu */
    .menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease;
    }
    
    body.menu-open .menu-overlay {
        opacity: 1;
        visibility: visible;
    }
}

/* Improved focus states for accessibility */
.nav-link:focus,
.dropdown-toggle:focus,
.menu-toggle:focus {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* For touch devices - better touch interaction */
@media (hover: none) {
    .nav-item:hover .submenu {
        visibility: hidden;
        opacity: 0;
        max-height: 0;
        pointer-events: none;
    }
    
    .nav-item.touch-active .submenu {
        visibility: visible;
        opacity: 1;
        max-height: 1000px;
        pointer-events: auto;
    }
    
    /* Larger touch targets for mobile */
    .nav-link, 
    .dropdown-toggle,
    .submenu-links a {
        padding: 12px 0;
    }
}