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

//
//  Variables
//  _____________________________________________

@autocomplete__background-color: @color-white;
@autocomplete__border: 1px solid @form-element-input__border-color;
@autocomplete-item__border: 1px solid @color-gray90;
@autocomplete-item__hover__color: @color-gray91;
@autocomplete-item-amount__color: @color-gray60;

//
//  Common
//  _____________________________________________

& when (@media-common =true) {
    .block-search {
        margin-bottom: 0;

        .block {
            &-title {
                display: none;
            }
        }

        .block-content {
            margin-bottom: 0;
        }

        .label {
            .lib-icon-font(@_icon-font-content: @icon-search,
                @_icon-font-size: 35px,
                @_icon-font-line-height: 33px,
                @_icon-font-color: @header-icons-color,
                @_icon-font-color-hover: @header-icons-color-hover,
                @_icon-font-color-active: @header-icons-color-hover,
                @_icon-font-text-hide: true);
            display: inline-block;
            float: right;

            &.active {
                +.control {
                    input {
                        position: static;
                    }
                }
            }
        }

        .action.search {
            display: none;
        }

        .control {
            border-top: 1px solid @border-color__base;
            clear: both;
            margin: 0 -@layout__width-xs-indent -1px;
            padding: 0 @layout__width-xs-indent;
        }

        input {
            font-size: 16px;
            left: -300%;
            margin: 15px 0;
            position: absolute;
        }

        .nested {
            display: none;
        }
    }

    .search-autocomplete {
        &:extend(.abs-add-box-sizing all);
        display: none;
        margin-top: 0px;
        overflow: hidden;
        position: absolute;
        z-index: 3;

        ul {
            .lib-list-reset-styles();

            li {
                .lib-css(border-top, @autocomplete-item__border);
                cursor: pointer;
                margin: 0;
                padding: @indent__xs @indent__xl @indent__xs @indent__s;
                position: relative;
                text-align: left;
                white-space: normal;

                &:not(:empty) {
                    border-top: 0;
                    .lib-css(border, @autocomplete__border);
                    .lib-css(background, @autocomplete__background-color);
                }

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

                &:hover,
                &.selected {
                    .lib-css(background, @autocomplete-item__hover__color);
                }

                .amount {
                    .lib-css(color, @autocomplete-item-amount__color);
                    position: absolute;
                    right: 7px;
                    top: @indent__xs;
                }
            }
        }
    }

    .form.search.advanced {
        .fields.range {
            .field {
                &:first-child {
                    position: relative;

                    .control {
                        padding-right: 25px;

                        &:after {
                            content: ' \2013 ';
                            display: inline-block;
                            position: absolute;
                            right: 0;
                            text-align: center;
                            top: 6px;
                            width: 25px;
                        }
                    }
                }

                &:last-child {
                    position: relative;

                    div.mage-error[generated] {
                        left: 0;
                        position: absolute;
                        top: 32px;
                    }
                }

                &.with-addon {
                    .control {
                        padding-right: 45px;
                    }
                }
            }
        }

        .group.price {
            .addon {
                .addafter {
                    background: none;
                    border: 0;
                    padding-top: 6px;
                    position: absolute;
                    right: 0;
                    top: 0;
                }
            }
        }
    }

    .search.summary {
        margin-bottom: @indent__s;
    }

    // Search elements
    .header-area {
        .table-icon-menu {

            .block-search .block-title,
            .minicart-wrapper .action.showcart,
            .theme-header-icon,
            .minicart-wrapper .action.showcart:before {
                background: 0 0;
                border: none;
                color: #000;
                font-size: 24px;
                line-height: 1;
                display: block;
            }

            >div {
                vertical-align: middle;
                padding: 17px 12px 17px 0;
                margin: 0;
                display: table-cell;
                float: none;

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

            .block-search {
                .block-title:before {
                    display: inline-block;
                    font-family: 'Pe-icon-7-stroke';
                    font-style: normal;
                    font-weight: 400;
                    font-variant: normal;
                    text-transform: none;
                    -webkit-font-smoothing: antialiased;
                    -moz-osx-font-smoothing: grayscale;
                    content: "\e618";
                    line-height: 30px;
                }
            }
        }

        &.header3 {
            .parent-search {
                display: table;
                width: 100%;

                .search-form,
                .table-icon-menu {
                    display: table-cell;
                    vertical-align: middle;
                }

                .table-icon-menu {
                    .minicart-wrapper {
                        float: none;
                    }
                }
            }

            .table-icon-menu {
                &>div {
                    padding: 12px 20px 9px 0;
                }
            }

            &.search-icon-popup {
                .parent-search {
                    .lib-flex();
                    .justify-content-end();

                    .table-icon-menu {
                        width: auto;
                    }
                }
            }

        }
    }

    header.page-header {
        .logo {
            z-index: 1;
        }

        .block-search {
            margin-right: 0;
            width: inherit;

            .block-title {
                display: block;
                cursor: pointer;
                margin: 0;

                >strong {
                    display: none;
                }

                &:before {
                    font-size: 24px;
                }
            }

            .action.search {
                opacity: 0;
                visibility: hidden;
                display: none;
            }

        }

        #search_mini_form.loading {
            .control:after {
                height: 50px;
                right: 20px;
            }

            >.actions {
                display: none;
            }
        }
    }

    .page-header {
        .search-form {
            .block-search {
                position: fixed;
                top: 0;
                left: 0;
                right: 0;
                bottom: 0;
                z-index: 9999;
                background: rgba(0, 0, 0, 0.95);
                opacity: 0;
                visibility: hidden;
                .lib-transition(all 400ms);

                .block-content {
                    .form.minisearch {
                        max-width: 580px;
                        margin: 0 auto;
                        padding: 15px;
                        margin-top: 130px;

                        .input-text {
                            position: fixed;
                            left: 0;
                            right: 0;
                            width: 100%;
                            min-width: auto;
                            height: 40px;
                            border: 0;
                            background: 0 0;
                            border-bottom: 1px solid @theme-text-color;
                            padding: 0;
                            text-align: center;
                            font-size: 20px;
                            color: #fff;
                            box-shadow: none;
                            border-radius: 0;
                        }

                        input:focus::-webkit-input-placeholder {
                            color: transparent;
                        }

                        input:focus::-moz-placeholder {
                            color: transparent;
                        }

                        input:focus:-ms-input-placeholder {
                            color: transparent;
                        }
                    }

                    .nested {
                        display: none;
                    }

                    .control {
                        padding: 0;
                        border: none;
                    }
                }
            }

            .actions-search {
                .action-search {
                    background: none;
                    border: none;
                    color: @color-black;
                    .lib-css(font-size, 24px);
                    line-height: 20px;
                    display: block;
                    cursor: pointer;
                    padding: 0;

                    &:hover {
                        color: @theme-link-color;
                    }
                }
            }
        }

        .search-close {
            position: absolute;
            right: 20px;
            top: 40px;
            color: #fff;
            width: 60px;
            height: 60px;
            background: none;
            border: none;
            .lib-css(font-size, 60px);
            padding: 0;
            margin: 0;
            display: none;

            i {
                display: block;
            }

            &:hover {
                color: #01bad4;
                .lib-transform(rotate(180deg));
            }
        }

    }

    .search-open {
        .page-header {
            .search-form {
                .block-search {
                    opacity: 1;
                    visibility: visible;
                    margin: 0;
                    z-index: 10001;

                    &.active {
                        background-color: transparent;

                        &:after {
                            position: absolute;
                            top: 0;
                            left: 0;
                            right: 0;
                            bottom: 0;
                            z-index: 1;
                            background: #000000f2;
                            opacity: 0.9;
                            content: "";
                        }

                        .block-content .form.minisearch {
                            z-index: 2;
                        }
                    }
                }

                .search-close {
                    display: block;
                    z-index: 3;
                }
            }
        }
    }

    .catalogsearch-result-index {
        .search-suggestions {
            ul {
                display: flex;
            }
        }

        .category-product-actions {
            .block.search-suggestions {
                ul {
                    li {
                        margin: 0 10px;
                        display: block;

                        a {
                            border-radius: 30px;
                            padding: 0 25px;
                            height: 40px;
                            border: 1px solid #333;
                            display: inline-block;
                            line-height: 40px;
                            color: #333;

                            &:hover {
                                background-color: #333;
                                color: #fff;
                            }
                        }

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

    @media (max-width: 1199px) {
        .header-area.header3 {
            .search-form {
                .actions-search {
                    button {
                        background: 0 0;
                        border: none;
                        color: #fff;
                        font-size: 24px;
                        line-height: 1;
                        display: block;
                    }
                }

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

            .parent-search {
                .table-icon-menu {
                    position: absolute;
                    top: -49px;
                    right: 0;
                    z-index: 10;
                }
            }

            &.search-icon-popup {
                .search-form {
                    .block-search+.actions-search {
                        display: block;
                    }
                }
            }
        }

        .navigation {
            .level0>.level-top {
                line-height: normal;
                padding: 36px 18px 37px;
            }
        }
    }

}

//
//  Mobile
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum ='max') and (@break =@screen__m) {
    .block-search {
        .block-content {
            margin-bottom: 0;
        }
    }

    .search-icon-popup {
        .block-search {
            .block-content {
                .form.minisearch {
                    .input-text {
                        margin: 0;
                    }
                }
            }

            .label {
                display: none;
            }
        }
    }

    .header-area.search-visible {
        .search-form {
            .label {
                border: 0;
                clip: rect(0, 0, 0, 0);
                height: 1px;
                margin: -1px;
                overflow: hidden;
                padding: 0;
                position: absolute;
                width: 1px;
            }
        }
    }

    .page-header {
        .search-form {
            .block-search {
                .block-content {
                    .form.minisearch {
                        margin-top: 130px;
                    }
                }
            }
        }
    }

    .parent-search {
        #search_mini_form {
            .mgs-instant-search-dropdown {
                top: 65px;
            }
        }
    }

    #search_mini_form {
        .mgs-instant-search-dropdown {
            top: 50px;
        }
    }

}

.media-width(@extremum, @break) when (@extremum ='max') and (@break =@screen__s) {
    .block-search {
        margin-top: @indent__s;
    }
}

//
//  Desktop
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum ='min') and (@break =@screen__m) {
    .block-search {
        .label {
            &:extend(.abs-visually-hidden-desktop all);
        }

        .control {
            border-top: 0;
            margin: 0;
            padding: 0 0 25px;
        }

        .nested {
            display: block;
            padding-top: 5px;
            position: absolute;
        }

        input {
            .lib-input-placeholder(@form-element-input-placeholder__color);
            margin: 0;
            padding-right: 35px;
            position: static;
        }

        .action.search {
            display: inline-block;
            .lib-button-icon(@_icon-font-content: @icon-search,
                @_icon-font-text-hide: true,
                @_icon-font-color: @header-icons-color );
            .lib-button-reset();
            padding: @indent__xs 0;
            position: absolute;
            right: 10px;
            top: 0;
            z-index: 1;

            &:focus {
                &:before {
                    .lib-css(color, @color-gray20);
                }
            }
        }
    }

    .header-area {
        &.header3 {
            &:not(.search-icon-popup) {
                .block-search {
                    .minisearch {
                        .input-text {
                            font-size: 14px;
                            text-align: left;
                            padding-left: 30px;
                            height: 36px;
                            line-height: 36px;
                            .lib-css(color, @theme-text-color);
                        }
                    }
                }
            }
        }
    }
}

.media-width(@extremum, @break) when (@extremum ='min') and (@break =@screen__ml) {
    .header-area.search-visible {
        .search-form {
            .block-search {
                position: static;
                background: none;
                opacity: 1;
                visibility: visible;

                .block-content {
                    .form.minisearch {
                        margin: 6px auto;
                        padding: 0;
                        border: 1px solid @color-white;
                        -webkit-border-radius: 40px;
                        -moz-border-radius: 40px;
                        -o-border-radius: 40px;
                        background-color: @color-white;
                        border-radius: 40px;

                        .input-text {
                            position: unset !important;
                            border-radius: 40px;
                            font-size: 14px;
                            text-align: left;
                            padding-left: 30px;
                            height: 36px;
                            line-height: 36px;
                            color: @theme-text-color;
                            border: 1px solid @theme-text-color;
                        }
                    }
                }

            }

            .actions-search {
                display: none;
            }
        }
    }

    .header-area.header3 {
        .parent-search {
            .table-icon-menu {
                width: 1%;
            }
        }
    }

}