/* --- TABBED MEGA MENU (Phase 7.9.2) --- */
.tgmenu__navbar-wrap ul.navigation li .sub-menu.mega-menu.tabbed-mega-menu {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    padding: 0;
    background: #ffffff;
    box-shadow: 0 15px 40px rgba(10, 22, 40, 0.08);
    display: block;
    /* Overrides the grid display of the old mega menu */
    border-top: 3px solid var(--theme-primary);
}

.mega-menu-inner {
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 15px;
    min-height: 300px;
}

/* Top Side: Tabs */
.mega-menu-tabs-list {
    width: 100%;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.mega-menu-tabs-list .nav-link {
    font-size: 18px !important;
    font-weight: 500 !important;
    color: var(--tg-heading-color) !important;
    padding: 10px 20px !important;
    border-radius: 6px;
    transition: all 0.3s ease;
    border-bottom: none !important;
    text-align: center;
    background: transparent !important;
}

.mega-menu-tabs-list .nav-link:hover,
.mega-menu-tabs-list .nav-link.active {
    color: var(--theme-primary) !important;
    background-color: rgba(var(--theme-primary-rgb), 0.05) !important;
    transform: translateY(-3px);
}

.mega-menu-tabs-list .nav-link i {
    display: none;
}

/* Bottom Side: Content Panels */
.mega-menu-tabs-content {
    flex-grow: 1;
    position: relative;
    width: 100%;
}

.mega-tab-pane {
    display: none;
    animation: fadeInTab 0.4s ease forwards;
}

.mega-tab-pane.active.show {
    display: block;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Products Grid inside Tab */
.mega-products-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px 15px;
    /* 20px row gap, 15px column gap */
    justify-content: center;
    max-width: 100%;
    margin: 0 auto;
}

.mega-product-card-wrap {
    /* If we want 9 items max: 100% / 9 = ~11.111%. 
       We allow them to shrink and grow, but base size caters to ~9 items considering gaps 
       or we just rely on the fixed 140px width to naturally wrap. */
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    width: calc(100% / 9 - 15px);
    /* Forces up to 9 items on one row if container is wide enough */
    min-width: 125px;
    /* If it gets smaller than this, it wraps. If 10 items, it forces a wrap. */
}

/* If there are 10 or more items, we restrict the container to force 5 items per row */
.mega-products-grid:has(.mega-product-card-wrap:nth-last-child(n+10)) {
    max-width: 800px;
    /* 5 items * 130px + gaps = ~750px + padding */
}

.mega-product-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    text-decoration: none;
    width: 130px;
    /* Scaled down slightly to fit 9 items (130*9 + 8*15 = 1170px + 120 + 20% paddings roughly fits 1320px container) */
    transition: all 0.3s ease;
}

.mega-product-img-wrapper {
    width: 120px !important;
    height: 120px !important;
    min-width: 120px !important;
    min-height: 120px !important;
    max-width: 120px !important;
    max-height: 120px !important;
    border-radius: 50% !important;
    /* Circle shape as requested via Yurtbay reference */
    padding: 3px;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.4s ease;
    overflow: hidden;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mega-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    aspect-ratio: 1 / 1;
    border-radius: 50% !important;
    transition: transform 0.5s ease;
}

.mega-product-card:hover .mega-product-img-wrapper {
    border-color: var(--theme-primary);
    box-shadow: 0 5px 15px rgba(var(--theme-primary-rgb), 0.2);
}

.mega-product-card:hover .mega-product-img {
    transform: scale(1.1);
}

.mega-product-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--tg-heading-color);
    transition: color 0.3s ease;
    margin-top: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mega-product-card:hover .mega-product-title {
    color: var(--theme-primary);
}