/* Mega Menu */
.mega-menu, .sidebar-menu {
    margin: 0;
    padding: 0;
    list-style: none;

    li.menu-item {
        display: block;
        position: relative;
        margin: 0;

        > a {
            display: block;
            text-decoration: none;
            text-align: $left;
            position: relative;
            margin-top: 0;
            margin-bottom: 0;
            font-family: inherit;
            font-size: inherit;

            > [class*=' fa-'] {
                width: 18px;
                text-align: center;
            }
            > i,
            > .avatar {
                /*display: none;*/
                margin-#{$right}: .5rem;
                @if $rtl == 1 {
                    float: right;
                }
            }
            > .avatar img {
                margin-top: -5px;
                margin-bottom: -4px;
            }
            > [class*='flag-'] {
                display: inline-block;
                width: 16px;
                height: 11px;
                margin-top: -2px;
                margin-#{$right}: 6px;
                margin-#{$left}: 1px;
                vertical-align: middle;
                line-height: 0;
                &:before {
                    display: none;
                }
            }
            > .thumb-info-preview {
                position: absolute;
                display: block;
                #{$left}: 100%;
                border: 0;
                padding-#{$left}: 10px;
                background: transparent;
                overflow: visible;
                margin: 15px 0 0;
                top: -1000px;
                @include transition(transform .2s ease-out, opacity .2s ease-out);
                @if $rtl == 1 {
                    transform: translate3d(30px,0,0);
                } @else {
                    transform: translate3d(-30px,0,0);
                }
                opacity: 0;
                max-width: none;
                .thumb-info-wrapper {
                    display: block;
                    border: 0;
                    box-shadow: 0 0 3px rgba(0, 0, 0, .15);
                    margin: 0;
                    padding: 0;
                    text-align: $left;
                }
                .thumb-info-image {
                    width: 182px;
                    height: 136px;
                    min-height: 0;
                    @include transition(5s linear 0s);

                    &.fixed-image {
                        background-position: $left top;
                        background-size: auto 100%;
                    }
                }
            }
            &:hover {
                z-index: 1;
                > .thumb-info-preview {
                    transform: translate3d(0,0,0);
                    top: 0;
                    opacity: 1;
                    margin-top: -5px;
                }
            }
        }
        > .nolink {
            cursor: default;
        }
    }

    ul.sub-menu {
        margin: 0;
        padding: 0;
        list-style: none;
    }
}

.mega-menu {
    @include clearfix;
}

.menu-custom-block a > i {
    margin-#{$right}: .5rem
}

.mega-menu, .sidebar-menu, .accordion-menu, .menu-custom-block {
    .tip {
        color: #fff;
        display: inline-block;
        font-size: 9px;
        font-style: normal;
        line-height: 1;
        padding: 2px;
        position: relative;
        margin-#{$left}: 10px;
        vertical-align: middle;
        top: -1px;

        &.hot {
            background-color: #eb2771;
            border-color: #eb2771;
        }

        &:before {
            content: '';
            position: absolute;
            #{$left}: -3px;
            top: 50%;
            margin-top: -2px;
            border-#{$right}: 3px solid;
            border-top: 2px solid transparent;
            border-bottom: 2px solid transparent;
            border-#{$right}-color: inherit;
        }
    }
}

#header .menu-custom-block,
.mega-menu > li.menu-item > a {
    .tip {
        position: absolute;
        top: -14px;
        #{$right}: 10px;

        &:before {
            content: '';
            top: auto;
            bottom: -3px;
            #{$left}: 2px;
            border-color: transparent;
            border-top-color: inherit;
            border-style: solid;
            border-width: 3px 2px 0 2px;
        }
    }
}

.mega-menu {
    li.menu-item {
        > a {
            font-weight: $font-weight-normal;
        }
    }
    > li.menu-item {
        float: $left;

        &.narrow {
            position: relative;
        }

        &.has-sub > a {
            .thumb-info-preview {
                display: none;
            }
        }

        > a {
            display: inline-block;
            font-size: .8571em;
            font-weight: 700;
            line-height: 20px;
            padding: 9px 12px 8px;

            > i {
                width: auto;
            }

            .tip {
                top: -9px;
            }

            > .thumb-info-preview {
                #{$left}: -100%;
                #{$right}: -100%;
                padding-#{$left}: 0;
                padding-top: 10px;
                transform: translate3d(0,20px,0);
                opacity: 0;
                margin: auto;
                width: 190px;
            }
            &:hover {
                > .thumb-info-preview {
                    top: 100%;
                    transform: translate3d(0,0,0);
                }
            }
        }

        &.active,
        &:hover > a {
            color: #fff;
        }

        &.has-sub {
            &:hover {
                z-index: 111;
            }
        }
    }

    .popup {
        position: absolute;
        text-align: $left;
        top: 100%;
        margin: 0;
        z-index: 111;
        min-width: 100%;
        line-height: 20px;
        will-change: transform, top;

        ul.sub-menu {
            position: relative;
        }
        li.menu-item {
            line-height: inherit;
            padding: 0;

            > a {
                font-size: 13px;
            }
        }
    }

    .wide {
        .popup {
            border-top: 3px solid #ccc;
            box-shadow: $menu-wide-box-shadow;
            display: none;
            #{$right}: auto;
            #{$left}: 0;

            > .inner {
                padding: 10px;

                > ul.sub-menu {
                    max-width: 100%;
                    @include display-flex;
                    -ms-flex-wrap: wrap; flex-wrap: wrap;

                    > .menu-block-item {
                        margin-bottom: -20px;
                    }
                }

                .container {
                    width: auto;
                    padding: 0;
                }
            }
        }

        li.menu-item {
            > a.has-preview {
                display: inline-block;
            }
        }

        li.sub {
            padding: 15px 15px 10px;

            > a {
                font-size: 1em;
                font-weight: 600;
                padding-bottom: 5px;
            }

            ul.sub-menu {
                padding-bottom: 5px;
                ul.sub-menu {
                    padding-bottom: 0;
                }
            }

            li.menu-item {
                > a {
                    margin-#{$left}: -8px;
                    padding: 7px 8px;
                    font-size: .9em;
                    font-weight: normal;
                }

                > ul.sub-menu {
                    padding-#{$left}: 10px;
                }
            }
        }
    }

    .narrow {
        ul.sub-menu {
            min-width: 200px;
            padding: 5px 0;
            box-shadow: $menu-narrow-box-shadow;
            border-top: 0 solid #ccc;
            z-index: 10;

            ul.sub-menu {
                position: absolute;
                #{$left}: 100%;
                display: none;
                opacity: 0;
            }

            li.menu-item:hover > ul.sub-menu {
                top: -5px;
            }
        }

        li.menu-item {
            > a {
                color: #fff;
                font-weight: 400;
                padding: 8px 18px;
                font-size: .9em;
                border-bottom: 1px solid rgba(255, 255, 255, .2);
                white-space: nowrap;
            }
            &:last-child {
                > a {
                    border-bottom-width: 0;
                }
            }
            &:hover > ul.sub-menu {
                opacity: 1;
                display: block;
            }
        }

        li.menu-item-has-children {
            > a {
                &:before {
                    /*content: if-ltr($fa-var-caret-right, $fa-var-caret-left);*/
                    content: if-ltr($fa-var-chevron-right, $fa-var-chevron-left);
                    float: $right;
                    margin-#{$right}: -1px;
                    font-size: .5rem;
                    opacity: .7;
                    transition: margin-#{$right} .2s;
                }

                .thumb-info-preview {
                    display: none;
                }
            }
            &:hover > a:before {
                margin-#{$right}: -7px;
            }
        }
        &.pos-left {
            .popup {
                #{$left}: 0px;
                #{$right}: auto;
            }

            ul.sub-menu {
                ul.sub-menu {
                    #{$left}: 100%;
                    #{$right}: auto;
                }
            }

            li.menu-item-has-children {
                > a:before {
                    content: $fa-var-chevron-right;
                }
            }
            li.menu-item {
                > a {
                    > .thumb-info-preview {
                        #{$left}: 100%;
                        #{$right}: auto;
                        padding-#{$left}: 10px;
                        padding-#{$right}: 0;
                        @if $rtl == 1 {
                            transform: translate3d(30px,0,0);
                        } @else {
                            transform: translate3d(-30px,0,0);
                        }
                    }
                    &:hover {
                        > .thumb-info-preview {
                            transform: translate3d(0,0,0);
                        }
                    }
                }
            }
        }
        &.pos-right {
            .popup {
                #{$right}: 0px;
                #{$left}: auto;
            }

            ul.sub-menu {
                ul.sub-menu {
                    #{$right}: 100%;
                    #{$left}: auto;
                }
            }

            li.menu-item-has-children {
                > a {
                    &:before {
                        content: $fa-var-chevron-left;
                    }
                }
            }
            li.menu-item {
                > a {
                    > .thumb-info-preview {
                        #{$left}: auto;
                        #{$right}: 100%;
                        padding-#{$left}: 0;
                        padding-#{$right}: 10px;
                        @if $rtl == 1 {
                            transform: translate3d(-30px,0,0);
                        } @else {
                            transform: translate3d(30px,0,0);
                        }
                    }
                    &:hover {
                        > .thumb-info-preview {
                            transform: translate3d(0,0,0);
                        }
                    }
                }
            }
        }
    }

    /* effect */
    .popup {
        top: -3000px;
        li.menu-item {
            > a {
                @include transition(transform .2s ease-out);
                @include transform(translate3d(0, -5px, 0));
            }
        }
    }
    > li.menu-item {
        .popup {
            @include transition(transform .2s ease-out);
            @include transform(translate3d(0, -5px, 0));
        }
        &.wide {
            .popup > .inner > ul.sub-menu > li.menu-item {
                > a {
                    @include transform(translate3d(0, 0, 0));
                }
            }
        }
    }
    > li.menu-item:hover {
        .popup {
            top: 100%;
            @include transform(translate3d(0, 0, 0));
        }
        li.menu-item {
            > a {
                @include transform(translate3d(0, 0, 0));
            }
        }
    }
    .narrow {
        ul.sub-menu ul.sub-menu {
            @if $rtl == 1 {
                @include animation(menuFadeInRight .2s ease-out);
            } @else {
                @include animation(menuFadeInLeft .2s ease-out);
            }
        }

        &.pos-left {
            ul.sub-menu ul.sub-menu {
                @include animation(menuFadeInLeft .2s ease-out);
            }
        }

        &.pos-right {
            ul.sub-menu ul.sub-menu {
                @include animation(menuFadeInRight .2s ease-out);
            }
        }
    }
}

.mega-menu.show-arrow {
    > li.has-sub {
        > a:after {
            display: inline-block;
            content: '\e81c';
            font-family: "porto";
            font-weight: 400;
            font-size: 1em;
            margin: side-values(0 0 0 5px);
            line-height: 1;
        }
    }
}

.mega-menu .narrow {
    .sub-menu.pos-left ul.sub-menu {
        #{$right}: 100%;
        #{$left}: auto;
    }
}

.sub-menu.pos-left li.menu-item-has-children:hover {
    > a {
        &:before {
            margin-#{$right}: 6px;
            content: if-ltr($fa-var-chevron-left, $fa-var-chevron-right);
        }
    }
}

.mega-menu.menu-flat {
    li.menu-item {
        > a {
            > .thumb-info-preview {
                .thumb-info-wrapper {
                    border-radius: 0 !important;
                }
            }
        }
    }
    > li.menu-item {
        margin-#{$right}: 0;

        &.active,
        &:hover {
            > a {
                border-radius: 0 !important;
            }
        }

        &.has-sub {
            &:hover {
                > a {
                    border-radius: 0 !important;
                }
            }
        }
    }

    .popup {
        margin: 0;
    }

    .wide {
        .popup, .popup > .inner, .popup li.menu-item li.menu-item > a {
            border-radius: 0 !important;
        }
    }

    .narrow {
        .popup > .inner > ul.sub-menu, ul.sub-menu ul.sub-menu {
            border-radius: 0 !important;
        }
    }
}

.mega-menu.menu-flat-border {
    > li.menu-item {
        > a {
            border-#{$right}: 1px solid rgba(0, 0, 0, .1);
        }

        &:last-child {
            > a {
                border-#{$right}: 0 none;
            }
        }
    }
}

.mega-menu.menu-hover-line {
    > li.menu-item {
        > a:before {
            content: "";
            position: absolute;
            width: 100%;
            height: 3px;
            top: 0;
            left: 0;
            opacity: 0;
        }
    }
    &:not(:hover) > li.menu-item.active,
    > li.menu-item:hover {
        > a:before {
            opacity: 1;
        }
    }
}
.mega-menu.menu-hover-underline {
    > li.menu-item {
        > a:before {
            top: 50%;
            margin-top: 15px;
            width: auto;
            #{$left}: 0;
            #{$right}: 15px;
            transition: cubic-bezier(0.55, 0, 0.1, 1) $right .3s;
        }
    }
    > li.menu-item.active,
    > li.menu-item:hover {
        > a:before {
            #{$right}: 0;
        }
    }
}