/* Mega Menu Styles */
@media (min-width: 992px) {
    .header-nav {
        position: static !important;
    }
}

.header-nav .nav>li.has-mega-menu {
    position: static !important;
}

.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    /* Will be 100% of header because of static parents */
    background: #fff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    border-top: 1px solid #eee;
    padding: 20px 0 20px 0;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 90vh;
}

/* Custom Scrollbar for Mega Menu - only appears if needed */
.mega-menu::-webkit-scrollbar {
    width: 6px;
}

.mega-menu::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.mega-menu::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.mega-menu::-webkit-scrollbar-thumb:hover {
    background: #0ABAB5;
}

.header-nav .nav>li.has-mega-menu:hover .mega-menu,
.header-nav .nav>li.has-mega-menu.active-menu .mega-menu {
    opacity: 1;
    visibility: visible;
}


.mega-menu-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

.categories-row {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
    padding: 0 15px 20px 15px;
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 115px;
}

.category-item:hover,
.category-item.active {
    background: #e5f0ef;
    transform: translateY(-5px);
}

.category-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.category-item:hover .category-icon {
    transform: scale(1.1);
}

.category-name {
    font-size: 11px;
    font-weight: 500;
    color: #1a1a1a;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.subcategories-container {
    display: none;
    padding: 30px 15px;
    grid-template-columns: repeat(5, 1fr);
    justify-content: center;
    gap: 30px;
    position: relative;
}

.subcategories-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -2000px;
    right: -2000px;
    bottom: 0;
    /* Bleed down */
    background: #f4f5f7;
    z-index: -1;
    border-top: 1px solid #eee;
}

.subcategories-container.active {
    display: grid;
}

.subcategory-group h4 {
    font-size: 16px;
    color: #0ABAB5; /* Restored primary color */
    margin-bottom: 0;
    padding: 8px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    border-bottom: 1px solid #0ABAB5; /* Restored underline */
    width: 100%;
}

.subcategory-group:hover h4 {
    color: #0ABAB5;
    background: transparent; /* No background needed if we have underline */
}

.subcategory-group h4::after {
    content: '\e92e'; /* feather chevron-right */
    font-family: 'feather';
    font-size: 14px;
    transition: transform 0.3s ease;
    opacity: 0.7;
    margin-left: 10px;
}

.subcategory-group:hover h4::after {
    transform: rotate(90deg);
}


.subcategory-list {
    list-style: none !important; /* Force override common ul styles */
    padding: 0 12px !important;
    max-height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    display: block !important; /* Ensure block for animation */
}

.subcategory-group:hover .subcategory-list {
    max-height: 1000px !important;
    opacity: 1 !important;
    visibility: visible !important;
    margin-top: 10px !important;
    margin-bottom: 10px !important;
}



.subcategory-item {
    margin-bottom: 8px;
}

.subcategory-item a {
    color: #666;
    font-size: 14px;
    transition: all 0.2s ease;
    text-decoration: underline; /* Added underline as requested */
    text-underline-offset: 3px;
    text-decoration-color: rgba(0, 0, 0, 0.1);
}

.subcategory-item a:hover {
    color: #0ABAB5;
    text-decoration-color: #0ABAB5;
}


/* Mobile Adjustments */
@media (max-width: 991px) {
    .mega-menu {
        position: relative;
        width: 100%;
        transform: none;
        left: 0;
        box-shadow: none;
        display: none;
        padding: 5px 0;
        transition: none !important;
        /* Fix jQuery slideToggle jitter */
    }

    .has-mega-menu.nav-active .mega-menu {
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .categories-row {
        flex-direction: column;
        gap: 0;
        padding-bottom: 0;
        align-items: flex-start;
    }

    .category-item {
        flex-direction: column;
        /* Stack header and wrapper */
        align-items: flex-start;
        width: 100%;
        padding: 0;
        text-align: left;
        border-bottom: 1px solid #f0f0f0;
        transition: none !important;
        /* Fix nested slideToggle jitter */
    }

    .category-header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center;
        width: 100%;
        padding: 12px 15px;
        cursor: pointer;
    }

    .category-item:hover,
    .category-item.active {
        background: #e5f0ef;
        transform: none;
    }

    .category-icon {
        width: 18px;
        /* Small icon as requested */
        height: 18px;
        margin-bottom: 0;
        margin-right: 12px;
    }

    .category-name {
        font-size: 14px;
        flex: 1;
        text-transform: none;
    }

    .mobile-arrow {
        font-size: 12px;
        color: #999;
        transition: transform 0.3s ease;
    }

    .category-item.active .mobile-arrow {
        transform: rotate(180deg);
    }

    .mobile-sub-wrapper {
        width: 100%;
        background: #fafafa;
        padding-left: 35px;
        /* Indent everything inside */
        padding-bottom: 15px;
    }

    .subcategories-container {
        display: none !important;
        /* Hide original container on mobile */
    }

    .subcategory-group {
        margin-top: 10px;
        margin-bottom: 5px;
        padding: 0;
        background: transparent;
        margin-right: 15px;
    }

    .subcategory-group h4 {
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 5px;
        color: #0ABAB5;
        background: #eff4f4;
        padding: 10px 15px;
        border-radius: 6px;
        display: flex !important;
        align-items: center;
        width: 100%;
    }

    .subcategory-group h4::before {
        content: "\f114";
        /* Folder icon or similar from feather if possible, or just a bullet */
        font-family: 'feather';
        display: inline-block;
        margin-right: 10px;
        font-size: 14px;
        font-weight: normal;
    }

    .subcategory-list {
        padding-left: 20px;
        margin-bottom: 10px;
        margin-top: 5px;
        list-style: none;
        /* Removed !important and visibility forcing to allow hover reveal or JS toggle */
        border-left: 1px dashed #e5e5e5;
        margin-left: 15px;
    }


    .subcategory-item {
        margin-bottom: 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .subcategory-item a {
        font-size: 13px !important;
        color: #444 !important;
        display: block !important;
        padding: 8px 12px !important;
        visibility: visible !important;
        text-decoration: none !important;
        transition: all 0.2s ease;
    }

    .subcategory-item a:active {
        color: #c29b61 !important;
        background: rgba(194, 155, 97, 0.05);
        border-radius: 4px;
    }
}