@use "../../base/mixins";
@use "../../base/variables";

/*----------------------------
	Menu/Navigation
----------------------------*/

.cwp-menu-wrapper {
    width: 100%;
}

//extend for hover and click menu
%sideBarMenuDesign {

    //mobile devices hover into click
    ul {
        li {
            .sub-menu {
                max-height: 0;
                transform: scaleY(0);
                transform-origin: top;
                transition: transform 0.5s ease 0s, max-height 0.3s ease-in-out 0s;

                &.open {
                    transform: scaleY(1);
                    max-height: 100vh;
                    transition: transform 0.5s ease 0s, max-height 0.3s ease-in-out 0s;
                }

                li {
                    width: 100%;
                    display: block;
                }
            }

            &.menu-item-has-children {
                .submenu-icon {
                    background: rgba(0, 0, 0, 0.3);
                    width: 20px;
                    height: 20px;
                    text-align: center;
                    line-height: 19px;
                }
            }
        }
    }
}

%desktopHoverMenu {
    ul {
        li {
            display: inline-block;

            &.page_item_has_children,
            &.menu-item-has-children {
                .submenu-icon {
                    background: transparent;
                    width: auto;
                    height: auto;
                    text-align: center;
                    line-height: normal;
                    text-indent: 10px;
                }

                >.children,
                >.sub-menu {
                    min-width: 250px;
                    position: absolute;
                    top: 100%;
                    left: 0;
                    z-index: 9999;
                    opacity: 0;
                    height: auto;
                    overflow: visible;
                    clip: rect(0, 0, 0, 0);
                    transform: translate3d(0, 0, 0);
                    box-shadow: 0 6px 10px 3px rgba(0, 0, 0, .1);
                    transition: all 0.5s ease-in-out 0s;

                    li {
                        width: 100%;
                        display: block;
                    }
                }

                &.cwp-open-submenu,
                &:focus,
                &:hover {

                    >.children,
                    >.sub-menu {
                        clip: auto;
                        opacity: 1;
                        transform: translate3d(0, 0, 0);
                        transition: all 0.3s ease-in-out 0s;

                        .children,
                        .sub-menu {
                            top: 0;
                            left: 100%;
                        }
                    }
                }

                &:focus-within {

                    >.children,
                    >.sub-menu {
                        clip: auto;
                        opacity: 1;
                        transform: translate3d(0, 0, 0);
                        transition: all 0.3s ease-in-out 0s;

                        .sub-menu {
                            top: 0;
                            left: 100%;
                        }
                    }
                }
            }
        }
    }
}

//extend for hover and click menu

.navigation {
    ul {
        list-style-type: none;
        margin: 0;
        display: flex;

        li {
            position: relative;

            &:first-child {
                a {
                    margin-left: 0;
                }
            }

            &:last-child {
                a {
                    margin-right: 0;
                }
            }

            ul {
                flex-direction: column;

                li {
                    a {
                        margin: 0;
                    }
                }
            }

            a {
                display: flex;
                align-items: center;
                position: relative;
            }

            &.page_item_has_children,
            &.menu-item-has-children {
                .submenu-icon {
                    order: 2;
                    margin-left: auto;
                }
            }
        }
    }
}


.cwp-submenu-onclick {
    ul {
        li {
            .sub-menu {
                max-height: 0;
                transform: scaleY(0);
                transform-origin: top;
                transition: transform 0.5s ease 0s, max-height 0.3s ease-in-out 0s;

                &.open {
                    max-height: 100vh;
                    transform: scaleY(1);
                    transition: transform 0.5s ease 0s, max-height 0.3s ease-in-out 0s;
                }

                li {
                    width: 100%;
                    display: block;
                }
            }

            &.menu-item-has-children {
                .submenu-icon {
                    background: rgba(0, 0, 0, 0.3);
                    width: 20px;
                    height: 20px;
                    text-align: center;
                    line-height: 19px;
                }
            }
        }
    }
}

.cwp-dynamic-header {

    &:not(.cwp-vertical-header-left),
    &:not(.cwp-vertical-header-right) {
        .navigation {
            &.cwp-submenu-onclick {
                @include mixins.respond-above(md) {
                    ul {
                        li {
                            display: inline-block;

                            ul {
                                &.sub-menu {
                                    position: absolute;
                                    width: 280px;
                                    box-shadow: -3px 5px 20px -2px rgba(0, 0, 0, .2);

                                    .sub-menu {
                                        left: 100%;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    .navigation {
        &.cwp-submenu-onclick {
            @include mixins.respond-above(md) {
                ul {
                    li {
                        display: block;

                        &.menu-item-has-children {
                            a {
                                display: flex;
                                align-items: center;
                            }

                            .submenu-icon {
                                margin-right: 0;
                                background: transparent;
                                padding-left: 8px;
                            }
                        }

                        ul {
                            li {
                                display: block;
                            }

                            &.sub-menu {
                                position: inherit;
                                width: 100%;
                                box-shadow: none;

                                .sub-menu {
                                    left: inherit;
                                }
                            }
                        }
                    }
                }
            }
        }

        &.cwp-submenu-onhover {
            @extend %desktopHoverMenu;
        }
    }
}

.cwp-header-menu-sidebar {
    .navigation {
        &.cwp-submenu-onhover {
            @extend %sideBarMenuDesign;
        }
    }
}


/*----------------------------
	Mobile Menu
----------------------------*/

.mobile-menu-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    padding: 0 15px;

    .cwp-logo {
        margin-right: auto;
    }
}

.cwp-toggle-btn,
.cwp-toggle-dropdown-btn {
    cursor: pointer;

    &-text+&-icon {
        margin-left: 5px;
    }

    &-icon+&-text {
        margin-left: 5px;
    }
}


/* Sidebar Menu */

.cwp-header-menu-sidebar {
    position: fixed;
    z-index: 999999;
    top: 0;
    width: 280px;
    padding: 20px;
    height: 100%;
    overflow-x: hidden;
    overflow-y: scroll;
    transition: all 0.5s ease-in-out 0s;

    .cwp-close-btn-box {
        overflow: hidden;
    }

    .grid-container {
        width: 100%;
        padding: 0;
    }

    .grid-row {
        margin: 0;

        [class^="grid-"],
        [class*="grid-"] {
            width: 100%;
        }
    }

    .navigation {
        ul {
            flex-direction: column;

            li {
                &.menu-item-has-children {
                    >a {}
                }

                &.open {
                    >a {}

                    >.sub-menu {
                        padding-left: 15px;
                        position: static;
                        min-width: 100%;

                        li {
                            a {}
                        }
                    }
                }
            }
        }
    }

    &.cwp-right-menu-slide {
        right: -280px;
    }

    &.cwp-left-menu-slide {
        left: -280px;
    }

    &.cwp-right-menu-push {
        right: -280px;
    }

    &.cwp-left-menu-push {
        left: -280px;
    }

    a {}

    .cwp-close-btn {
        float: right;
        margin-bottom: 20px;
    }
}

.cwp-right-push {
    right: 0;
    position: relative;
    transition: all 0.5s ease-in-out 0s;

    #wpadminbar {
        top: -46px;
    }

    @include mixins.respond-above(sm) {
        #wpadminbar {
            top: 0;
        }
    }
}

.cwp-left-push {
    left: 0;
    position: relative;
    transition: all 0.5s ease-in-out 0s;

    #wpadminbar {
        top: -46px;
    }

    @include mixins.respond-above(sm) {
        #wpadminbar {
            top: 0;
        }
    }
}

.cwp-show-menu-slide {
    overflow: hidden;

    &:after {
        position: fixed;
        content: '';
        background: rgba(0, 0, 0, .5);
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 999991;
    }

    .cwp-header-menu-sidebar {
        &.cwp-right-menu-slide {
            right: 0;
        }

        &.cwp-left-menu-slide {
            left: 0;
        }
    }
}

.cwp-show-menu-sidebar {
    overflow: hidden;

    &:after {
        position: fixed;
        content: '';
        background: rgba(0, 0, 0, .5);
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        z-index: 999991;
    }

    .cwp-right-push {
        right: 280px;

        //left: -280px;
        .cwp-header-menu-sidebar {
            &.cwp-right-menu-push {
                right: 0;
            }
        }
    }

    .cwp-left-push {
        left: 280px;

        .cwp-header-menu-sidebar {
            &.cwp-left-menu-push {
                left: 0;
            }
        }
    }

    .cwp-header-menu-sidebar {
        ul {
            li {
                &.menu-item-has-children {
                    >a {
                        display: flex;
                        align-items: center;

                        .submenu-icon {
                            position: static;
                            margin-left: auto;
                            top: 0;
                            right: inherit;
                            order: 2;
                            transform: translateY(0);
                        }
                    }
                }
            }
        }

        &.cwp-right-menu-slide {
            right: 0;
        }

        &.cwp-left-menu-slide {
            left: 0;
        }
    }
}