/* ==========================================================================
   Mega Menu & Multi-level Dropdown Styles
   ========================================================================== */

/* --- Desktop Dropdown Hover --- */
@media (min-width: 992px) {
    .navbar .nav-item.dropdown:hover > .dropdown-menu {
        display: block;
        animation: fadeInDropdown 0.3s ease-in-out;
    }
    
    /* Smooth fade in for dropdowns */
    @keyframes fadeInDropdown {
        0% {
            opacity: 0;
            transform: translateY(10px);
        }
        100% {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Submenu (Dropdown within Dropdown) */
    .dropdown-submenu {
        position: relative;
    }
    
    .dropdown-submenu:hover > .dropdown-menu {
        display: block;
        animation: fadeInDropdown 0.3s ease-in-out;
    }

    .dropdown-submenu > .dropdown-menu {
        top: 0;
        right: 100%; /* RTL support */
        margin-top: -6px;
        margin-right: 0;
    }

    /* Caret rotation for submenus */
    .dropdown-submenu > a::after {
        transform: rotate(90deg);
        transition: transform 0.2s ease;
    }
    .dropdown-submenu:hover > a::after {
        transform: rotate(180deg);
    }
}

/* --- Mega Menu --- */
@media (min-width: 992px) {
    /* Ensure the navbar container is relatively positioned to constrain mega menu */
    .navbar > .container {
        position: relative;
    }

    .nav-item.mega-menu-parent {
        position: static !important;
    }

    .nav-item.mega-menu-parent > .dropdown-menu.mega-menu-content {
        width: 100%;
        left: 0;
        right: 0;
        top: 100%;
        border-radius: 0 0 1rem 1rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-top: 3px solid var(--bs-primary) !important;
        margin-top: 0;
    }

    .mega-menu-title {
        font-size: 1.1rem;
        color: #2c3e50;
        position: relative;
        padding-bottom: 0.5rem;
        margin-bottom: 1rem;
    }
    
    .mega-menu-title::after {
        content: "";
        position: absolute;
        bottom: 0;
        right: 0; /* RTL */
        width: 40px;
        height: 2px;
        background: var(--bs-primary);
        transition: width 0.3s ease;
    }
    
    .mega-menu-column:hover .mega-menu-title::after {
        width: 100%;
    }

    .mega-menu-column-list > li > a {
        padding: 0.5rem 0;
        color: #555;
        transition: all 0.2s ease;
        display: block;
        text-decoration: none;
    }

    .mega-menu-column-list > li > a:hover {
        color: var(--bs-primary);
        padding-right: 8px; /* RTL visual indent */
        background: transparent;
    }
}

/* --- Standard Dropdown Styles --- */
.dropdown-menu {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    padding: 0.5rem 0;
}

.dropdown-item {
    padding: 0.5rem 1.5rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: rgba(90, 111, 220, 0.08); /* Primary color with opacity */
    color: var(--bs-primary);
}

/* --- Mobile Menu Enhancements --- */
.offcanvas .mobile-submenu {
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.offcanvas .mobile-submenu .list-group-item {
    background-color: transparent;
    border: none;
    padding: 0.5rem 1rem;
}

.mobile-submenu-toggle {
    transition: transform 0.3s ease;
    background: white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.mobile-submenu-toggle[aria-expanded="true"] {
    transform: rotate(180deg);
    background: var(--bs-primary) !important;
    color: white !important;
}

.nav-link-mobile {
    font-size: 0.95rem;
}
