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

//
//  Common
//  _____________________________________________

& when (@media-common = true) {
    table {
        width: 100%;
        caption {
            display: none;
        }
    }
    .table-order-items, .table-downloadable-products, .table-additional-addresses-items {
        thead th {
            font-weight: 500;
            border-top: 1px solid #ccc;
            border-bottom: 1px solid #ccc;
            padding: 15px 10px;
            background: #f1f1f1;
        }
    }
    .order-links {
        display: block;
        vertical-align: top;
        position: relative;
        z-index: 10;
        white-space: nowrap;
        margin: 0 -20px;
        overflow-x: auto;
        overflow-y: auto;
        .item {
            display: inline-block;
            padding: 10px 20px;
        }
    }

    .block-order-details-view .block-title {
        margin-bottom: 15px;
    }

    .order-items, .table-wrapper.invoice, .order-items-shipment {
        border: 1px solid #ccc;
        border-radius: 3px;
        table {
            border-style: hidden;
        }
    }

    .order-details-items {
        margin-top: 10px;
        padding: 0;
        display: inline-block;
        vertical-align: top;
        width: 100%;
        position: relative;
        z-index: 8;

        .order-title {
            padding: 0 0 @indent__s;
            display: none;

            > strong {
                .font-size(18);
                font-weight: 500;
            }

            .action {
                display: inline-block;
            }
        }

        .table-wrapper {
            margin: 0;

            &:not(:last-child) {
                margin-bottom: @indent__l;
            }
        }

        .actions-toolbar {
            display: none;
        }

        .table-order-items {
            > thead > tr > th {
                border-bottom: 1px solid @border-color__base;
                width: auto;
            }

            tbody {
                & + tbody {
                    border-top: 1px solid @border-color__base;
                }

                .account & {
                    tr:nth-child(even) td {
                        background: none;
                    }
                }

                td {
                    padding-bottom: 10px;
                    padding-top: 10px;
                }

                .col {
                    &.label {
                        font-weight: @font-weight__bold;
                        padding-bottom: 5px;
                        padding-top: 0;
                    }

                    &.options {
                        padding: 0 0 15px;
                    }
                }

                > .item-parent {
                    td {
                        padding-bottom: 5px;
                    }

                    + tr td {
                        padding-top: 5px;
                    }
                }

                .item-options-container td {
                    padding-bottom: 15px;
                    padding-top: 0;
                }
            }

            .product-item-name {
                margin: 0;
                .font-size(16);
            }
        }

        tfoot {
            .amount,
            .mark {
                text-align: right;
                padding: 3px 10px;
            }
        }

        .item-options {
            margin: 0;
            .font-size(14);

            dt {
                margin: 0;
            }

            dd {
                margin: 0 0 15px;
                &:last-child {
                    margin-bottom: 0;
                }
            }

            &.links {
                dt {
                    display: inline-block;

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

                dd {
                    margin: 0;
                }
            }
        }

        thead {
            .col.qty {
                text-align: center;
            }
        }

        .col {
            &.price,
            &.subtotal {
                &:extend(.abs-incl-excl-tax all);
            }
        }

        .cart-tax-total {
            &:extend(.abs-tax-total all);
            &-expanded {
                &:extend(.abs-tax-total-expanded all);
            }
        }

        tfoot {
            &:extend(.abs-account-summary all);
        }

        .action {
            &.show {
                .lib-icon-font(
                        @icon-down,
                    @_icon-font-size: 10px,
                    @_icon-font-line-height: 10px,
                    @_icon-font-text-hide: true,
                    @_icon-font-position: after,
                    @_icon-font-display: inline-block
                );
                .lib-css(color, @primary__color);

                &.expanded {
                    .lib-icon-font-symbol(
                        @_icon-font-content: @icon-up,
                        @_icon-font-position: after
                    );
                }
            }
        }

        .product-item-name {
            .lib-font-size(18);
        }

        .items-qty {
            &:extend(.abs-reset-list all);
            .item {
                white-space: nowrap;
            }

            .title {
                &:after {
                    content: ': ';
                }
            }
        }

        .pages-items {
            .item {
                &:first-child,
                &:last-child {
                    margin-right: 0;
                }
            }
        }
    }

    .block-order-details {
        &-comments {
            margin: 30px 0 30px;
            display: inline-block;
            width: 100%;
            .comment-date {
                font-weight: 500;
            }

            .comment-content {
                line-height: 1.6;
                margin: 0 0 20px;
            }
        }

        &-view {
            .block-content .box {
                margin-bottom: 30px;
            }

            > .block-title strong {
                .font-size(18);
                font-weight: 500;
            }

            .box-title strong {
                font-weight: 500;
            }

            .box-content {
                .payment-method {
                    .title {
                        font-weight: @font-weight__regular;
                    }

                    .content {
                        margin: 0;

                        > strong {
                            font-weight: @font-weight__regular;

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

        &-gift-message {
            .column.main .order-details-items & {
                margin: 30px 0 0;
            }

            + .actions-toolbar {
                display: none;
            }
        }
    }

    .order-tracking {
        margin: 0;
        padding: 0 0 20px;

        .tracking-title {
            display: inline-block;
        }

        .tracking-content {
            display: inline-block;
            margin: 0 0 0 5px;
        }
    }

    .order-actions-toolbar {
        margin-bottom: 25px;

        .action {
            &.print {
                &:extend(.abs-action-print all);
            }
            a {
                color: @main2_color;
                &:hover {
                    color: @main_color;
                }
            }
        }
    }

    .order-status {
        border: 1px solid #d1d1d1;
        border-radius: 3px;
        display: inline-block;
        padding: 5px 10px;
        vertical-align: top;
        font-size: 1.5rem;
        &.complete {
            color: green;
            border-color: green;
        }
        &.new {
            color: #e91e63;
            border-color: #e91e63;
        }
        &.processing {
            color: blue;
            border-color: blue;
        }
        &.holded {
            color: #ff5722;
            border-color: #ff5722;
        }
        &.closed, &.canceled {
            color: gray;
            border-color: gray;
        }
        &.pending_payment, &.payment_review {
            color: darkcyan;
            border-color: darkcyan;
        }
    }

    .order-status-wrap {
        .actions-toolbar {
            float: right;
            text-align: right;
        }
    }

    .account,
    [class^='sales-guest-'],
    .sales-guest-view,
    .magento-rma-guest-returns {
        &:extend(.abs-title-orders all);
    }

    .form-orders-search {
        .field {
            &:last-child {
                margin-bottom: @indent__base;
            }
        }
    }

    .block-reorder {
        .block-title {
            &:extend(.abs-block-widget-title all);
        }

        .actions-toolbar {
            margin: 17px 0;
        }

        .product-item-name {
            display: inline-block;
        }

        .product-item {
            .label {
                &:extend(.abs-visually-hidden all);
            }

            .field.item {
                display: inline-block;
            }
        }
    }

    //
    //  Guest order view page
    //  ---------------------------------------------

    [class^='sales-guest-'],
    .sales-guest-view {
        .column.main {
            .block:not(.widget) {
                &:extend(.abs-account-blocks all);
            }
        }
    }

    .magento-rma-guest-returns {
        .column.main {
            .order-details-items {
                .table-wrapper {
                    .data.table {
                        &:extend(.abs-table-striped all);
                    }
                }
            }
        }
    }
}

//
//  Mobile
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
    .table-wrapper {
        &.orders-recent {
            &:extend(.abs-account-table-margin-mobile all);
            &:extend(.abs-no-border-top all);
        }
    }

    .order-details-items {
        thead {
            display: block;

            tr {
                display: block;
            }
        }
    }

    .order-pager-wrapper {
        display: block;
    }

    .account {
        .table-order-items {
            tbody tr {
                display: block;
            }

            .product-item-name {
                display: inline-block;
                margin: 0;
            }

            .action.show {
                margin-top: 0;
            }

            .col {
                &.actions,
                &.options {
                    &:extend(.abs-col-no-prefix all);
                }
            }
        }
    }

    .account,
    [class^='sales-guest-'],
    .sales-guest-view {
        &:extend(.abs-title-orders-mobile all);
    }

    .order-details-items {
        .table-wrapper {
            &:extend(.abs-no-border-top all);
        }

        .action {
            margin: 0 15px;
        }

        .items-qty {
            display: inline-block;
            vertical-align: top;
        }

        .col {
            &.price,
            &.subtotal {
                .price-including-tax,
                .price-excluding-tax {
                    display: inline-block;
                }
            }
        }

        .data.table .col.options {
            padding: 0 10px 15px;
            &:before {
                display: none;
            }
        }

        .table-order-items .options-label {
            &:extend(.abs-no-display-s all);
        }

        .options-label + .item-options-container,
        .item-options-container + .item-options-container {
            &:before {
                content: attr(data-th) ':';
                display: block;
                font-weight: 500;
                padding-left: 10px;
            }

            .col {
                .lib-font-size(12);
                padding: 0 10px;

                &:first-child {
                    padding-top: 3px;
                }

                &:last-child {
                    padding-bottom: 20px;
                }
            }
        }
    }
}

.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
    .order-pager-wrapper {
        .toolbar-amount {
            left: inherit;
            position: relative;
            text-align: center;
            top: inherit;
        }

        .pages {
            text-align: center;
        }

        .action.previous,
        .action.next {
            margin: 0;
        }
    }
}

//
//  Desktop
//  _____________________________________________

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
    .order-details-items {
        .order-title {
            .action {
                margin: 12px 15px 0;
            }
        }
    }
}

.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
    .account,
    [class^='sales-guest-'],
    .sales-guest-view {
        &:extend(.abs-title-orders-desktop all);
        .column.main .block.block-order-details-view {
            &:extend(.abs-add-clearfix-desktop all);
            .block-content:not(.widget) .box {
                &:extend(.abs-add-box-sizing-desktop all);
                clear: none;
                float: left;
                width: 100%/4;
            }
        }
    }

    .block-order-details-comments {
        .comment-content {
            overflow: hidden;
        }
    }

    .order-details-items {
        .col {
            width: auto;

            &.price {
                text-align: center;
            }

            &.subtotal {
                text-align: right;
            }
        }

        tbody td {
            padding-bottom: 20px;
            padding-top: 20px;
        }

        &.ordered {
            .order-title {
                display: none;
            }
        }
    }

    .order-pager-wrapper {
        .order-pager-wrapper-top {
            padding-left: 0;
            padding-right: 0;
        }

        .toolbar-amount {
            position: relative;
        }

        .pages {
            float: right;
        }
    }

    .table-order-items {
        tbody {
            .col {
                &.label,
                &.value {
                    padding-left: 0;
                }
            }
        }

        &.invoice,
        &.shipment {
            .col.qty {
                text-align: center;
            }
        }

        &.creditmemo {
            .col {
                &.qty,
                &.discount,
                &.subtotal {
                    text-align: center;
                }

                &.total {
                    text-align: right;
                }
            }
        }
    }
}
