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


// Local Variables
$namespace: ".productReviews";
$product-rating-align-left-selector: #{$namespace}_gridContainer--rating-left;
$product-rating-align-top-selector: #{$namespace}_gridContainer--rating-top;
$product-rating-align-right-selector: #{$namespace}_gridContainer--rating-right;

$product-review-color: $deep-gray;
$product-review-header-bg-color: $light-gray;

// Component Styles
#{$namespace} {
    &_gridContainer {
        display: flex;
        flex-direction: column;
        padding-bottom: 14px;
        
        @include media-lg-up {
            &--rating-right,
            &--rating-left {
                flex-direction: row;
            }
        }
    }

    &_hgroup {
        display: flex;
        align-items: flex-start;

        &BtnReview {
            margin-top: 4px;
        }

        @include media-lg-up {
            display: flex;
            align-items: flex-start;
        }
    }

    &_title {
        @include title-2;
        flex-grow: 1;
        display: inline-block;
        margin: 0;
        line-height: 25px;

        &--hidden {
            @extend %sr-only;
        }
    }

    &_header {
        @include text-4;
        margin: 18px 0 0;
        font-family: $body-fontFace;
        line-height: 25px;

        @include media-lg-up {
            display: flex;
            align-items: center;
            padding: 12px 30px;
            background: $product-review-header-bg-color;
        }
    }

    &_filter {
        display: flex;
        align-items: center;
        flex-grow: 1;
        margin-right: 15px;

        @include media-xl-down {
            justify-content: space-between;
        }
    }

    &_paging {
        margin-right: 25px;

        @include media-lg-down {
            display: none;
        }
    }

    &_clearFilter {
        display: flex;
        align-items: baseline;

        @include media-lg-down {
            margin-bottom: 7px;
        }
    }

    &_btnClearFilter {
        margin-left: 5px;
    }

    &_sort {
        min-width: 250px;
    }

    &_content {
        order: 2;

        @include media-lg-up {
            #{$product-rating-align-right-selector} &,
            #{$product-rating-align-left-selector} & {
                @include grid-width(8);
                padding-top: 13px;
            }

            #{$product-rating-align-right-selector} & {
                order: 0;
            }

            #{$product-rating-align-left-selector} & {
                @include grid-offset;
            }
        }
    }

    &_aside {
        display: flex;
        flex-direction: column;

        @include media-lg-up {
            #{$product-rating-align-right-selector} & {
                @include grid-offset;
            }

            #{$product-rating-align-right-selector} &,
            #{$product-rating-align-left-selector} & {
                @include grid-width(3);
            }
        }
    }

    &_content + &_aside {
        margin-bottom : 40px;

        @include media-lg-up {
            #{$product-rating-align-right-selector} &,
            #{$product-rating-align-left-selector} & {
                margin-bottom: 0;
            }
        }
    }

    &_item {
        margin: 40px 0 0;
    }

    &_btnContainer {
        margin: 30px 0 0;
        text-align: center;
    }

    &_rating {
        $rating-spacing: 15px;

        &Average {
            &Total {
                @include text-5;
                @include color-title($dark-gray);
                line-height: 16px;
                
                &--empty {
                    visibility: hidden;
                    height: 30px;
                }

                &Value {
                    font-size: 60px;
                    line-height: 74px;
                    font-weight: 500;
                    color: $product-review-color;
                }
            }

            &Content {
                display: flex;
                align-content: center;
                flex-wrap: wrap;
            }

            &Stars {
                margin: 0 0 5px;

                @include media-lg-up {
                    margin-right: $rating-spacing;
                }
            }
        }

        &Star {
            &List {
                margin: 25px 0 0;
            }

            &Item {
                position: relative;
                display: flex;
                align-items: center;
                padding: 1px 0;
                cursor: pointer;

                &--empty {
                    cursor: default;
                }

                &:after {
                    content: "";
                    position: absolute;
                    top: 0;
                    right: -12px;
                    bottom: 0;
                    left: -12px;
                    opacity: 0;
                    background-color: $faint-gray;
                    border-radius: 10px;
                    z-index: -1;
                    transition: opacity 0.2s ease;
                }

                @include focus-outline;

                &:not(&--empty) {
                    &:hover, &:focus {
                        &:after {
                            opacity: 1;
                        }
    
                        #{$namespace}_ratingStarCount {
                            font-weight: bold;
                        }
                    }
                }
            }

            &Progress {
                $progress-bar-height: 7px;

                position: relative;
                overflow: hidden;
                flex-grow: 1;
                height: $progress-bar-height;
                margin-left: $rating-spacing;
                border-radius: calc($progress-bar-height / 2);
                background-color: $mid-gray;

                &Bar {
                    position: absolute;
                    top: 0;
                    left: 0;
                    height: 100%;
                    border-radius: calc($progress-bar-height / 2);

                    &--rating-5 {
                        background-color: $rating-5-color;
                    }

                    &--rating-4 {
                        background-color: $rating-4-color;
                    }

                    &--rating-3 {
                        background-color: $rating-3-color;
                    }

                    &--rating-2 {
                        background-color: $rating-2-color;
                    }

                    &--rating-1 {
                        background-color: $rating-1-color;
                    }
                }
            }

            &Count {
                @include text-5;
                @include color-title($dark-gray);
                width: var(--product-review-rating-count-width, '3ch');
                margin-left: 8px;
                line-height: 16px;
            }
        }

        &BtnReview {
            margin: 25px 0 0;
            text-align: center;

            #{$product-rating-align-left-selector} &,
            #{$product-rating-align-right-selector} & {
                @include media-lg-up {
                    display: none;
                }
            }
        }

        &TotalReview {
            @include text-5;
            @include color-title($dark-gray);
            display: inline-block;
            line-height: 16px;
        }

        @include media-lg-up {
            #{$product-rating-align-top-selector} & {
                $rating-item-spacing: 20px;
                display: flex;

                &StarList, &Average, &BtnReview {
                    @include column-width(3);
                }

                &StarList, &Average {
                    padding-right: $rating-item-spacing;
                }

                &Average, &BtnReview {
                    padding-left: $rating-item-spacing;
                }

                &StarList {
                    order: -1;
                    border-right: 1px solid $gray-87;
                }

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

                    &Total {
                        &Value {
                            display: block;
                            font-size: 50px;
                            line-height: 61px;
                        }
                    }

                    &Content {
                        order: -1;
                    }
                }

                &TotalReview {
                    margin-bottom: 7px;
                }

                &BtnReview {
                    padding-top: 7px;
                    border-left: 1px solid $gray-87;
                }
            }
        }
    }

    &_rating + &_quotes {
        margin-top: 50px;
    }
}
