@import '../../../styles/definitions/breakpoints';
@import '../../../styles/definitions/colors';
@import '../../../styles/definitions/mixins';
@import '../../../styles/fills';

// Local Variables
$product-listing-header-iten-spacing: 20px;

$filter-button-icon-width: 36px;
$filter-item-font-size: $bodyFontSize6;
$filter-item-bg-color: $white;
$filter-item-color: $body-color;
$filter-item-font-weight: 500;
$filter-item-border-radius: 3px;
$filter-item-border-color: $gray;
$filter-item-color-hover: $white;
$filter-item-bg-color-hover: $primary-color;
$filter-item-number-badge-color: $primary-color;

//Local Placeholders
%filter-input {
    color: $filter-item-color;
    font-size: $filter-item-font-size;
    line-height: 15px;
    font-weight: $filter-item-font-weight;
}

%filter-item {
    margin-bottom: 8px;

    &:not(:last-of-type) {
        margin-right: $product-listing-header-iten-spacing;
    }

    @include media-md-up {
        margin-bottom: 5px;
    }
}

%filter-button {
    .button {
        &_item {
            background-color: $filter-item-bg-color;
            border-color: $filter-item-border-color;
            font-weight: $filter-item-font-weight;
            color: $filter-item-color;

            &--active {
                .button_icon {
                    background-color: $filter-item-bg-color-hover;
        
                    svg {
                        fill: $filter-item-color-hover;
                    }
                }

                div {
                    background-color: transparent;
                }
            }

            svg {
                height: 12px;
                fill: $filter-item-color;
            }
        }

        &_text {
            text-align: left;
        }

        &_icon {
            display: flex;
            align-items: center;
            justify-content: center;
            position: absolute;
            top: 0;
            right: 0;
            width: $filter-button-icon-width;
            height: 100%;
        }
    }
}

// Component Styles
.productListingControls {
    &_desktop-actions {
        display: none;
        align-items: center;
        flex-wrap: wrap;

        @include media-lg-up {
            justify-content: flex-end;
        }
        @include media-md-up {
            display: flex;
        }
    }

    &_hgroup {
        flex-grow: 1;
    }

    &_title {	
        margin: 0;
        @include title-1;
        line-height: 29px;
        font-weight: 700;
    }
    
    &_results {
        @include text-4;
        display: block;
        line-height: 22px;
    }

    &_filter {
        position: relative;
        display: flex;
        align-items: center;
        align-self: flex-start;
        flex-wrap: wrap;
        z-index: 1;
        margin-top: 15px;

        &Compare, &Sidebar, &Sort, &View {
            @extend %filter-item;
        }

        &Compare, &Sidebar {
            @extend %filter-button;
        }

        &Sidebar {
            .button_item {
                position: relative;
                min-width: 145px;
                padding-right: $filter-button-icon-width;
                color: $body-color;
                padding: 0;
            }
        }

        &Sort {
            min-width: 250px;
            font-weight: 500;
            @include text-5;
        }

        @include media-md-up {
            margin-top: 0;
        }
    }

    &_toggleFilters {
        &Checkbox {
            position: absolute;
            top: 0;
            left: 0;
            z-index: -1;
            opacity: 0;
        }
    }

    &_mobile-actions {
        $btn-spacing: 8px;

        position: fixed;
        z-index: 1;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 8px 0;
        display: flex;
        justify-content: space-between;
        height: 58px;
        background: $white;

        & > .button_item {
            @include column-width(2);
            position: relative;
            margin-left: $btn-spacing;
            margin-right: $btn-spacing;

            .button_text {
                display: flex;
                align-items: center;
                justify-content: center;

                @include media-xs-down {
                    padding-left: 10px;
                    padding-right: 10px;
                }
            }
        }

        @include media-md-up {
            display: none;
        }
    }

    &_sortOptionsWrapper {
        @include media-md-down {
            display: flex;
            flex-direction: column;
            width: 100%;
            height: 100%;
        }
    }

    &_sortOptionsHeader {
        display: none;
        @include media-md-down {
            border-bottom: 1px solid $gray;
            margin-bottom: 16px;
            position: relative;
            text-align: center;
            width: 100%;
            height: 76px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0;
        }
    }

    &_sortOptionsContainer {
        @include media-md-down {
            padding: 0 18px;
            background-color: $white;
            overflow-y: auto;
            flex: 1 1 100%;
            overflow: scroll;
            border-width: 1px 0 0 0;

        }
    }

    &_sortOptionsFooter {
        display: none;
        @include media-md-down {
            width: 100%;
            padding: 8px;
            display: flex;
            justify-content: space-between;
            height: 58px;
            background: $white;
            & > button {
                margin-left: 8px;
                position: relative;
                flex: 1 1 auto;
                &:first-child {
                    margin-left: 0;
                }
            }
        }
    }

    &_sortOptionsTitle {
        @include title-1;
        
        @include media-md-down {
            line-height: 1;
            margin: 0;
            font-weight: 400;
        }
    }

    &_number-badge {
        width: 20px;
        height: 20px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: $headingFontSize6;
        border-radius: 50%;
        background: $filter-item-number-badge-color;
        color: $white;
        margin-left: 7px;

        @include media-xs-down {
            width: 16px;
            height: 16px;
            font-size: $headingFontSize7;
        }
    }

    &_breadCrumbs {
        &:not(:empty) {
            margin-bottom: 25px;
        }
    }
}

// When the filters (mobile) are shown the body scroll need to be disabled
body.fixed {
    @include fixed-body;
}
