@import '../helpers/helpers';

$android-offset: 60px !default;
$ios-notch-offset: 80px !default;

.summary {
  &__aside {
    padding: 15px;
    background: $gray-bg;
    margin: 0 auto;
    z-index: $summary-aside;
    box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.25);

    & .form-row__col-btn {
      padding-right: 0;
      padding-left: 0;

      & .paypal-button-container {
        min-width: inherit;

        & .paypal-button-text {
          padding-left: 3px;
        }
      }
    }
  }

  &__klarna {
    border: 1px solid $gray;
    margin: -20px -20px 0;
  }

  & .checkout-widget-large + &__klarna {
    margin: 0 -20px;
  }

  &__payment {
    display: none;

    .footer-checkout-holder {
      .payments {
        &__list {
          display: flex;
          justify-content: space-around;
          align-items: center;

          .payments {
            &__item {
              margin-right: 0;
            }
          }
        }
      }
    }

    &-message {
      padding-bottom: 20px;
      font-size: 0.75rem;
    }

    &-main {
      font-weight: 500;
    }

    &-additional {
      margin-bottom: 0;
    }
  }

  &__mobile-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  &__icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
  }

  &__mobile-bar-total,
  &__mobile-bar-label {
    font-weight: 400;
    font-size: 1.125rem;
    line-height: 1.25rem;
  }

  &__icon {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    transform: rotate(180deg);

    &-up,
    &-down {
      display: flex;
      justify-content: center;
      align-items: center;
      width: 16px;
      height: 16px;

      i {
        font-size: 16px;
        line-height: 16px;
        display: inline-block;
        margin: auto;
      }
    }
  }

  .summary__mobile-order.collapsed .summary__icon {
    transform: rotate(0deg);
  }

  .checkout-widget__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    line-height: 1.25rem;
    margin: 10px 0;
    padding: 5px 0;
  }

  .checkout-widget__item:nth-child(3) {
    padding-top: 10px;
  }

  .checkout-widget__item-free {
    line-height: 1.375rem;

    .icon {
      margin-left: 8px;
      vertical-align: middle;
      color: $green;
      width: 1rem;
      height: 1rem;
    }
  }

  .checkout-widget__item-bold {
    font-weight: 500;
    margin: 0;
  }

  .checkout-widget__item-vat {
    font-size: 0.875rem;
    margin: 0;
    padding: 0;
  }

  .checkout-widget__item-value {
    text-align: right;
  }

  .checkout-widget__item-cc,
  .checkout-widget__item-delivery {
    font-size: 1rem;
    margin-top: 5px;
  }

  .checkout-widget__item-delivery-cost-message {
    margin-top: 4px;
    justify-content: flex-end;

    #order-delivery-cost-message {
      @include font-size(10);
      @include line-height(12);

      font-weight: 700;
      color: $squant;
    }
  }

  .checkout-widget__total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 1.25rem;
    color: $white;
    background-color: $blue-dark;
  }

  &__aside.collapse,
  &__aside.collapsing {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
    display: block !important;
    transition: height 0.3s ease-in-out;
    max-height: calc(100vh - 177px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  &__aside.collapse {
    height: 0;
  }

  &__aside.collapse.show {
    bottom: 177px;
    height: auto;

    &.single-button {
      bottom: 125px;
    }
  }

  &__aside.collapsing {
    bottom: 177px;
    height: auto;

    &.single-button {
      bottom: 125px;
    }
  }

  &__aside.collapsing.show {
    height: 0;
  }

  .collapsing {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease-in-out;
  }

  .collapse.show {
    height: auto;
    transition: height 0.3s ease-in-out;
  }
}

.summary__mobile-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: $summary-mobile-bar;
  transition: transform 0.3s ease;
}

.summary__mobile-order {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: $blue-dark;
  padding: 20px 0;
  height: 44px;
  cursor: pointer;
  color: $white;
  transition: transform 0.3s ease;
}

.summary:not(.summary--mobile) {
  .summary__aside {
    padding: 20px 20px 0;
    background: $gray-bg;
    max-width: none;
    box-shadow: none;
  }
}

@include media-breakpoint-up(sm) {
  .summary {
    &__aside.collapse.show {
      bottom: 182px;
      height: auto;

      &.single-button {
        bottom: 130px;
      }
    }

    &__aside.collapsing {
      bottom: 182px;

      &.single-button {
        bottom: 130px;
      }
    }
  }
}

@include media-breakpoint-up(md) {
  body:has(.summary__aside.collapse.show) .back-to-top {
    display: none !important;
  }
}

@include media-breakpoint-up(lg) {
  .summary {
    &__aside {
      padding: 20px 20px 0;
      box-shadow: none;
    }

    & &__payment {
      display: block;
      padding: 0;
      margin: 0 -10px;

      .footer-checkout {
        &-holder {
          padding-top: 0;
          padding-bottom: 20px;
          justify-content: center;

          .payments {
            @include make-col(12);
            padding: 0;
          }

          &--payways {
            padding-bottom: 16px;
          }
        }

        &__copyright {
          display: none;
        }
      }
    }

    .checkout-widget.checkout-widget_order-summary {
      .checkout-widget {
        &__total {
          margin-left: -30px;
          margin-right: -30px;
        }
      }
    }

    &-large {
      order: inherit;

      .summary {
        &__aside {
          padding: 35px 60px 0;
        }

        &__payment {
          display: none;
        }
      }

      .checkout-widget.checkout-widget_order-summary {
        .checkout-widget {
          &__total {
            margin-left: -60px;
            margin-right: -60px;
            padding-left: 60px;
            padding-right: 60px;
          }
        }
      }
    }
  }

  .checkout-action__wrapper {
    position: static;
    box-shadow: none;
  }

  .basket {
    .summary {
      & .summary__payment {
        .footer-checkout-holder {
          padding: 20px 0;

          &--payways {
            padding: 16px 0;
          }
        }
      }
    }
  }
}
