/**
 * JClick Solution - Modern Mega Menu Styles
 * Matches new-design.jpg design specifications
 */

/* ==========================================================================
   Desktop Navigation & Mega Menu (min-width: 992px)
   ========================================================================== */
@media (min-width: 992px) {
    /* Navbar Container Positioning */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1030;
    }

    .navbar > .container {
        position: relative;
    }

    #navbar {
        position: static !important;
    }

    .navbar-nav {
        position: static !important;
        align-items: center;
    }

    /* Top-level Nav Links */
    .navbar-nav .nav-item .nav-link {
        font-family: 'Outfit', sans-serif;
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
        padding: 10px 16px;
        transition: color 0.2s ease;
        position: relative;
    }

    .navbar-nav .nav-item .nav-link:hover,
    .navbar-nav .nav-item .nav-link.active {
        color: #2563EB;
    }

    /* Dropdown Chevron Animation */
    .navbar-nav .nav-item.dropdown .nav-link.dropdown-toggle {
        display: inline-flex;
        align-items: center;
    }

    .navbar-nav .nav-item.dropdown .nav-link.dropdown-toggle::after {
        content: "";
        display: inline-block;
        margin-left: 6px;
        vertical-align: middle;
        border-top: 5px solid currentColor;
        border-right: 4px solid transparent;
        border-bottom: 0;
        border-left: 4px solid transparent;
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .navbar-nav .nav-item.dropdown.is-active .nav-link.dropdown-toggle::after,
    .navbar-nav .nav-item.dropdown:hover .nav-link.dropdown-toggle::after {
        transform: rotate(180deg);
    }

    /* Mega Menu Dropdown Trigger */
    .navbar-nav .nav-item.dropdown-mega {
        position: static !important;
    }

    /* Standard Dropdown Menu (for non-mega items like About/Services) */
    .navbar-nav .nav-item.dropdown:not(.dropdown-mega) {
        position: relative;
    }

    .navbar-nav .nav-item.dropdown:not(.dropdown-mega) > .dropdown-menu {
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 8px;
        border: 1px solid rgba(0, 0, 0, 0.06);
        border-radius: 12px;
        box-shadow: 0 15px 35px -5px rgba(15, 23, 42, 0.12), 0 5px 15px rgba(0, 0, 0, 0.04);
        padding: 8px;
        background: #ffffff;
        min-width: 220px;
        display: block;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateY(-8px);
        transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
        z-index: 1000;
    }

    .navbar-nav .nav-item.dropdown:not(.dropdown-mega):hover > .dropdown-menu,
    .navbar-nav .nav-item.dropdown:not(.dropdown-mega).show > .dropdown-menu {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .navbar-nav .nav-item.dropdown:not(.dropdown-mega) .dropdown-item {
        padding: 9px 16px;
        color: #334155;
        font-size: 14px;
        font-weight: 500;
        border-radius: 6px;
        transition: all 0.18s ease;
    }

    .navbar-nav .nav-item.dropdown:not(.dropdown-mega) .dropdown-item:hover {
        background-color: #f1f5f9;
        color: #2563EB;
        transform: translateX(3px);
    }

    /* ==========================================================================
       Mega Menu Card Floating Container (Desktop)
       ========================================================================== */
    .mega-menu-wrapper {
        position: absolute;
        top: calc(100% + 10px);
        left: 50%;
        transform: translateX(-50%) translateY(-12px);
        width: calc(100% - 30px);
        max-width: 1240px;
        background: #ffffff;
        border-radius: 20px;
        box-shadow: 0 20px 50px -10px rgba(15, 23, 42, 0.16), 
                    0 10px 25px -5px rgba(15, 23, 42, 0.08), 
                    0 0 1px 1px rgba(0, 0, 0, 0.04);
        border: 1px solid rgba(0, 0, 0, 0.06);
        padding: 24px 24px 20px 24px;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.24s cubic-bezier(0.16, 1, 0.3, 1), 
                    transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), 
                    visibility 0.24s;
        z-index: 9999;
        max-height: calc(100vh - 90px);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: #cbd5e1 transparent;
    }

    .mega-menu-wrapper::-webkit-scrollbar {
        width: 6px;
    }

    .mega-menu-wrapper::-webkit-scrollbar-thumb {
        background-color: #cbd5e1;
        border-radius: 3px;
    }

    /* Open State */
    .nav-item.dropdown-mega:hover .mega-menu-wrapper,
    .nav-item.dropdown-mega.is-active .mega-menu-wrapper {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
    }

    /* Explicitly closed by button or toggle */
    .nav-item.dropdown-mega.is-closed .mega-menu-wrapper {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* Invisible bridge to prevent mouseleave gap */
    .nav-item.dropdown-mega::before {
        content: "";
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        height: 18px;
        display: block;
        z-index: 9998;
    }
}

/* ==========================================================================
   Mega Menu Internal Structure (4-Column Default Grid)
   ========================================================================== */
.mega-menu-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    width: 100%;
}

.mega-menu-col {
    padding: 0 14px;
    border-right: 1px solid #edf2f7;
    display: flex;
    flex-direction: column;
}

.mega-menu-col:first-child {
    padding-left: 2px;
}

.mega-menu-col:last-child {
    border-right: none;
    padding-right: 2px;
}

/* Close Button (Top Right of Card) */
.mega-menu-close {
    position: absolute;
    top: 14px;
    right: 18px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.18s ease;
    z-index: 10;
    padding: 0;
}

.mega-menu-close:hover {
    background: #e2e8f0;
    color: #0f172a;
    transform: scale(1.08);
}

/* Category Header Badges */
.mega-cat-header {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 14px;
    padding-bottom: 4px;
}

.mega-cat-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.mega-cat-icon svg {
    width: 22px;
    height: 22px;
}

.mega-cat-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.mega-cat-title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.2;
    margin: 0;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -0.01em;
}

.mega-cat-sub {
    font-size: 11px;
    font-weight: 500;
    color: #64748b;
    line-height: 1.3;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Category Color Themes */
/* 0. AI & Data: Indigo / Electric Blue */
.cat-ai .mega-cat-icon {
    background: #EEF2FF;
    color: #4F46E5;
}

/* 1. Civil / Architecture: Blue */
.cat-civil .mega-cat-icon {
    background: #EBF4FF;
    color: #2563EB;
}

/* 2. Mechanical: Peach / Coral */
.cat-mechanical .mega-cat-icon {
    background: #FFF1EB;
    color: #EA580C;
}

/* 3. IT Courses: Mint / Emerald */
.cat-it .mega-cat-icon {
    background: #E6F9F0;
    color: #059669;
}

/* 4. Electrical: Amber / Orange */
.cat-electrical .mega-cat-icon {
    background: #FFF7ED;
    color: #EA580C;
}

/* 5. Non-IT: Lavender / Purple */
.cat-nonit .mega-cat-icon {
    background: #FAF5FF;
    color: #7C3AED;
}

/* Course Items List */
.mega-course-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5px;
}

.mega-course-item {
    margin: 0;
    padding: 0;
}

.mega-course-link {
    display: block;
    padding: 5px 8px;
    border-radius: 6px;
    text-decoration: none !important;
    color: #334155;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.38;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.mega-course-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Course Item Hover States */
.mega-course-link:hover {
    color: #0f172a;
    transform: translateX(4px);
}

.cat-ai .mega-course-link:hover {
    color: #4F46E5;
    background: #eef2ff;
}

.cat-civil .mega-course-link:hover {
    color: #2563EB;
    background: #eff6ff;
}

.cat-mechanical .mega-course-link:hover {
    color: #EA580C;
    background: #fff7ed;
}

.cat-it .mega-course-link:hover {
    color: #059669;
    background: #ecfdf5;
}

.cat-electrical .mega-course-link:hover {
    color: #EA580C;
    background: #fff7ed;
}

.cat-nonit .mega-course-link:hover {
    color: #7C3AED;
    background: #f5f3ff;
}

/* ==========================================================================
   Mobile & Responsive Styles (max-width: 991px)
   ========================================================================== */
@media (max-width: 991px) {
    /* Top-level Nav Links in mobile sidebar */
    .navbar-nav .nav-item .nav-link {
        font-family: 'Outfit', sans-serif;
        font-size: 15px;
        font-weight: 600;
        color: #1e293b;
        padding: 12px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .navbar-nav .nav-item.dropdown .nav-link.dropdown-toggle::after {
        content: "";
        display: inline-block;
        margin-left: auto;
        vertical-align: middle;
        border-top: 5px solid currentColor;
        border-right: 4px solid transparent;
        border-bottom: 0;
        border-left: 4px solid transparent;
        transition: transform 0.2s ease;
    }

    .navbar-nav .nav-item.dropdown-mega.is-open-mobile > .nav-link.dropdown-toggle::after {
        transform: rotate(180deg);
    }

    /* Accordion Mega Menu inside Mobile Sidebar */
    .nav-item.dropdown-mega .mega-menu-wrapper {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        max-width: 100% !important;
        background: #f8fafc;
        border-radius: 10px;
        box-shadow: none;
        border: 1px solid #e2e8f0;
        padding: 12px 10px;
        margin: 6px 0 12px 0;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        display: none;
    }

    .nav-item.dropdown-mega.is-open-mobile > .mega-menu-wrapper {
        display: block !important;
        animation: fadeIn 0.22s ease;
    }

    .mega-menu-close {
        display: none !important;
    }

    .mega-menu-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 14px !important;
        grid-template-columns: none !important;
        width: 100% !important;
    }

    .mega-menu-col {
        border-right: none !important;
        border-bottom: 1px solid #e2e8f0 !important;
        padding: 0 0 12px 0 !important;
        width: 100% !important;
    }

    .mega-menu-col:last-child {
        border-bottom: none !important;
        padding-bottom: 0 !important;
    }

    .mega-cat-header {
        display: flex;
        align-items: center;
        gap: 10px;
        margin-bottom: 8px;
    }

    .mega-cat-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .mega-cat-icon svg {
        width: 18px;
        height: 18px;
    }

    .mega-cat-title {
        font-size: 14px;
        font-weight: 700;
    }

    .mega-cat-sub {
        font-size: 11px;
        white-space: normal;
    }

    .mega-course-link {
        padding: 6px 10px;
        font-size: 13.5px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
