/* Nested Dropdown Styles */
.dropdown-menu {
    display: none;
    position: absolute;
    background-color: #fff;
    min-width: 220px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    list-style: none;
    padding: 0.5rem 0;
    border-radius: 8px;
    border: 1px solid #f1f5f9;
}

@media (max-width: 768px) {

    /* Base mobile dropdown state - hidden via max-height instead of display */
    .dropdown-menu {
        display: block !important;
        /* Override style.css */
        position: static !important;
        box-shadow: none !important;
        background-color: transparent !important;
        border: none !important;
        padding-left: 1rem !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        width: 100%;
        margin-top: 0 !important;

        /* Accordion transition for smooth vertical sliding */
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.4s ease-out, opacity 0.3s ease-out, margin 0.3s ease-out, padding 0.3s ease-out;
    }

    /* Active mobile dropdown state */
    .dropdown.active>.dropdown-menu,
    .dropdown-submenu.active>.dropdown-menu {
        max-height: 1500px;
        opacity: 1;
        margin-top: 0.5rem !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        transition: max-height 0.5s ease-in, opacity 0.4s ease-in, margin 0.4s ease-in, padding 0.4s ease-in;
    }
}

/* Show dropdown on hover - Only direct child */
@media (min-width: 769px) {
    .dropdown:hover>.dropdown-menu {
        display: block;
    }
}

/* Link Styles */
.dropdown-item {
    color: var(--text-dark);
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    display: block;

    transition: all 0.2s;
    font-size: 0.95rem;
    position: relative;
    /* For submenu positioning */
}

.dropdown-item:hover {
    background-color: #f8fafc;
    color: var(--primary-blue);
    padding-left: 1.75rem;
}

@media (max-width: 768px) {
    .dropdown-item {
        padding: 0.6rem 1rem;
        color: #f8fafc;
    }
}

/* Submenu Styles */
.dropdown-submenu {
    position: relative;
}

@media screen and (min-width: 769px) {
    .dropdown-submenu .dropdown-menu {
        top: 0;
        left: 100%;
        /* Position to the right */
        margin-top: -5px;
        margin-left: 0;
        display: none;
    }

    /* Show submenu on hover */
    .dropdown-submenu:hover>.dropdown-menu {
        display: block;
    }
}

@media screen and (max-width: 768px) {
    .dropdown-submenu .dropdown-menu {
        /* Base mobile submenu state - hidden via max-height */
        display: block !important;
        /* Override default display: none */
        position: static !important;
        box-shadow: none !important;
        margin-top: 0;
        margin-left: 0;
        padding-left: 0.5rem !important;
        background-color: rgba(0, 0, 0, 0.03) !important;
        border-radius: 6px;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transition: max-height 0.4s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out;
    }
}

/* Arrow indicator */
.dropdown-submenu>a::after {
    content: "›";
    position: absolute;
    right: 1rem;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1rem;
    transition: transform 0.3s ease;
}

@media screen and (max-width: 768px) {
    .dropdown-submenu>a::after {
        content: "▼";
        font-size: 0.8rem;
        line-height: 1.2rem;
    }

    .dropdown-submenu.active>a::after {
        transform: rotate(180deg);
    }
}

/* Main dropdown arrow transition for mobile */
.dropdown>.nav-link::after {
    display: inline-block;
    transition: transform 0.3s ease;
}

@media (max-width: 768px) {
    .dropdown>.nav-link {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .dropdown.active>.nav-link::after {
        transform: rotate(180deg);
    }
}