// /**
//  * Copyright © Magento, Inc. All rights reserved.
//  * See COPYING.txt for license details.
//  */

//
//  Common
//  _____________________________________________
@filter-link-hover: @theme__color__primary;
@filter-link: @text__color;
@toolbar-background: @color-white;
@toolbar-element-background: @color-white;
& when (@media-common = true) {
    .filter {
        &.block {
            margin-bottom: 0;
        }

        &-title {
            strong {
                &[data-count]:after {
                    .lib-css(color, @color-white);
                    background: @theme__color__secondary;
                    border-radius: 2px;
                    content: attr(data-count);
                    display: inline-block;
                    font-size: .8em;
                    line-height: 1;
                    margin: 0 @indent__xs;
                    min-width: 1em;
                    padding: 2px;
                }

                &.disabled {
                    opacity: .5;
                }
            }
        }
        .block-subtitle {
            border-bottom: @border-width__base solid @border-color__base;
            font-size: @font-size__base;
            line-height: 1em;
            padding-bottom: 1.8rem;
        }

        &-subtitle {
            display: none;
        }

        &-current {
            margin: 0;

            .items {
                padding: @indent__xs @indent__s;
                padding-left: 0;
            }

            .item {
                padding-left: 20px;
                position: relative;
                z-index: 1;
                color: @heading__color__base;
            }

            .filter &-subtitle {
                border: none;
                display: block;
                padding-bottom: @indent__s;
            }

            .action.remove {
                &:extend(.abs-remove-button-for-blocks all);
                left: -5px;
                position: absolute;
            }
        }

        &-actions {
            margin-bottom: @indent__m;
            a{
                &:not(:hover){
                    color: @heading__color__base;
                }
            }
        }

        &-label {
            font-weight: @heading__font-weight__base;

            &:after {
                content: ': ';
            }
        }

        &-value {
            .lib-css(color, @text__color);
        }

        &-options {
            display: none;
            margin: 0;
            &-content {
                margin: 0;
                ul,
                ol{
                    padding-left: 0;
                    list-style: none;
                    margin-bottom: 0;
                }
                .item {
                    margin: @indent__s 0;
                    &:last-child{
                        margin-bottom: 0;
                    }
                    &:first-child{
                        margin-top: 0;
                    }
                }
                
                a {
                    .lib-css(color, @filter-link);
                    margin-left: -5px;
                    margin-right: -5px;
                    padding-left: 5px;
                    padding-right: 7px;

                    &:hover {
                        color: @link__hover__color;
                        text-decoration: none;

                        & + .count {
                            background-color: @color-gray91;
                        }
                    }
                }

                .count {
                    .lib-css(color, @text__color);
                    font-weight: @font-weight__light;
                    padding-left: 5px;
                    padding-right: 5px;

                    &:before {
                        content: '(';
                    }

                    &:after {
                        content: ')';
                    }
                }

                .filter-count-label {
                    &:extend(.abs-visually-hidden all);
                }
                .swatch-attribute{
                    .swatch-option{
                        min-width: 2.6rem;
                        width: 2.6rem;
                        height: 2.6rem;
                        font-size: 0.85714rem;
                        padding: 0;
                        margin: 0 7px 5px 0;
                        background: transparent;
                        display: inline-flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 50%;
                        text-transform: uppercase;
                        outline: none;
                        &:hover{
                            color: @color-white; 
                        }
                    }
                }
            }
        }
    }
    .filter-options,
    .sidebar .block {
         .filter-options-title,
         .block-title strong{
            cursor: pointer;
            font-weight: @heading__font-weight__base;
            color: @heading__color__base;
            margin: 0;
            overflow: hidden;
            padding: @indent__s @indent__s + 30px 12px 0;
            position: relative;
            word-break: break-all;
            z-index: 1;
            font-size: @h4__font-size;
            font-family: @font-family__base;
         }
    }
}

//
//  Mobile
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
    body {
        &.filter-active {
            .page-header {
                display: none;
            }
            .columns {
                z-index: 999;
            }
        }
    }

    .filter {
        &:not(.active){
            .filter-title {
                strong{
                    position: fixed;
                    left: 0;
                    top: 50%;
                    font-size: 0;
                    display: block;
                    background-color: @color-white;
                    border: 1px solid @border-color__base;
                    border-left: 0;
                    min-width: 4.5rem;
                    min-height: 4.5rem;
                    display: inline-flex;
                    align-items: center;
                    justify-content: center;
                    margin-bottom: 0;
                    padding: 0;
                    z-index: 33;
                    background-image: url(../images/icon.png);
                    background-size: 20px;
                    background-repeat: no-repeat;
                    background-position: center;
                }
            }
        }
        &.active {
            position: relative;
            visibility: visible;
            z-index: 99;
             &:after {
                background: rgba(0, 0, 0, @overlay__opacity);
                content: '';
                display: block;
                height: 100%;
                position: fixed;
                right: 0;
                top: 0;
                width: 100%;
                z-index: 1;
            }
            .filter-options-item:last-child {
                margin-bottom: @indent__xl;
            }

            .filter-title {
                height: 50px;
                left: 0;
                position: fixed;
                right: 0;
                top: 0;
                z-index: 2;
                max-width: 30rem;
                background-color: @theme__color__primary;
                border-bottom: @border-width__base solid @border-color__base;
                strong {
                    font-size: @h4__font-size;
                    .lib-css(box-shadow, none);
                    color: @button__color;
                    font-weight: @heading__font-weight__base;
                    background: none;
                    text-align: left;
                    padding: 1rem;
                    padding-left: 1.5rem;
                    .lib-icon-font(
                        @icon-remove,
                        @_icon-font-color: @button__color,
                        @_icon-font-size: 36px,
                        @_icon-font-position: after
                    );
                    display: block;
                    &:after{
                        float: right;
                        line-height: 1;
                        position: relative;
                        top: -2px;
                    }
                }
            }

            .filter-subtitle {
                .lib-css(background, @toolbar-background);
                display: block;
                height: 50px;
                left: 0;
                line-height: 32px;
                position: fixed;
                right: 0;
                top: 0;
                z-index: 1;
                max-width: 30rem;
            }

            .filter-options {
                .lib-css(background, @color-white);
                bottom: 0;
                display: block;
                left: 0;
                overflow: scroll;
                position: fixed;
                right: 0;
                top: 50px;
                z-index: 10;
                max-width: 30rem;
            }
        }
    }

    .filter {
        .block-subtitle {
            font-weight: @heading__font-weight__base;
            padding: @indent__s 0;
        }
        &-options {
            &-item {
                border-bottom: @border-width__base solid @border-color__base;
                &:first-of-type{
                    .filter-options-title,
                    .block-title strong{
                        padding-top: 0;
                    }
                }
            }
            &-title {
                padding-left: 1.5rem !important;
                padding-top: @indent__s !important;
                .lib-icon-font(
                @_icon-font-content: @icon-down,
                @_icon-font-size: 30px,
                @_icon-font-position: after,
                @_icon-font-display: block
                );
                &:after {
                    position: absolute;
                    right: 13px;
                    top: 4px;
                }   
                .active > & {
                    .lib-icon-font-symbol(
                        @_icon-font-content: @icon-up,
                        @_icon-font-position: after
                    );
                }             
            }
            &-content{
                padding: 0 1.5rem 3rem;
            }
        }
        &-actions {
            margin: -15px 0 @indent__m;
        }
    }

    .filter .filter-current {
        border: solid @border-color__base;
        border-width: 1px 0;
        margin-bottom: 3rem;

        .items {
            display: none;
            .item{
                color: @heading__color__base;
            }
        }

        &-subtitle {
            position: relative;
            z-index: 1;
            .lib-icon-font(
                @_icon-font-content: @icon-down,
                @_icon-font-size: 30px,
                @_icon-font-position: before,
                @_icon-font-display: block
            );

            &:before {
                position: absolute;
                right: 10px;
                top: 13px;
            }

            &:after {
                .lib-css(color, @text__color);
                content: ' (' attr(data-count) ')';
                font-size: .9em;
            }
        }

        &.active {
            padding-bottom: 20px;

            .block-subtitle {
                .lib-icon-font-symbol(
                    @_icon-font-content: @icon-up,
                    @_icon-font-position: before
                );
            }

            .items {
                display: block;
            }

            & + .block-actions {
                display: block;

            }
        }

        & + .block-actions {
            display: none;
        }
    }

    .filter-no-options {
        .filter-title {
            &:before {
                background: rgba(255,255,255,.5);
                content: '';
                display: block;
                height: 40px;
                left: 0;
                margin-top: -60px;
                position: relative;
                width: 75px;
                z-index: 99;
            }
        }

        .filter-content {
            margin-bottom: @indent__base;
        }
    }

    .page-with-filter {
        .columns {
            .sidebar-main {
                .lib-vendor-prefix-order(0);
                .block-title{
                    margin-bottom: 0;
                }
            }
        }
    }
}

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {

    .filter {
        .block-subtitle {
            font-weight: @text-weight;
            &:not(.filter-current-subtitle){
                margin-bottom: 3rem;
            }
        }
        &.block {
            margin-bottom: 3rem;
        }

        &-title {
            display: none;
        }
        &-options {
            &-content {
                padding-bottom: 2.6rem;
                display: block !important;
            }
            &-item {
                margin-bottom: 2rem; 
            }
        }
        &-actions {
            margin-bottom: @indent__l;
        }

        &.active &-options,
        &-options {
            background: transparent;
            clear: both;
            display: block;
            overflow: initial;
            position: static;
        }

        &-subtitle {
            display: block;
            position: static;
        }
    }

    .page-layout-1column {
        .toolbar-products {
            position: absolute;
            top: 0;
            width: 100%;
        }

        .products ~ .toolbar-products {
            position: static;
        }

        &.page-with-filter .column.main {
            padding-top: 45px;
            position: relative;
            z-index: 1;
        }

        .filter {
            &.block {
                border-top: 1px solid @border-color__base;
            }

            &-content {
                margin-top: @indent__s;
            }

            &-subtitle {
                display: none;
            }

            &-options {
                &-item {
                    border: 0;
                    display: inline-block;
                    margin-right: @indent__m;
                    position: relative;

                    &.active {
                        z-index: 2;

                        .filter-options-content {
                            visibility: visible;
                        }

                        &:hover {
                            z-index: 3;
                        }

                        &:after,
                        &:before {
                            .lib-arrow(up, 8px, @color-black);
                            bottom: -1px;
                            content: '';
                            display: block;
                            left: @indent__xs;
                            position: absolute;
                            z-index: 3;
                        }

                        &:after {
                            .lib-css(border-bottom-color, @color-white);
                            margin-top: 2px;
                            z-index: 4;
                        }
                    }
                }

                &-title {
                    padding: 0 @indent__base 0 0;

                    &:after {
                        right: 2px;
                        top: 3px;
                        z-index: 3;
                    }
                }

                &-content {
                    @_shadow: 0 3px 5px 0 rgba(50, 50, 50, .75);

                    .lib-css(background, @color-white);
                    .lib-css(box-shadow, @_shadow, 1);
                    border: 1px solid @border-color__base;
                    padding: @indent__xs 0;
                    position: absolute;
                    top: 100%;
                    visibility: hidden;
                    width: 180px;
                    z-index: 2;

                    .item {
                        margin: 0;
                        padding: @indent__xs;

                        a {
                            margin-left: 0;
                        }

                        &:hover {
                            background-color: @color-gray91;
                        }
                    }
                }
            }

            &-current {
                display: inline;
                line-height: 35px;

                &-subtitle {
                    .lib-css(color, @text__color);
                    display: inline;
                    font-size: @font-size__base;
                    font-weight: normal;
                    padding: 0;

                    &:after {
                        content: ':';
                    }
                }

                .item,
                .items {
                    display: inline;
                }

                .item {
                    margin-right: @indent__m;
                    white-space: nowrap;
                }

                .action.remove {
                    line-height: normal;
                }
            }

            &-actions {
                display: inline;
                white-space: nowrap;

                & ~ .filter-options {
                    margin-top: @indent__m;
                }
            }
        }
    }
}
