/**
 * Header search component.
 * This component is responsible for styling search form in header component.
 */

.#{$namespace}header-search {
    $root: &;
    display: flex;
    position: relative;
    font-size: 1rem;
    background-color: $colorWhite;
    fill: $colorCeruleanBlue;

    &__input,
    &__submit {
        transition: border-color 0.3s;
        position: relative;
        z-index: 5;
    }

    &__button-icon {
        width: 2rem;
        height: 2.1rem;
        transition: transform 0.15s cubic-bezier(0, 0.78, 0.23, 1),
            opacity 0.15s linear;
    }

    &__input {
        border-radius: 3px 0 0 3px;
        z-index: 201;

        &:focus + #{$root}__button {
            .ajax-loading & {
                #{$root}__button-icon {
                    transform: skew(18deg) translate(-8rem, -50%);
                    opacity: 0;
                }

                #{$root}__autocomplete-loader {
                    transform: skew(18deg) translate3d(0, 0, 0);
                    opacity: 1;
                    z-index: 202;
                }
            }
        }
    }

    &__submit {
        border-radius: 0 3px 3px 0;
    }

    &__button {
        right: 0;
        z-index: 201;
    }

    &__autocomplete-loader {
        display: block;
        width: 2.5rem;
        height: 2.5rem;
        position: absolute;
        top: 0.75rem;
        right: 1.6rem;
        z-index: -5;
        will-change: z-index;
        transform: translate3d(4rem, 0, 0);
        transition: transform 0.15s cubic-bezier(0, 0.78, 0.23, 1),
            opacity 0.15s linear;
    }

    &__autocomplete {
        width: 100% !important;
        top: 100%;
        left: 0;
        margin-top: -3px;
        padding-top: 3px;
        box-sizing: border-box;
        border: 1px solid $colorAlto;
        background-color: $colorWhite;
        z-index: 200;
        border-bottom-left-radius: 3px;
        border-bottom-right-radius: 3px;
        box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.17);

        .autocomplete-list {
            margin: -1px 0 1rem;
            border-top: 1px solid $colorAlto;

            &:first-child {
                border-top: 0;
            }

            &:last-child {
                margin-bottom: 0;
            }
        }

        dl dt {
            border: none;
            padding: 1.2rem 3rem 1rem 1rem;
            color: $colorGray;
            font-weight: 700;
            text-transform: uppercase;
            font-size: 1.19rem;
            letter-spacing: 1px;

            &:not(:empty) {
                border: none;
                background-color: transparent;
            }

            &:hover,
            &.selected {
                background-color: $colorWhite;
            }

            &.title-product ~ dd:not(:empty) {
                border-bottom: 1px solid $colorAlto;
                display: flex;
                align-items: center;

                &:last-child {
                    border-bottom: none;
                }

                @include media('>=tablet', '<laptop') {
                    flex-wrap: wrap;
                }

                .product-image-box {
                    width: 4.5rem;
                    height: 4.5rem;
                    padding: 0 1rem 0 0;
                    flex-shrink: 0;
                }
            }
        }

        dl dd {
            padding: 0.5rem 1rem;

            @include media('>=tablet', '<laptop') {
                padding-top: 1rem;
                padding-bottom: 1rem;
            }

            &:not(:empty) {
                border: none;
                background-color: transparent;
                transition: background-color 0.15s linear;
            }

            &:hover,
            &.selected {
                background-color: $colorGallery;
            }

            .product-shop {
                width: calc(100% - 4.5rem);
                margin: 0;

                @include media('>=tablet', '<laptop') {
                    width: calc(100% - 5.5rem);
                }
            }

            .product-item {
                .product-name {
                    font-size: 1.29rem;
                    color: $colorBlack;
                    font-weight: 700;
                }

                img {
                    display: block;
                }

                .price-box {
                    display: flex;
                    flex-direction: row-reverse;
                    justify-content: flex-end;
                    margin: 0.3rem 0 0;

                    .price {
                        font-size: 1.29rem;
                    }
                }

                .old-price .price {
                    margin: 0 0.5rem 0 0;
                    color: $colorDoveGray;
                    text-decoration: line-through;
                    font-size: 90%;
                    font-weight: 700;
                }

                .special-price .price {
                    color: $colorCrimson;
                }
            }

            .product-badges {
                display: flex;
                flex-shrink: 0;
                flex-direction: column;
                align-items: flex-end;
                max-width: 10.5rem;

                &:not(:empty) {
                    padding-left: 1.5rem;

                    @include media('>=tablet', '<laptop') {
                        padding-left: 5.5rem;
                        margin-top: 0.5rem;
                        max-width: 100%;
                        align-items: flex-start;
                    }
                }

                @include media('>=tablet', '<laptop') {
                    width: 100%;
                    box-sizing: border-box;
                }
            }

            .#{$namespace}badge {
                text-align: left;
                padding-left: 0.3rem;

                &:before {
                    left: -0.5rem;
                }
            }

            .category-mini-crumb {
                margin: 0;
                display: inline-block;
                font-size: 1.29rem;
                color: $colorGray;
                font-style: normal;

                &:empty {
                    display: none;
                }

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

            .qs-option-name {
                font-size: 1.29rem;
            }

            .product-attribute-label {
                float: left;
                margin-top: 0.2rem;
                padding-right: 0.4rem;
                text-transform: none;
                font-size: 1.29rem;
                vertical-align: baseline;
                color: $colorGray;

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

            .amount {
                position: static;
                color: $colorGray;
                font-size: 1.29rem;

                &:not(:empty):before {
                    content: '(';
                }

                &:not(:empty):after {
                    content: ')';
                }
            }
        }

        .price {
            .price-box__price {
                line-height: 1.6rem;
            }
        }
    }

    &__icon {
        width: 2em;
        height: 2em;
    }

    &__text {
        position: absolute;
        font: 0/0 a;
        color: transparent;
    }
}
