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

//
//  Variables
//  _____________________________________________

@minicart__border-color: @color-gray80;
@minicart__padding-horizontal: @indent__base;

@minicart-qty__height: 24px;

//
//  Common
//  _____________________________________________

& when (@media-common = true) {

    // New:
    .mini-cart .mini-cart-heading .ic {
        font-size: 16px;
        line-height: 1em;
    }

    //
    //  Minicart
    //  ---------------------------------------------

    .block-minicart {
        position: relative; // New
        .items-total {
            float: left;
            margin: 0 @indent__s;
            .count {
                font-weight: @font-weight__bold;
            }
        }
        .subtotal {
            margin: 0 @indent__s;
            text-align: right;
            .label {
                &:extend(.abs-colon all);
            }
        }
        .amount {
            .price-wrapper {
                &:first-child {
                    .price {
                        font-size: @font-size__l;
                        font-weight: @font-weight__bold;
                    }
                }
            }
        }
        .subtitle {
            display: none;
            &.empty {
                display: block;
                // font-size: 14px;
                // padding: @indent__l 0 @indent__base;
                // text-align: center;

                // New:
                margin: 20px 0;
                font-weight: normal;
            }
        }
        .text {
            &.empty {
                text-align: center;
            }
        }
        .block-content {
            > .actions {
                margin-top: 15px;
                text-align: center;
                > .primary {
                    margin: 0 @indent__s 15px;
                    .action {
                        &.primary {
                            &:extend(.abs-button-l all);
                            display: block;
                            margin-bottom: 15px;
                            width: 100%;
                            &:last-child {
                                margin-bottom: 0;
                            }

                            // New:
                            span {
                                .lib-icon-font(
                                    @_icon-font-content: '',
                                    @_icon-font-size: 36px,
                                    @_icon-font-color: inherit,
                                    @_icon-font-color-hover: inherit,
                                    @_icon-font-color-active: inherit,
                                    @_icon-font-text-hide: true,
                                    @_icon-font-vertical-align: middle,
                                    @_icon-font-line-height: 22px,
                                    @_icon-font-position: after
                                );
                                .lib-icon-font-symbol(
                                    @_icon-font-content: @icon-next,
                                    @_icon-font-position: after
                                );
                                &:after {
                                    font-weight: bold;
                                }
                            }
                        }
                    }
                }
            }
        }
        .block-category-link,
        .block-product-link,
        .block-cms-link,
        .block-banners {
            margin: 15px 0 0;
            text-align: center;
        }
    }

    .minicart-wrapper {
        // .lib-dropdown(
        // @_toggle-selector: ~".action.showcart",
        // @_options-selector: ~".block-minicart",
        // @_dropdown-toggle-icon-content: @icon-cart,
        // @_dropdown-toggle-active-icon-content: @icon-cart,
        // @_dropdown-list-item-padding: false,
        // @_dropdown-list-item-hover: false,
        // @_icon-font-position: before,
        // @_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
        // );

        // New: if we need to add an icon to the element:
        // .lib-icon-font(
        //     @_icon-font-content: @icon-cart,
        //     @_icon-font-position: before,
        //     @_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
        // );

        float: right;
        .block-minicart {
            .lib-css(padding, 25px @minicart__padding-horizontal);
            right: 0;
            width: 320px;
            .block-title {
                display: none;
            }
            //TODO: the code below, what is this for?
            &:after {
                left: auto;
                right: 25px;
            }
            &:before {
                left: auto;
                right: 26px;
            }
            li {
                margin: 0;
            }
        }
        .product {
            .actions {
                float: right;
                margin: -24px 0 0;
                text-align: right;
                
                > .primary,
                > .secondary {
                    display: inline;
                }
            }
        }

        .action {
            &.close {
                .lib-button-icon(
                @icon-remove,
                @_icon-font-size: 32px,
                @_icon-font-line-height: 32px,
                @_icon-font-text-hide: true
                );
                .lib-button-reset();
                height: 40px;
                position: absolute;
                right: 0;
                top: 0;
                width: 40px;

                // New:
                display: none;
            }
            &.showcart {
                white-space: nowrap;
                .text {
                    &:extend(.abs-visually-hidden all);
                }
                .counter.qty {
                    .lib-css(background, @active__color);
                    .lib-css(color, @page__background-color);
                    .lib-css(height, @minicart-qty__height);
                    .lib-css(line-height, @minicart-qty__height);
                    border-radius: 2px;
                    display: inline-block;
                    margin: 3px 0 0;
                    min-width: 18px;
                    overflow: hidden;
                    padding: 0 3px;
                    text-align: center;
                    white-space: normal;
                    &.empty {
                        display: none;
                    }
                    .loader {
                        > img {
                            .lib-css(max-width, @minicart-qty__height);
                        }
                    }

                    // New:
                    &._block-content-loading {
                    }
                }
                .counter-label {
                    &:extend(.abs-visually-hidden all);
                }
            }
        }
        .minicart-widgets {
            margin-top: 15px;
        }
    }

    .minicart-items-wrapper {
        .lib-css(border, 1px solid @minicart__border-color);
        .lib-css(margin, 0 -@minicart__padding-horizontal);
        border-left: 0;
        border-right: 0;
        overflow-x: auto;
        padding: 15px;
        // New:
        &:extend(.abs-global-border-color-light all);
    }

    .minicart-items {
        .lib-list-reset-styles();

        .product-item {
            padding: 15px 0; // New
            &:not(:first-child) {
                .lib-css(border-top, 1px solid @minicart__border-color);
                // New:
                &:extend(.abs-global-border-color-light all);
            }
            &:first-child {
                padding-top: 0;
            }
            > .product {
                &:extend(.abs-add-clearfix all);
            }
        }
        .product-image-wrapper {
            &:extend(.abs-reset-image-wrapper all);
        }
        .product-item-pricing {
            .label {
                display: inline-block;
                width: 4.5rem;
            }
        }
        .price-minicart {
            margin-bottom: @indent__xs;
        }
        .product {
            > .product-item-photo,
            > .product-image-container {
                float: left;
            }
            .toggle {
                .lib-icon-font(
                @_icon-font-content: @icon-down,
                @_icon-font-size: 28px,
                @_icon-font-line-height: 16px,
                @_icon-font-text-hide: false,
                @_icon-font-position: after,
                @_icon-font-display: block
                );
                cursor: pointer;
                position: relative;
                &:after {
                    position: static;
                    right: @indent__base;
                    top: 0;
                }
            }
            &.active {
                > .toggle {
                    .lib-icon-font-symbol(
                    @_icon-font-content: @icon-up,
                    @_icon-font-position: after
                    );
                }
            }
        }
        .product-item-name {
            font-weight: @font-weight__regular;
            margin: 0 0 2px; // New
            a {
                .lib-css(color, @link__color);
            }
        }
        .product-item-details {
            padding-left: 88px;
            .price {
                font-weight: @font-weight__bold;
            }
            .price-including-tax,
            .price-excluding-tax {
                margin: 2px 0 0; // New
            }
            .weee[data-label] {
                .lib-font-size(11);
                .label {
                    &:extend(.abs-no-display all);
                }
            }
            .details-qty {
                margin-top: @indent__xs; // New
            }
        }
        .product.options {
            .tooltip.toggle {
                .lib-icon-font(
                @icon-down,
                @_icon-font-size: 28px,
                @_icon-font-line-height: 28px,
                @_icon-font-text-hide: true,
                @_icon-font-margin: -3px 0 0 7px,
                @_icon-font-position: after
                );
                .details {
                    display: none;
                }
            }
        }
        .details-qty,
        .price-minicart {
            .label {
                &:extend(.abs-colon all);
            }
        }
        .item-qty {
            margin-right: @indent__s;
            text-align: center;
            width: 40px;
        }
        .update-cart-item {
            .lib-font-size(11);
            vertical-align: top;
            // New:
            // Decrease vertical padding to make the button the same height as input field
            // padding-top: 8px;
            // padding-bottom: 8px;
        }
        .subtitle {
            display: none;
        }
        .action {
            &.edit,
            &.delete {
                .lib-icon-font(
                @icon-settings,
                @_icon-font-size: 28px,
                @_icon-font-line-height: 28px,
                @_icon-font-text-hide: true,
                @_icon-font-color: @color-gray19,
                @_icon-font-color-hover: @color-gray19,
                @_icon-font-color-active: @color-gray19
                );
            }
            &.delete {
                .lib-icon-font-symbol(
                @_icon-font-content: @icon-trash
                );
            }
        }
    }
}

//
//  Mobile
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__xs) {
    .minicart-wrapper .block-minicart {
        width: 290px;
    }
}

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

//
//  Desktop
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
    .minicart-wrapper {
        // margin-left: 13px;
        .block-minicart {
            // right: -15px;
            width: 390px;
        }
    }
}
