/**
 * Copyright © Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */

& when (@media-common = true) {
    .amazon-button-container {
        display: flex;
        flex-direction: row;
        justify-content: center;
        .amazon-button-column {
            display: flex;
            flex-direction: column;
            position: relative;
        }
        .amazon-button-column-tooltip {
            width: 30px;
        }
        &.amazon-button-product-page {
            justify-content: left;
            margin-bottom: 2em;
        }
    }

    /* for the "Amazon Sign-in" button */
    .amazon-sign-in-button-container {
        display: table;
        margin: 0 0 22px;

        &__cell {
            display: table-cell;
            min-width: 45px;
            position: relative;
        }

        img {
            display: block;
        }

        .field-tooltip {
            margin: -12px 0 0;
            right: 5px;
            top: 50%;
        }
    }
    .block-customer-login {
        .amazon-sign-in-button-container {
            .field-tooltip {
                .field-tooltip-content {
                    top: 38px;
                    left: -245px;

                    &:before {
                        border: none;
                        border-left: 10px solid transparent;
                        border-right: 10px solid transparent;
                        border-bottom: 10px solid #666666;
                        top: -10px;
                        left: 244px;
                    }
                    &:after {
                        border: none;
                        border-left: 10px solid transparent;
                        border-right: 10px solid transparent;
                        border-bottom: 10px solid #f4f4f4;
                        top: -8px;
                        left: 244px;
                    }
                }
            }
        }
    }

    .cart-summary {
        .amazon-button-container {
            .checkout-methods-items {
                margin-top: 0;
            }
        }
    }

    .checkout-methods-items,
    .block-minicart {
        .amazon-button-container {
            flex-wrap: wrap;
        }
        .amazon-divider {
            flex-basis: 100%;
        }
    }
    .checkout-methods-items {
        .amazon-divider {
            margin-top: 0;
            span {
                .lib-css(background, @sidebar__background-color);
            }
        }
        .amazon-button-column-tooltip .field-tooltip {
            display: block;
        }
    }
    .product-info-main {
        .amazon-button-container {
            .field-tooltip {
                display: none;
            }
        }
    }
    #checkout {
        .amazon-button-container {
            margin: 22px 0;
            justify-content: left;
        }
    }
    #amazon-payment {
        .payment-method-title {
            display: flex;
            align-items: center;

            img {
                margin: 0 10px 0 4px;
                width: 74px;
            }
        }
        .checkout-billing-address{
            margin-top: 20px;
        }
        .amazon-payment-action-container{
            padding-left: 10px;
        }
        .actions-toolbar {
            margin-top: 20px;
        }
    }

    .amazon-divider {
        border-bottom: 1px solid #cccccc;
        line-height: 0.1em;
        margin: 18px 0 20px;
        text-align: center;
        max-width: 500px;
        span {
            background: #fff;
            padding:0 5px;
        }
    }

    /** mini cart styling **/
    .product-social-links,
    .amazon-minicart-container {
        width: 100%;
        display: block;
        text-align: center;
        .field-tooltip {
            .field-tooltip-content {
                top: 38px;
                left: -245px;

                &:before {
                    border: none;
                    border-left: 10px solid transparent;
                    border-right: 10px solid transparent;
                    border-bottom: 10px solid #666666;
                    top: -10px;
                    left: 244px;
                }
                &:after {
                    border: none;
                    border-left: 10px solid transparent;
                    border-right: 10px solid transparent;
                    border-bottom: 10px solid #f4f4f4;
                    top: -8px;
                    left: 244px;
                }
            }
        }
    }
    .amazon-minicart-container {
        .amazon-button-container {
            display: inline-block;
            margin: 0px;
        }
    }
    .amazon-checkout-now {
        border-top: 1px solid #c1c1c1;
        padding-top: 10px;
        margin-bottom: 10px;
    }

    .revert-checkout {
        margin-top: 20px;
        margin-bottom: 20px;
        display: block;
    }

    .centered-button {
        text-align: center;
        display: inline-block;
        .catalog-product-view & {
            display: table;
        }
    }

    .checkout-payment-method {
        .amazon-sandbox-simulator {
            .lib-css(border-bottom, @checkout-payment-option-title__border);

            .payment-option-title {
                border-top: none;
                padding-top: 0;
            }

            .amazon-sandbox-simulator-scenario {
                margin-bottom: 10px;
            }
        }
    }

    .checkout-methods-items {
        .amazon-minicart-container {
            .amazon-divider {
                display: none;
            }
        }
        .centered-button {
            margin-bottom: 0;

            @media all and (max-width: @screen__m) {
                width: auto;
            }
        }

        .field-tooltip {
            display: none;

            .field-tooltip-content {
                @abs-checkout-tooltip-content-position-top();

                @media all and (max-width: @screen__m) {

                    @right-shift: 56px;
                    right: -@right-shift;
                    top: 38px;
                    left: auto;

                    &:before,
                    &:after {
                        right: @right-shift;
                    }
                }
            }
        }
    }

    .amazon-widget {
        max-width: 400px;
        height: 228px;
    }

    .amazon-widget--address {
        margin-top: 20px;
    }

    .amazon-addresses {
        margin-top: 20px;
        .amazon-address {
            margin-bottom: 20px;
        }
    }

    #checkout-step-shipping {
        .amazon-divider {
            margin: 40px 0;
        }
    }

    .checkout-payment-method {
        .amazon-payment-method {
            .payment-method-title {
                visibility: hidden; //hide the title for Amazon Pay methods only
                padding-bottom: 0;
            }
        }
    }

    /** Prevent movement after a soft decline to other payment steps **/
    .opc-progress-bar-item._complete.lock-step {
        cursor: none;
        pointer-events: none;
    }

    .ap-promotional-message {
        padding-top: 10px;
        padding-bottom: 10px;
    }
}

@media all and (max-width: @screen__m) {
    .amazon-minicart-container {
        .amazon-button-container {
            width: auto;
        }
    }

    .amazon-button-container {
        &.amazon-button-product-page {
            justify-content: center;
            margin-bottom: 2em;
        }
    }
}

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
    .checkout-payment-method {
        .amazon-sandbox-simulator {
            .lib-css(border-top, @checkout-payment-option-title__border);
        }
    }

    .checkout-shipping-address {
        .field-tooltip {
            .field-tooltip-content {
                right: -65px;

                &:before,
                &:after {
                    right: 64px;
                }
            }
        }
    }

    .cart-summary{
        .checkout-methods-items {
            .field-tooltip {
                .field-tooltip-content {
                    right: -35px;

                    &:before,
                    &:after {
                        right: 35px;
                    }
                }
            }
        }
    }

    .block-minicart {
        .field-tooltip {
            right: -115px;
            top: -45px;

            .field-tooltip-content {
                right: -21px;
                top: 46px;

                &:before,
                &:after {
                    right: 20px;
                }
            }
        }
    }
}

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
    .amazon-addresses {
        &:extend(.abs-add-clearfix-desktop all);
        .amazon-address {
            &:extend(.abs-blocks-2columns all);
            margin-bottom: 0;
        }
    }
    .login-container {
        .block {
            &-amazon-login {
                clear: none;
                float: right;
                .actions-toolbar {
                    margin-top: 25px;
                }
            }
            &:nth-child(2) + .block-amazon-login {
                clear: none;
            }
        }
    }

    .amazon-validate-container {
        margin: 40px auto 0 auto;
        width: 500px;

        .primary {
            width: 190px;
        }

        .continue-as-guest {
            width: 130px;
        }

        .forgot-password {
            text-align: right;
            width: 175px;
        }

        .amazon-logout {
            margin-top: 1em;
        }
    }

    .checkout-shipping-address {
        .field-tooltip {
            .field-tooltip-content {
                right: -65px;

                &:before,
                &:after {
                    right: 64px;
                }
            }
        }
    }
}
