//
// Based of file from Blank theme (m20x)
//

//
//  New variables
//  ---------------------------------------------

@header-search__field__height: @interface-element__height__base; // Default = 36px
@header-search__button__margin: 1px;
@header-search__button-size: @header-search__field__height - (2 * @header-search__button__margin);

//
//  Default variables
//  ---------------------------------------------

@autocomplete-background: @color-white;
@autocomplete-border: 1px solid @form-element-input__border-color;
@autocomplete-item-border: 1px solid @color-gray90;
@autocomplete-item-hover: @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: @minicart-icons-color,
    //         @_icon-font-color-hover: @minicart-icons-color-hover,
    //         @_icon-font-color-active: @minicart-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 {
    //     left: -300%;
    //     position: absolute;
    //     margin: 15px 0;
    // }
    .nested {
        display: none;
    }

    //
    //  New:
    //  ---------------------------------------------
    position: relative;
    z-index: 5; //One level above main menu elements (holders)

    .block.block-content {
        padding: 0;
    }
    .input-text {
        height: @header-search__field__height;
        line-height: @header-search__field__height;
        padding-right: @header-search__field__height;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .action.search {
        //New: added param: @_icon-font-line-height
        .lib-button-icon(
            @_icon-font-line-height: @header-search__field__height - 2,
            @_icon-font-content: @icon-search,
            @_icon-font-text-hide: true,
            @_icon-font-color: @header-icons-color
        );
        .lib-button-reset();
        &:focus {
            &:before {
                .lib-css(color, @color-gray20);
            }
        }
    }
    // Duplicated selector to override properties changed through button reset
    .action.search {
        position: absolute;
        right: 0;
        top: 0;
        display: inline-block;
        z-index: 1;
        padding: 0;
        margin: @header-search__button__margin;
        width: @header-search__button-size;
        height: @header-search__button-size;
        line-height: @header-search__button-size;
        text-align: center;
    }
}

//  Search box inside top header

.header-top {
    .block-search {
        .input-text {
            height: 28px;
            line-height: 28px; /*IE8*/
        }
        .action.search {
            width: 28px;
            height: 28px;
            line-height: 28px;
            font-size: 10px;
            top: 4px; // TODO: temporary fix of button position
            &:before {
                font-size: 20px;
            }
        }
        .search-autocomplete {
            top: 32px;
        }
    }
}

//
//  New: search inline. Deprecated.
//  ---------------------------------------------
.search-wrapper-inline {
    .block-search {
        display: inline-block;
        vertical-align: middle;
    }
}

.search-autocomplete {
    display: none;
    position: absolute;
    z-index: 3;
    overflow: hidden;
    // margin-top: -15px;
    &:extend(.abs-add-box-sizing all);
    ul {
        .lib-list-reset-styles();
        li {
            &:not(:empty) {
                .lib-css(background, @autocomplete-background);
                .lib-css(border, @autocomplete-border);
                border-top: 0;
            }
            .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;
            &:first-child {
                border-top: none;
            }
            &:hover,
            &.selected {
                .lib-css(background, @autocomplete-item-hover);
            }
            .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;
                        text-align: center;
                        width: 25px;
                        position: absolute;
                        right: 0;
                        top: 6px;
                    }
                }
            }
            &:last-child {
                position: relative;
                div.mage-error[generated] {
                    position: absolute;
                    top: 32px;
                    left: 0;
                }
            }
            &.with-addon {
                .control {
                    padding-right: 45px;
                }
            }
        }
    }
    .group.price {
        .addon {
            .addafter {
                background: none;
                border: 0;
                padding-top: 6px;
                position: absolute;
                right: 0;
                top: 0;
            }
        }
    }
}

}

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

// .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 {
        // position: relative;
        // float: right;
        // padding-left: 15px;
        // width: 250px;
        // z-index: 4;
        .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 {
        //     position: static;
        //     padding-right: 35px;
        //     margin: 0;
        //     .lib-input-placeholder(@form-element-input-placeholder__color);
        // }
        // .action.search {
        //     position: absolute;
        //     display: inline-block;
        //     right: 10px;
        //     top: 0;
        //     z-index: 1;
        //     .lib-button-icon(
        //         @_icon-font-content: @icon-search,
        //         @_icon-font-text-hide: true,
        //         @_icon-font-color: @header-icons-color
        //     );
        //     .lib-button-reset();
        //     &:focus {
        //         &:before {
        //             .lib-css(color, @color-gray20);
        //         }
        //     }
        //     padding: @indent__xs 0;
        // }
    }
    // .search-autocomplete {
    //     margin-top: 0;
    // }
}
