@import "../core/index-noreset.scss";
@import "./scss/mixin";
@import "./scss/variable";

$nav-icononly-width: 58px;

#{$nav-prefix} {
    @include box-sizing;
    min-width: auto;
    border-radius: 0;

    &-icon.#{$css-prefix}icon {
        @include icon-size(
            $size: $nav-icon-self-size,
            $marginRight: $nav-icon-self-margin
        );
        font-weight: inherit;
    }

    &-group-label {
        height: $nav-group-height;
        line-height: $nav-group-height;
        font-size: $nav-group-font-size;
    }

    &-item {
        #{$menu-prefix}-item-text > span,
        #{$nav-prefix}-group-label > span {
            opacity: 1;
            transition: opacity $motion-duration-immediately $motion-linear;
        }

        & .#{$css-prefix}menu-item-text > a {
            text-decoration: none;
            color: inherit;
        }

        &,
        &:hover,
        &.#{$css-prefix}focused,
        &.#{$css-prefix}selected,
        &.#{$css-prefix}opened {
            #{$menu-prefix}-hoz-icon-arrow.#{$css-prefix}icon,
            #{$menu-prefix}-icon-arrow.#{$css-prefix}icon {
                color: inherit;
                top: 0;
                transform-origin: center 50%;
            }
        }
    }

    &.#{$css-prefix}active &-item:before {
        position: absolute;
        transition: all $motion-duration-standard $motion-ease;
        content: '';
    }

    &.#{$css-prefix}hoz {
        padding: 0;
        height: calc(#{$nav-hoz-height} + 2 * #{$nav-hoz-item-margin-tb});

        @include nav-size(
            'hoz',
            calc(#{$nav-hoz-height} - #{$popup-local-border-width} * 2),
            $nav-hoz-font-size,
            $nav-hoz-item-padding-lr,
            $nav-hoz-item-margin-tb,
            $nav-hoz-item-margin-lr,
            $nav-hoz-item-corner
        );

        #{$nav-prefix}-group-label #{$menu-prefix}-item-inner {
            height: $nav-group-height;
            line-height: $nav-group-height;
            font-size: $nav-group-font-size;
        }

        #{$menu-prefix}-header {
            float: left;
            height: calc(#{$nav-hoz-height} - #{$popup-local-border-width} * 2);
        }

        #{$menu-prefix}-footer {
            float: right;
            height: calc(#{$nav-hoz-height} - #{$popup-local-border-width} * 2);
        }

        #{$nav-prefix}-item {
            &:before {
                width: 0;
                left: 50%;
                height: $nav-hoz-item-selected-active-line;
            }

            &:hover:before {
                height: $nav-hoz-item-hover-active-line;
            }

            @if (get-compiling-value($nav-hoz-item-hover-active-line) != 0 and
            get-compiling-value($nav-hoz-item-hover-active-line) != 0px) {
                &:hover:before {
                    width: 100%;
                    left: 0;
                }
            }
        }

        &.#{$css-prefix}top #{$nav-prefix}-item:before {
            top: calc(0px - #{$popup-local-border-width});
        }

        &.#{$css-prefix}bottom #{$nav-prefix}-item:before {
            bottom: calc(0px - #{$popup-local-border-width});
        }

        .#{$css-prefix}selected#{$nav-prefix}-item:before {
            width: 100%;
            left: 0;
            height: $nav-hoz-item-selected-active-line;
        }
    }

    &.#{$css-prefix}ver {
        padding: 0;
        transition: width $motion-duration-standard $motion-ease;

        @include nav-size(
            'ver',
            $nav-ver-height,
            $nav-ver-font-size,
            $nav-ver-item-padding-lr,
            $nav-ver-item-margin-tb,
            $nav-ver-item-margin-lr,
            $nav-ver-item-corner
        );

        #{$nav-prefix}-group-label #{$menu-prefix}-item-inner {
            height: $nav-group-height;
            line-height: $nav-group-height;
            font-size: $nav-group-font-size;
        }

        > #{$menu-prefix}-item:first-child,
        > #{$menu-prefix}-sub-menu-wrapper:first-child > #{$menu-prefix}-item {
            margin-top: $nav-ver-item-margin-tb;
        }

        > #{$menu-prefix}-item:last-child,
        > #{$menu-prefix}-sub-menu-wrapper:last-child > #{$menu-prefix}-item {
            margin-bottom: $nav-ver-item-margin-tb;
        }

        #{$menu-prefix}-sub-menu {
            line-height: $nav-ver-sub-nav-height;
        }

        #{$menu-prefix}-sub-menu #{$menu-prefix}-item-inner {
            height: $nav-ver-sub-nav-height;
            font-size: $nav-ver-sub-nav-font-size;
        }

        #{$nav-prefix}-item {
            &:before {
                height: 0;
                top: 50%;
                width: $nav-ver-item-selected-active-line;
            }

            &:hover:before {
                width: $nav-ver-item-hover-active-line;
            }

            @if (get-compiling-value($nav-ver-item-hover-active-line) != 0 and
            get-compiling-value($nav-ver-item-hover-active-line) != 0px) {
                &:hover:before {
                    height: 100%;
                    top: 0;
                }
            }
        }

        &.#{$css-prefix}left #{$nav-prefix}-item:before,
        &.#{$css-prefix}top #{$nav-prefix}-item:before {
            left: calc(0px - #{$popup-local-border-width});
        }

        &.#{$css-prefix}right #{$nav-prefix}-item:before,
        &.#{$css-prefix}bottom #{$nav-prefix}-item:before {
            right: calc(0px - #{$popup-local-border-width});
        }

        .#{$css-prefix}selected#{$nav-prefix}-item:before {
            height: 100%;
            top: 0;
            width: $nav-ver-item-selected-active-line;
        }
    }

    &.#{$css-prefix}primary {
        @include nav-border-fix(
            $nav-hoz-height,
            $nav-primary-border-width
        );
        @include nav-statement(
            $nav-primary-bg-color,
            $nav-primary-border-color,
            $nav-primary-text-color,
            $nav-primary-text-style,
            $nav-primary-shadow,
            $nav-primary-item-hover-bg-color,
            $nav-primary-item-hover-text-color,
            $nav-primary-item-hover-text-style,
            $nav-primary-item-selected-bg-color,
            $nav-primary-item-selected-text-color,
            $nav-primary-item-selected-text-style,
            $nav-primary-item-selected-active-color,
            $nav-primary-item-hover-active-color,
            $nav-primary-item-opened-bg-color,
            $nav-primary-item-opened-text-color,
            $nav-primary-group-text-color,
            $nav-primary-group-text-style,
            $nav-primary-item-childselected-bg-color,
            $nav-primary-item-childselected-text-color,
            $nav-primary-item-childselected-text-style,
        );
        @include sub-nav-statement(
            $nav-primary-sub-nav-text-color,
            $nav-primary-sub-nav-text-style,
            $nav-primary-sub-nav-bg-color,
            $nav-primary-sub-nav-hover-bg-color,
            $nav-primary-sub-nav-hover-text-color,
            $nav-primary-sub-nav-selected-bg-color,
            $nav-primary-sub-nav-selected-text-color,
            $nav-primary-sub-nav-active-color
        );
        @include nav-disabled-statement(
            $nav-primary-item-disabled-text-color
        );
    }

    &.#{$css-prefix}secondary {
        @include nav-border-fix(
            $nav-hoz-height,
            $nav-secondary-border-width
        );
        @include nav-statement(
            $nav-secondary-bg-color,
            $nav-secondary-border-color,
            $nav-secondary-text-color,
            $nav-secondary-text-style,
            $nav-secondary-shadow,
            $nav-secondary-item-hover-bg-color,
            $nav-secondary-item-hover-text-color,
            $nav-secondary-item-hover-text-style,
            $nav-secondary-item-selected-bg-color,
            $nav-secondary-item-selected-text-color,
            $nav-secondary-item-selected-text-style,
            $nav-secondary-item-selected-active-color,
            $nav-secondary-item-hover-active-color,
            $nav-secondary-item-opened-bg-color,
            $nav-secondary-item-opened-text-color,
            $nav-secondary-group-text-color,
            $nav-secondary-group-text-style,
            $nav-secondary-item-childselected-bg-color,
            $nav-secondary-item-childselected-text-color,
            $nav-secondary-item-childselected-text-style,
        );
        @include sub-nav-statement(
            $nav-secondary-sub-nav-text-color,
            $nav-secondary-sub-nav-text-style,
            $nav-secondary-sub-nav-bg-color,
            $nav-secondary-sub-nav-hover-bg-color,
            $nav-secondary-sub-nav-hover-text-color,
            $nav-secondary-sub-nav-selected-bg-color,
            $nav-secondary-sub-nav-selected-text-color,
            $nav-secondary-sub-nav-active-color
        );
        @include nav-disabled-statement(
            $nav-secondary-item-disabled-text-color
        );
    }

    &.#{$css-prefix}normal {
        @include nav-statement(
            $nav-normal-bg-color,
            $nav-normal-border-color,
            $nav-normal-text-color,
            $nav-normal-text-style,
            $nav-normal-shadow,
            $nav-normal-item-hover-bg-color,
            $nav-normal-item-hover-text-color,
            $nav-normal-item-hover-text-style,
            $nav-normal-item-selected-bg-color,
            $nav-normal-item-selected-text-color,
            $nav-normal-item-selected-text-style,
            $nav-normal-item-selected-active-color,
            $nav-normal-item-hover-active-color,
            $nav-normal-item-opened-bg-color,
            $nav-normal-item-opened-text-color,
            $nav-normal-group-text-color,
            $nav-normal-group-text-style,
            $nav-normal-item-childselected-bg-color,
            $nav-normal-item-childselected-text-color,
            $nav-normal-item-childselected-text-style,
        );
        @include sub-nav-statement(
            $nav-normal-sub-nav-text-color,
            $nav-normal-sub-nav-text-style,
            $nav-normal-sub-nav-bg-color,
            $nav-normal-sub-nav-hover-bg-color,
            $nav-normal-sub-nav-hover-text-color,
            $nav-normal-sub-nav-selected-bg-color,
            $nav-normal-sub-nav-selected-text-color,
            $nav-normal-sub-nav-active-color
        );
        @include nav-disabled-statement(
            $nav-normal-item-disabled-text-color
        );
    }

    &.#{$css-prefix}line {
        &.#{$css-prefix}hoz {
            border-top-color: $nav-line-bg-color;
            border-left-color: $nav-line-bg-color;
            border-right-color: $nav-line-bg-color;
        }

        &.#{$css-prefix}ver {
            border-top-color: $nav-line-bg-color;
            border-left-color: $nav-line-bg-color;
            border-bottom-color: $nav-line-bg-color;
        }

        @include nav-statement(
            $nav-line-bg-color,
            $nav-line-border-color,
            $nav-line-text-color,
            $nav-line-text-style,
            $shadow-zero,
            $nav-line-item-hover-bg-color,
            $nav-line-item-hover-text-color,
            $nav-line-item-hover-text-style,
            $nav-line-item-selected-bg-color,
            $nav-line-item-selected-text-color,
            $nav-line-item-selected-text-style,
            $nav-line-item-selected-active-color,
            $nav-line-item-hover-active-color,
            $nav-line-item-opened-bg-color,
            $nav-line-item-opened-text-color,
            $nav-line-group-text-color,
            $nav-line-group-text-style,
            $nav-line-item-childselected-bg-color,
            $nav-line-item-childselected-text-color,
            $nav-line-item-childselected-text-style,
        );
        @include sub-nav-statement(
            $nav-line-sub-nav-text-color,
            $nav-line-sub-nav-text-style,
            $nav-line-sub-nav-bg-color,
            $nav-line-sub-nav-hover-bg-color,
            $nav-line-sub-nav-hover-text-color,
            $nav-line-sub-nav-selected-bg-color,
            $nav-line-sub-nav-selected-text-color,
            $nav-line-sub-nav-active-color
        );
        @include nav-disabled-statement(
            $nav-line-item-disabled-text-color
        );
    }

    &.#{$css-prefix}icon-only {
        &.#{$css-prefix}icon-only-text {
            padding-top: $s-1;
            padding-bottom: $s-1;
        }
        &.#{$css-prefix}custom-icon-only-width {
            text-align: center;
        }

        #{$menu-prefix}-item-inner {
            text-overflow: clip;
        }

        #{$menu-prefix}-item#{$nav-prefix}-item {
            padding: 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        // #{$menu-prefix}-item-text > span,
        // #{$nav-prefix}-group-label > #{$menu-prefix}-item-inner > span {
        //     opacity: 0;
        // }

        &.#{$css-prefix}normal {
            @include icon-only-size($popup-local-border-width);
        }

        &.#{$css-prefix}primary {
            @include icon-only-size($nav-primary-border-width);
        }
        &.#{$css-prefix}secondary {
            @include icon-only-size($nav-secondary-border-width);
        }

        #{$nav-prefix}-icon-only-arrow.#{$css-prefix}icon {
            @include icon-size(
                $size: $nav-icon-only-font-size,
                $marginLeft: calc((#{$nav-icononly-width} - #{$nav-icon-only-font-size}) / 2 - #{$nav-ver-item-padding-lr}),
                $marginRight: calc((#{$nav-icononly-width} - #{$nav-icon-only-font-size}) / 2 - #{$nav-ver-item-padding-lr})
            );
            transition: all $motion-duration-immediately $motion-linear;
            transform-origin: center 50%;
        }

        #{$nav-prefix}-item.#{$css-prefix}opened #{$nav-prefix}-icon-only-arrow.#{$css-prefix}icon-arrow-down {
            @include icon-size(
                $size: $nav-icon-only-font-size,
                $marginLeft: calc((#{$nav-icononly-width} - #{$nav-icon-only-font-size}) / 2 - #{$nav-ver-item-padding-lr}),
                $marginRight: calc((#{$nav-icononly-width} - #{$nav-icon-only-font-size}) / 2 - #{$nav-ver-item-padding-lr}),
                $transform: rotate(180deg)
            );
        }

        // #{$nav-prefix}-item.#{$css-prefix}selected #{$nav-prefix}-icon.#{$css-prefix}icon {
        //     animation: pulse .3s cubic-bezier(.23, 1, .32, 1);
        // }

        #{$menu-prefix}-hoz-icon-arrow,
        #{$menu-prefix}-icon-arrow {
            display: none;
        }
    }

    &-embeddable {
        &.#{$css-prefix}primary,
        &.#{$css-prefix}secondary,
        &.#{$css-prefix}normal {
            height: 100%;
            background: transparent;
            box-shadow: none;
            border: none;

            #{$menu-prefix}-sub-menu #{$menu-prefix}-item,
            #{$nav-prefix}-item#{$menu-prefix}-item {
                background: transparent;
            }

            &.#{$css-prefix}icon-only {
                @include icon-only-size(0px);
            }
        }

        &#{$nav-prefix}.#{$css-prefix}hoz {
            #{$menu-prefix}-item-inner {
                height: 100%;
            }

            #{$menu-prefix}-sub-menu #{$menu-prefix}-item,
            #{$nav-prefix}-item#{$menu-prefix}-item {
                height: 100%;
            }
        }
    }

    &-embeddable,
    &-embeddable &-item.#{$css-prefix}disabled,
    &-embeddable &-item.#{$css-prefix}disabled #{$menu-prefix}-item-text > a {
        background: transparent;
        border: none;
    }
}

@import "./rtl.scss";
