/* Mobile menu */
.nav-menu {
    max-height: 0;
    overflow: hidden;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    visibility: hidden;
    opacity: 0;
}

.nav-menu.active {
    max-height: 100vh;
    visibility: visible;
    opacity: 1;
}

/* Desktop menu */
@media (min-width: 768px) {
    .nav-menu {
        max-height: none;
        overflow: visible;
        visibility: visible;
        opacity: 1;
    }
}

/* Background */
.page-background {
    background-image: url('/static/images/backgrounds/main-bg.jpg');
    background-size: cover;
    background-repeat: no-repeat;
    background-color: #151515;
    background-position: top center;
}

/* Navigation items */
.nav-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-item button,
.nav-item a {
    height: 100%;
    display: flex;
    align-items: center;
    white-space: nowrap;
    padding: 0.75rem 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

/* Dropdowns */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 200px;
    background-color: white;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 9999;
    margin-top: 0.25rem;
    overflow: hidden;
}

/* Right-align last two dropdowns */
.nav-item:nth-last-child(1) .dropdown-menu,
.nav-item:nth-last-child(2) .dropdown-menu {
    left: auto;
    right: 0;
}

.dropdown-menu.show {
    display: block !important;
}

.dropdown-menu a {
    display: block;
    padding: 1rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.dropdown-menu a div:first-child {
    color: #374151;
    margin-bottom: 0.25rem;
}

.dropdown-menu a div:last-child {
    color: #6b7280;
    line-height: 1.25;
}

.dropdown-menu a:hover {
    background-color: #a21caf;
}

.dropdown-menu a:hover div {
    color: white;
}

/* Only last item should have rounded corners */
.dropdown-menu a:last-child {
    border-bottom-left-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* First item should have square corners */
.dropdown-menu a:first-child {
    border-radius: 0;
}

/* Mobile-specific styles */
@media (max-width: 767px) {
    /* Container adjustments */
    .nav-menu {
        padding: 0;
        height: 0;
        transform: translateY(-20px);
        transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-menu.active {
        height: auto;
        padding: 0.5rem 0;
        transform: translateY(0);
    }

    .nav-menu > div {
        display: flex;
        flex-direction: column;
        width: 100%;
        opacity: 0;
        transform: translateY(-20px);
        transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
    }

    .nav-menu.active > div {
        opacity: 1;
        transform: translateY(0);
    }

    /* Navigation items */
    .nav-item {
        flex-direction: column;
        align-items: stretch;
        margin: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        height: auto;
        width: 100%;
        opacity: 0;
        transform: translateY(-10px);
        transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .nav-menu.active .nav-item {
        opacity: 1;
        transform: translateY(0);
    }

    /* Staggered animation delays using nth-child selectors */
    .nav-menu.active .nav-item:nth-child(1) {
        transition-delay: 0s;
    }

    .nav-menu.active .nav-item:nth-child(2) {
        transition-delay: 0.1s;
    }

    .nav-menu.active .nav-item:nth-child(3) {
        transition-delay: 0.2s;
    }

    .nav-menu.active .nav-item:nth-child(4) {
        transition-delay: 0.3s;
    }

    .nav-menu.active .nav-item:nth-child(5) {
        transition-delay: 0.4s;
    }

    .nav-menu.active .nav-item:nth-child(6) {
        transition-delay: 0.5s;
    }

    .nav-menu.active .nav-item:nth-child(7) {
        transition-delay: 0.6s;
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    .nav-item button,
    .nav-item a {
        width: 100%;
        padding: 0.75rem 1rem;
        justify-content: flex-start;
        color: white;
        font-weight: 500;
        height: auto;
    }

    .nav-item button:hover,
    .nav-item a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    /* Dropdown menus */
    .dropdown-menu {
        position: static;
        box-shadow: none;
        background-color: transparent;
        min-width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
        transform: translateY(-5px);
        transition: all 0.25s ease-out;
        overflow: visible;
    }

    /* Remove desktop styles in mobile */
    .dropdown-menu a {
        padding: 0.75rem 1.5rem;
        background-color: rgba(0, 0, 0, 0.2);
        margin-bottom: 1px;
    }

    .dropdown-menu a:last-child {
        margin-bottom: 0;
    }

    .dropdown-menu a div:first-child {
        color: white;
        font-size: 0.875rem;
        margin-bottom: 0.125rem;
    }

    .dropdown-menu a div:last-child {
        color: rgba(255, 255, 255, 0.7);
        font-size: 0.75rem;
    }

    .dropdown-menu a:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }

    .dropdown-menu a:hover div:first-child,
    .dropdown-menu a:hover div:last-child {
        color: white;
    }

    /* Remove rounded corners in mobile view */
    .dropdown-menu a:first-child,
    .dropdown-menu a:last-child {
        border-radius: 0;
    }

    .dropdown-menu.show {
        transform: translateY(0);
    }

    /* Dropdown toggle buttons */
    .dropdown-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        background: none;
        border: none;
        cursor: pointer;
        height: auto;
    }

    .dropdown-toggle svg {
        transition: transform 0.25s ease-out;
    }

    .dropdown-toggle[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }
}

/* Desktop-specific styles */
@media (min-width: 768px) {
    .nav-menu {
        justify-content: flex-start;
        position: relative;
        height: 3.5rem;
    }

    .nav-item {
        flex: 0 0 auto;
    }

    .nav-menu > div {
        display: flex;
        align-items: center;
        height: 100%;
    }

    .nav-item + .nav-item {
        margin-left: 1rem;
    }
}

/* Adjust spacing for medium screens */
@media (min-width: 768px) and (max-width: 800px) {
    .nav-item + .nav-item {
        margin-left: 0.5rem;
    }
}

/* Fix for Firefox */
@-moz-document url-prefix() {
    .dropdown-menu {
        margin-top: 0;
    }
}

/* Fix for Safari */
@media not all and (min-resolution:.001dpcm) {
    @supports (-webkit-appearance:none) {
        .dropdown-menu {
            margin-top: 0;
        }
    }
}