/* Base navigation styles */
.main-nav {
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 0;
    transition: all 0.3s ease;
}

body.dark-mode .main-nav {
    background-color: rgba(26, 31, 46, 0.98);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-list {
    list-style-type: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin: 0 1.5rem;
    position: relative;
    animation: fadeInDown 0.5s ease forwards;
    opacity: 0;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.5rem 0;
    transition: all 0.3s ease;
    position: relative;
    display: inline-block;
}

body.dark-mode .nav-link {
    color: var(--dark-text-color);
}

.nav-link:hover, .nav-link:focus {
    color: var(--primary-color);
}

body.dark-mode .nav-link:hover, body.dark-mode .nav-link:focus {
    color: var(--dark-primary-color);
}

.nav-indicator {
    position: absolute;
    bottom: -5px;
    left: 0;
    height: 3px;
    width: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

body.dark-mode .nav-indicator {
    background-color: var(--dark-primary-color);
}

.nav-link:hover .nav-indicator, .nav-link:focus .nav-indicator {
    width: 100%;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    background-color: rgba(66, 153, 225, 0.1);
    border-radius: 50%;
    transition: all 0.5s ease;
    z-index: -1;
}

body.dark-mode .nav-item::before {
    background-color: rgba(127, 179, 236, 0.1);
}

.nav-item:hover::before {
    width: 180%;
    height: 180%;
}


/* Hamburger menu button */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
}

.nav-toggle span {
    display: block;
    width: 25px;
    height: 2px;
    background-color: var(--text-color);
    margin: 5px 0;
    transition: all 0.3s ease;
}

body.dark-mode .nav-toggle span {
    background-color: var(--dark-text-color);
}


/* Mobile styles */
@media (max-width: 768px) {
    .nav-toggle {
        display: block;
        position: relative;
        z-index: 1002; /* Ensure button stays above overlay */
    }

    .nav-list {
        position: fixed;
        top: 0;
        right: -100%;
        width: 70%;
        max-width: 300px;
        height: 100%;
        background-color: var(--surface-color);
        flex-direction: column;
        padding: 5rem 2rem;
        transition: right 0.3s ease;
        box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
        z-index: 1001; /* Above overlay */
    }

    body.dark-mode .nav-list {
        background-color: var(--dark-surface-color);
    }

    /* When menu is open */
    .nav-list.active {
        right: 0;
    }

    /* Overlay positioning fixed */
    .nav-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1000; /* Below menu, above other content */
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .nav-overlay.active {
        display: block;
        opacity: 1;
    }

    /* When menu is open */
    .nav-list.active {
        right: 0;
    }

    /* Hamburger animation when active */
    .nav-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

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

    .nav-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    .nav-item {
        margin: 0.8rem 0;
        width: 100%;
        text-align: left;
        opacity: 0;
        transform: translateX(20px);
    }

    .nav-list.active .nav-item {
        opacity: 1;
        transform: translateX(0);
        transition: all 0.3s ease;
    }

    /* Stagger animation for menu items */
    .nav-list.active .nav-item:nth-child(1) { transition-delay: 0.1s; }
    .nav-list.active .nav-item:nth-child(2) { transition-delay: 0.2s; }
    .nav-list.active .nav-item:nth-child(3) { transition-delay: 0.3s; }
    .nav-list.active .nav-item:nth-child(4) { transition-delay: 0.4s; }

    .nav-link {
        width: 100%;
        padding: 0.7rem 0;
        font-size: 1.1rem;
        color: var(--text-color);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    body.dark-mode .nav-link {
        color: var(--dark-text-color);
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .nav-link:hover, .nav-link:focus {
        color: var(--primary-color);
        padding-left: 0.5rem;
    }

    body.dark-mode .nav-link:hover, 
    body.dark-mode .nav-link:focus {
        color: var(--dark-primary-color);
    }

    .nav-indicator {
        display: none;
    }
}

/* Prevent body scroll when menu is open */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}