@import '../helpers/helpers';

.order-item {
  margin-bottom: 20px;
  padding: 20px 20px 0;
  background: $gray-bg;
  border: 1px solid $border-grey;

  &__main {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
  }

  &__image {
    max-width: 60px;

    & img {
      width: 60px;
      height: 60px;
    }
  }

  &__content {
    flex: 1;
    padding-left: 10px;
  }

  &__offers {
    width: 100%;
    font-size: .625rem;
    color: $red;
    order: 0;
    padding-bottom: 10px;

    .order-line__promo {
      margin: 0 35px 0 0;
    }
  }

  &__title {
    width: calc(100% - 35px);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 20px;
    order: 1;
  }

  &__info {
    display: flex;
    flex-wrap: wrap;
    min-height: 90px;

    &-tile {
      .order-item {
        &__quantity {
          width: 100%;
        }

        &__cost {
          flex-wrap: wrap;
          justify-content: flex-start;
        }

        &__price,
        &__total,
        &__area,
        &__quant,
        &__wastage,
        &__price-m {
          @include make-col(6);
          padding-top: 10px;

          &-title {
            display: block;
            white-space: nowrap;
          }
        }

        &__price {
          display: block;
        }
      }
    }
  }

  &__quantity {
    display: inline-flex;
    align-items: flex-end;
    flex-direction: row-reverse;
    justify-content: flex-end;
    order: 3;

    &-btn {
      width: 36px;
      height: 39px;
      padding: 0;
      background-color: $white;
      color: $blue;

      & .btn__text {
        font-size: 1.125rem;
      }

      &:first-of-type {
        border-radius: 3px 0 0 3px;
      }

      &:last-of-type {
        border-radius: 0 3px;
      }
    }

    &-label {
      position: relative;
      margin: 0;
      width: 36px;
    }

    &-value {
      text-align: center;
      width: 37px;
      height: 39px;
      border-radius: 0;
      border: 0;
      padding: 5px;
      font-weight: 500;

      //rules for hiding arrows for input type number
      -moz-appearance: textfield;

      &::-webkit-outer-spin-button,
      &::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
      }

      &.tbx {
        font-size: 1rem;
      }
    }
  }

  &__cost {
    display: flex;
    align-items: flex-end;
    flex: 1;
    order: 2;
    padding-bottom: 20px;
    min-width: 100%;

    & > div {
      &:nth-of-type(2n+1) {
        padding-right: 10px;
      }
    }
  }

  &__total {
    &-hide {
      display: none;
    }
  }

  &__price,
  &__total,
  &__quant,
  &__area,
  &__wastage,
  &__price-m {
    &-title {
      line-height: 14px;
      font-size: .75rem;
      color: $gray-text;
    }

    &-value {
      font-size: 0;
      color: $gray-dark;
      font-weight: 500;
      line-height: 1;

      & .order-item {
        &__currency,
        &__value {
          font-size: 1.5rem;
        }
      }

      & .order-item {
        &__value {
          &-sm {
            font-size: 1.25rem;
          }

          &-xs {
            font-size: 1.125rem;
          }
        }
      }
    }
  }

  &__quant {
    &-title {
      display: block;
    }
  }

  &__message {
    display: inline-flex;
    align-items: center;
    padding: 5px;
    border-radius: 3px;
    font-size: .675rem;
    line-height: 14px;
    background: $blue;
    color: $white;
    margin-top: 15px;

    &-icon {
      margin-right: 5px;
    }
  }

  &__action {
    width: 100%;
    margin-top: 15px;

    &-ctas {
      display: flex;
      justify-content: center;
      max-height: 150px;
    }

    &-btn {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 100%;
      padding: 4px;
      margin-right: 10px;

      & .btn__text {
        font-size: .75rem;
      }

      &:last-of-type {
        margin-right: 0;
      }

      &-remove {
        top: 0;
        right: 0;
        position: absolute;
        display: flex;
        justify-content: center;
        align-items: center;
        background: $white;
        width: 30px;
        height: 30px;
        border-radius: 50%;
        color: $blue;
        padding: 0;

        & .btn__text {
          font-size: .875rem;
        }
      }

      &-primary {
        background-color: $blue;
        border-color: $blue;
        color: $white;
        cursor: default !important;
      }
    }
  }

  &__delivery {
    display: flex;
    margin-top: 15px;
    padding: 10px 5px;
    background: $gray-bg;

    &-type {
      font-weight: 500;
    }

    &-icon {
      font-size: 1.25rem;
      color: $blue;
      margin-right: 5px;
    }
  }

  &__wisdom {
    background: $white;
    padding: 20px;
    margin-top: 15px;

    &-close {
      margin-bottom: 8px;
      text-align: right;
      font-size: 1rem;
    }

    &-hide {
      display: none;
    }
  }
}

.basket {
  &__section {
    &[data-type="Delivery"] {
      .cc-order {
        display: none;
      }
    }
  }
}

@include media-breakpoint-up(sm) {
  .order-item {
    padding-left: 25px;
    padding-right: 25px;

    &__image {
      max-width: 150px;

      & img {
        width: 150px;
        height: 150px;
      }
    }

    &__info {
      min-height: 150px;
      max-width: 85%;
      display: grid;
      grid-template-columns: 1fr 50px;
      grid-auto-rows: 24px 1fr 38px;

      &-tile {
        height: auto;
        grid-auto-rows: 24px 1fr auto;

        .order-item {
          &__cost {
            @include make-col(12);
          }

          &__wastage {
            &-title {
              white-space: normal;
            }
          }

          &__quantity {
            justify-content: flex-start;
          }
        }
      }

      &-offers {
        grid-auto-rows: auto 1fr auto;

        .order-item__quantity {
          padding-top: 8px;
          grid-row: 1/span 3;
        }
      }

      &-tile {
        .order-item {
          &__cost {
            @include make-col(6);
          }

          &__price,
          &__area,
          &__wastage,
          &__quant,
          &__price-m {
            &-value {
              & .order-item {
                &__currency,
                &__value {
                  font-size: 1.125rem;
                }
              }
            }
          }
        }
      }
    }

    &__offers {
      font-size: .75rem;
      grid-column: 1 / span 1;
      grid-row: 1 / span 1;
      padding-bottom: 5px;


      .order-line__promo {
        margin: 0 15px 0 0;
      }
    }

    &__title {
      grid-column: 1 / span 1;
      grid-row: 2 / span 1;
      font-size: 1rem;
      line-height: 20px;
    }

    &__quantity {
      grid-column: 2 / span 1;
      grid-row: 2 / span 2;
      flex-direction: column;
      align-items: flex-start;
      justify-content: flex-start;
      width: 50px;

      &-btn {
        width: 100%;

        &:first-of-type {
          border-radius: 3px 3px 0 0;
        }

        &:last-of-type {
          border-radius: 0 0 3px 3px;
        }
      }

      &-value {
        height: 36px;
        width: 100%;
      }

      &-label {
        height: 36px;
        width: 100%;

        &::after,
        &::before {
          position: absolute;
          content: '';
          height: 1px;
          width: calc(100% - 8px);
          border-top: 2px dotted $gray;
          border-left: 0;
          left: 4px;
        }

        &::after {
          top: 33px;
        }

        &::before {
          top: 0;
        }
      }
    }

    &__price,
    &__total,
    &__quant,
    &__area,
    &__wastage,
    &__price-m {
      &-value {
        & .order-item {
          &__currency,
          &__value {
            font-size: 1.5rem;
          }
        }
      }
    }

    &__delivery {
      align-items: center;
      padding: 10px;

      &-message {
        font-size: 1rem;
      }
    }

    &__action {
      max-width: 89%;

      &-btn {
        padding: 5px;

        &-remove {
          top: 58px;
          width: 50px;
          height: 50px;

          & .btn__text {
            font-size: 1.125rem;
          }
        }
      }
    }

    &__cost {
      grid-column: 1 / span 1;
      grid-row: 3 / span 1;
      padding-right: 10px;

      & > div {
        &:nth-of-type(2n+1) {
          padding-right: 30px;
        }
      }
    }

  }
}

@include media-breakpoint-up(lg) {
  .order-item {
    padding: 20px;

    &:last-of-type {
      margin-bottom: 30px;
      border-bottom: 1px solid $border-grey;
    }

    &__main {
      padding-top: 0;
      flex-wrap: nowrap;
    }

    &__image {
      max-width: 160px;

      & img {
        width: 160px;
        height: 160px;
      }
    }

    &__info {
      max-width: 100%;

      &-offers {
        .order-item__quantity {
          padding-top: 25px;
        }
      }
    }

    &__title,
    &__offers {
      width: 100%;
      padding-right: 10px;
    }

    &__price {
      display: block;
    }

    &__cost {
      justify-content: space-between;
      padding-right: 10px;

      & > div:nth-of-type(odd) {
        padding-right: 10px;
      }

      & .order-item {
        &__value {
          &-sm {
            font-size: 1.25rem;
          }

          &-xs {
            font-size: 1.125rem;
          }
        }
      }
    }

    &__action {
      width: auto;
      max-width: 100%;
      padding-left: 10px;
      padding-top: 10px;

      &-ctas {
        flex-direction: column;
      }

      &-btn {
        width: 160px;
        height: 50px;
        margin-right: 0;
        margin-bottom: 10px;

        & .btn__text {
          font-size: .875rem;
        }

        &:last-of-type {
          margin-bottom: 0;
        }

        &-remove {
          position: static;
          background-color: $white;
          border-radius: 50%;
          width: 50px;
          height: 50px;

          & .btn__text {
            font-size: 1.125rem;
          }
        }
      }

      &-remove {
        padding-top: 10px;
        display: flex;
        justify-content: flex-end;
      }
    }

    &__delivery {
      border-top: 2px dotted $border-grey;
      padding: 10px 0;
      margin-bottom: -20px;
      background: transparent;
    }
  }
}

@include media-breakpoint-up(md) {
  .order-item {
    &__price,
    &__total,
    &__quant,
    &__area,
    &__wastage,
    &__price-m {
      padding-right: 15px;
    }
  }
}

@include media-breakpoint-up(lg) {
  .order-item {
    &__total {
      &_mobile {
        display: none;
      }
    }
  }
}

@include media-breakpoint-up(xl) {
  .order-item {
    padding: 30px;

    &__content {
      padding-left: 30px;
    }

    &__action {
      display: flex;
      max-height: 135px;

      &-ctas {
        justify-content: flex-start;
      }

      &-remove {
        align-items: center;
        padding-top: 20px;
        padding-left: 20px;
      }

    }

    &__message {
      font-size: .75rem;
    }

    &__price,
    &__total,
    &__quant,
    &__area,
    &__wastage,
    &__price-m {
      padding-right: 20px;
    }

    &__delivery {
      margin-bottom: -28px;
    }

    &__cost {


      & > div:nth-of-type(odd) {
        padding-right: 0;
      }

      & .order-item {
        &__value {
          &-sm {
            font-size: 1.5rem;
          }

          &-xs {
            font-size: 1.5rem;
          }
        }
      }
    }
  }
}
