// core
.p-megamenu {
    display: flex;
    position: relative;
}

.p-megamenu-root-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.p-megamenu .p-menuitem-link {
    cursor: pointer;
    display: flex;
    align-items: center;
    text-decoration: none;
    overflow: hidden;
    position: relative;
}

.p-megamenu .p-menuitem-text {
    line-height: 1;
}

.p-megamenu-panel {
    display: none;
    width: auto;
    z-index: 1;
    left: 0;
    min-width: 100%;
}

.p-megamenu-panel:not(.p-megamenu-mobile) {
    position: absolute;
}

.p-megamenu-root-list > .p-menuitem-active > .p-megamenu-panel {
    display: block;
}

.p-megamenu-submenu {
    margin: 0;
    padding: 0;
    list-style: none;
}

.p-megamenu-button {
    display: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

/* Horizontal */
.p-megamenu-horizontal {
    align-items: center;
}

.p-megamenu-horizontal .p-megamenu-root-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.p-megamenu-horizontal .p-megamenu-end {
    margin-left: auto;
    align-self: center;
}

/* Vertical */
.p-megamenu-vertical {
    flex-direction: column;
}

.p-megamenu-vertical:not(.p-megamenu-mobile) {
    display: inline-flex;
}

.p-megamenu-vertical .p-megamenu-root-list {
    flex-direction: column;
}

.p-megamenu-vertical:not(.p-megamenu-mobile) .p-megamenu-root-list > .p-menuitem-active > .p-megamenu-panel {
    left: 100%;
    top: 0;
}

.p-megamenu-vertical .p-megamenu-root-list > .p-menuitem > .p-menuitem-content > .p-menuitem-link > .p-submenu-icon {
    margin-left: auto;
}

.p-megamenu-grid {
    display: flex;
}

.p-megamenu-col-2,
.p-megamenu-col-3,
.p-megamenu-col-4,
.p-megamenu-col-6,
.p-megamenu-col-12 {
    flex: 0 0 auto;
    padding: 0.5rem;
}

.p-megamenu-col-2 {
    width: 16.6667%;
}

.p-megamenu-col-3 {
    width: 25%;
}

.p-megamenu-col-4 {
    width: 33.3333%;
}

.p-megamenu-col-6 {
    width: 50%;
}

.p-megamenu-col-12 {
    width: 100%;
}

.p-megamenu.p-megamenu-mobile .p-megamenu-button {
    display: flex;
}

.p-megamenu.p-megamenu-mobile .p-megamenu-root-list {
    position: absolute;
    display: none;
    width: 100%;
}

.p-megamenu.p-megamenu-mobile .p-submenu-list {
    width: 100%;
    position: static;
    box-shadow: none;
    border: 0 none;
}

.p-megamenu.p-megamenu-mobile .p-megamenu-root-list .p-menuitem {
    width: 100%;
    position: static;
}

.p-megamenu.p-megamenu-mobile-active .p-megamenu-root-list {
    display: flex;
    flex-direction: column;
    top: 100%;
    left: 0;
    z-index: 1;
}

.p-megamenu.p-megamenu-mobile .p-megamenu-grid {
    flex-wrap: wrap;
    overflow: auto;
    max-height: 90%;
}

// theme
.p-megamenu {
    padding: $horizontalMenuPadding;
    background: $horizontalMenuBg;
    color: $horizontalMenuTextColor;
    border: $horizontalMenuBorder;
    border-radius: $borderRadius;

    .p-megamenu-root-list {  
        outline: 0 none;
    }

    .p-menuitem {
        @include menuitem();
    }

    .p-megamenu-panel {
        background: $overlayMenuBg;
        color: $menuTextColor;
        border: $overlayMenuBorder;
        box-shadow: $overlayMenuShadow;
        border-radius: $borderRadius;
    }

    .p-submenu-header {
        margin: $submenuHeaderMargin;
        padding: $submenuHeaderPadding;
        color: $submenuHeaderTextColor;
        background: $submenuHeaderBg;
        font-weight: $submenuHeaderFontWeight;
        border-top-right-radius: $borderRadius; 
        border-top-left-radius: $borderRadius; 
    }

    .p-submenu-list {
        padding: $verticalMenuPadding;
        min-width: $menuWidth;

        .p-menuitem-separator {
            border-top: $divider;
            margin: $menuSeparatorMargin;
        }
    }

    &.p-megamenu-vertical {
        min-width: $menuWidth;
        padding: $verticalMenuPadding;
    }

    &.p-megamenu-horizontal {
        .p-megamenu-root-list {  
            > .p-menuitem {
                @include horizontal-rootmenuitem();
            }
        }
    }

    &.p-megamenu-mobile {
        &.p-megamenu-vertical {
            width: 100%;
            padding: $horizontalMenuPadding;
        }

        .p-megamenu-button {
            width: $actionIconWidth;
            height: $actionIconHeight;
            color: $horizontalMenuRootMenuitemIconColor;
            border-radius: $actionIconBorderRadius;
            transition: $actionIconTransition;
            outline-color: transparent;
        
            &:hover {
                color: $horizontalMenuRootMenuitemIconHoverColor;
                background: $horizontalMenuRootMenuitemHoverBg;
            }
        
            &:focus {
                @include focused();
            }
        }

        .p-megamenu-root-list {
            padding: $verticalMenuPadding;
            background: $overlayMenuBg;
            border: $overlayMenuBorder;
            box-shadow: $overlayMenuShadow;
    
            .p-menuitem-separator {
                border-top: $divider;
                margin: $menuSeparatorMargin;
            }
    
            .p-submenu-icon {
                font-size: $menuitemSubmenuIconFontSize;
            }

            .p-menuitem {
                .p-menuitem-content {
                    .p-menuitem-link {
                        .p-submenu-icon {
                            margin-left: auto;
                            transition: transform $transitionDuration;
                        }
                    }
                }


                &.p-menuitem-active {
                    > .p-menuitem-content {
                        > .p-menuitem-link {
                            > .p-submenu-icon {
                                transform: rotate(-180deg);
                            }
                        }
                    }
                }
            }

            .p-submenu-list {
                .p-submenu-icon {
                    transition: transform $transitionDuration;
                    transform: rotate(90deg);
                }

                .p-menuitem-active {
                    > .p-menuitem-content {
                        > .p-menuitem-link {
                            > .p-submenu-icon {
                                transform: rotate(-90deg);
                            }
                        }
                    }
                }
            }
    
            @include nested-submenu-indents(nth($menuitemPadding, 1), 2, 2);
        }
    }
}
