@import "../../../../../styles/definitions/variables";
@import "../../../../../styles/definitions/typography";
@import "../../../../../styles/grid";
@import "../../../../../styles/definitions/mixins";

$lateral-item-padding: var(--item-spacing, $header-nav-item-spacing);
$header-default-zindex: 1;

$link-color: var(--text-color, $header-nav-link-color);
$link-color-hover: var(--text-color-hover, $header-nav-link-hover-color);
$bar-height: var(--height, 40px);

// pull sub-menu closer to item, relative to padding
$dropdown-menu-item-sub-menu-vertical-offset: calc((#{$bar-height} / 2) + (#{$header-nav-item-sub-menu-vertical-offset} * 2));

.headerAuxiliaryBar {
    &_wrapper {      
        display: flex;
        height: $bar-height;
        background-color: var(--background-color, $header-aux-bar-bg-color);
        &::before {
            content: "";
            display: block;
            @include full-window-width;
            background-color: var(--background-color, $header-aux-bar-bg-color);
            border-top: 1px solid var(--border-color, $header-aux-bar-border-color);
            border-bottom: 1px solid var(--border-color, $header-aux-bar-border-color);
        }

        &--small-text {
            @include default($bodyFontSize6);
        }

        &--medium-text {
            @include default($bodyFontSize5);
        }

        &--large-text {
            @include default($bodyFontSize4);
        }

        &--left {
            justify-content: flex-start;
        }

        &--center {
            justify-content: center;
        }

        &--right {
            justify-content: flex-end;
        }
       
    }

    &_auxBar {
        position: relative;
    }

    &_nav {
        display: flex;
        align-items: center;
    }

    &_item {
        padding: 0 $lateral-item-padding;

        &:first-child {
            padding-left: 0;
        }

        &:last-child {
            padding-right: 0;
        }

        align-self: stretch;
        position: relative;
        display:flex;

        &:hover,
        &:focus {
            .headerAuxiliaryBar_link .link_text{
                @include underline-hover-active($link-color-hover);
                color: $link-color-hover;
            }

            .buttonIcon_icon {
                transform: rotate(-180deg);
            }
        }
    }

    &_links {
        @extend %reset-list;
        margin: 0 calc(#{$lateral-item-padding} * -1);
        display: flex;
        align-items: center;

        &:hover,
        &:focus {
            text-decoration: none;   
            color: $link-color-hover;
            fill: $link-color-hover;  
        }
    }

    &_link {
        @extend %reset-link;
        color: $link-color;
        fill: $link-color;
        padding-right: $header-dropdown-arrow-spacing;

        &:last-child {
            padding-right: 0;
        }

        &:hover,
        &:focus {
            color: $link-color-hover;
            fill: $link-color-hover;   
            text-decoration: none;
        }

        .link_text {
            @include underline-hover-initial(2px, $link-color-hover);
        }
    }

    &_languagesSwitcher {
        color: $link-color;
        fill: $link-color;
        margin-left: calc(2 * #{$lateral-item-padding});
        &:before{
            z-index: -1;
        }

        .select {
            svg {
                @include fill-header-arrow-svg-color($link-color);
            }

            &__indicator {
                width: 22px;
                padding-left: $header-dropdown-arrow-spacing;
            }

            &__single-value {
                margin-right: 0;
                @include underline-hover-initial(2px, $link-color-hover);
            }
        }

        &--small {
            .select__single-value {
                @include default($bodyFontSize6);
            }
        }
        &--medium {
            .select__single-value {
                @include default($bodyFontSize5);
            }
        }
        &--large {
            .select__single-value {
                @include default($bodyFontSize4);
            }
        }

        &:hover,
        &:focus {
            .select__single-value {
                color: $link-color-hover;
                @include underline-hover-active($link-color-hover);
            }
            .select__indicator svg {
                transform: rotate(-180deg);
                fill: $link-color-hover;

                @include fill-header-arrow-svg-color($link-color-hover);
            }
        }

        .select__menu {
            margin-top: $header-nav-item-sub-menu-vertical-offset;
        }
    }

    &_auxBarNav {
        display: flex;
        align-self: stretch;
        flex-shrink: 0;
        margin-left: -$grid-gutter-width;
        margin-right: -$grid-gutter-width;

        &--nav {
            margin-right: $grid-gutter-width;
        }

        &--quick-links {
            margin-left: $grid-gutter-width;
        }

        &List {
            @extend %reset-list;
            display: flex;
            align-items: stretch;

            @include media-md-down {
                flex-direction: column;
                justify-content: center;
                align-items: flex-end;
            }
        }

        &Item {
            display: flex;
            align-items: stretch;
            position: relative;

            &--cart {
                @include media-md-down {
                    height: 100%;
                }
            }

            > .menuDropdown_userDropdownList {
                visibility:  hidden;
                top: $dropdown-menu-item-sub-menu-vertical-offset;
            }
            
            &:hover, &:focus {
                > .menuDropdown_userDropdownBtn {
                    svg {
                        fill: $link-color-hover;
                        @include fill-header-arrow-svg-color($link-color-hover);
                    }
                }
                > .headerAuxiliaryBar_link {
                    color: $link-color-hover;
                    fill: $link-color-hover;
                }
                > .menuDropdown_userDropdownList {
                    visibility:  visible
                }

                .headerAuxiliaryBar_link .link_text{
                    @include underline-hover-active($link-color-hover);
                    color: $link-color-hover;
                }
    
                .buttonIcon_icon {
                    transform: rotate(-180deg);
                }
            }
        }

        &Link {
            justify-content: flex-end;
            display: flex;
            align-items: center;

            color: $link-color;
            fill: $link-color;

            &:hover,
            &:focus {
                color: $link-color-hover;
                fill: $link-color-hover;
                text-decoration: none;
            }

            @include media-md-down {
                &--cart svg {
                    height: 20px;
                }
            }
        }

        @include media-md-down {
            margin-left: auto;
        }
        
    }
    &_userDropdown {   
        &Btn {
            svg {
                width: 12px;
                color: $link-color;
                fill: $link-color;
            }
            &:hover,
            &:focus {
                .headerAuxBar_userLabel {
                    color: $link-color-hover;
                }
            }
        }
        &List {
            @extend %reset-list;
            position: absolute;
            align-self: center;
            top: 100%;
            right: 0;
            width: 200px;
            border: 1px solid $gray-80;
            border-radius: 3px;
            z-index: $header-default-zindex + 3;
            background-color: $white;
            visibility: hidden;
    
            &--visible {
                visibility: visible;
            }
    
            @include sub-menu-nub;
        }
        &Link {
            display: flex;
            justify-content: flex-start;
            padding: 10px;
            position: relative;
    
            &:hover,
            &:focus {
                background-color: $gray-96;
                text-decoration: none;
            }
        }
    }

    &_nav + &_languagesSwitcher {
        margin-left: calc(2 * #{$lateral-item-padding});
    }
}
