.date-selection {
  position: relative;

  &.date-selection_selected {
    border: 1px solid $gray;
  }
}

.delivery-date {
  width: 100%;
  height: 324px;
}

.delivery-time {
  position: relative;
  background: $white;

  &__no-selection {
    @include heading-4;
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    font-weight: 500;
    color: $gray-dark;
    text-align: center;

    .date-selection_selected & {
      display: none;
    }
  }

  &__rapid-hint {
    border-top: 1px dashed $blue-dark;
    display: flex;
    padding: 24px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    align-self: stretch;

    .description {
      @include font-size(14);
      @include line-height(22);
      text-align: center;
      font-weight: 400;
      max-width: 226px;
      margin-bottom: 0;
    }

    .icon {
      font-size: 2rem;
      height: auto;
      color: $blue-satin;
    }

    .date-selection_selected & {
      display: none;
    }
  }
}

.calendar {
  height: 100%;
  padding: 20px;
  border: 1px solid $gray;
  text-align: center;

  .date-selection_selected & {
    border: 0;
  }

  &__month {
    @include heading-4;
    margin-bottom: 20px;
  }

  &__row {
    display: flex;
    justify-content: space-between;

    &_names {
      margin-bottom: 10px;
      background: $gray-light;
    }
  }

  &__cell {
    width: 14.2857%;
    height: 34px;
    line-height: 2.375rem;

    &_cnt {
      font-size: 1rem;
      cursor: pointer;
      border: 1px solid transparent;
      user-select: none;

      &:hover {
        border-color: $blue;
      }
    }

    &_inactive {
      pointer-events: none;
      color: $gray;
    }

    &_selected {
      background: $blue;
      color: $white;
    }

    &_rapid {
      display: inline;
      align-items: center;
      position: relative;

      &::after {
        content: '';
        position: relative;
        display: block;
        background: $ma-white;
        border-radius: 50%;
        width: 34px;
        height: 34px;
        top: -34px;
        left: calc(50% - 34px / 2);
        z-index: $circle-z-index;
      }

      .label-rapid {
        @include font-size(10);
        @include line-height(10);
        border-radius: 30px;
        border: 1px solid $white;
        background: $pacific-depths;
        position: absolute;
        bottom: -8px;
        left: 50%;
        font-style: normal;
        font-weight: 700;
        transform: translate(-50%, 0);
        padding: 2px 4px;
        color: $white;
        z-index: $label-z-index;
        pointer-events: none;
      }

      &.calendar__cell_selected {
        &:after {
          background: $blue;
        }
      }
    }
  }
}

.delivery-types {
  display: none;
  background: $blue-transparent5;
  margin: 10px 10px 10px -20px;
}

.delivery-types {
  position: relative;
  padding: 20px 20px 10px;

  &__date {
    font-size: 1.125rem;
    font-weight: 500;
  }

  .date-selection_selected & {
    display: block;
  }

  &__name {
    @include heading-5;
    display: inline-block;
    margin-bottom: 5px;

    .icon {
      display: inline;
      padding-left: 5px;
      color: $blue;
    }
  }

  &__slots {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
  }

  &__slot {
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-start;

    .rbn {
      display: inline-block;
      width: 175px;
      padding-right: 20px;
    }
  }

  &__cost {
    display: inline-block;
    text-transform: uppercase;
    font-weight: bold;
    line-height: 1.5rem;
    padding-right: 20px;
  }

  &__confirm {
    width: 76px;
    padding: 8px 12px;
    margin: 22px 0 0;
  }

  &__error {
    display: none;
    color: $red;
    margin-bottom: 15px;
    margin-top: -2px;

    &-show {
      display: block;
    }
  }

  &.delivery-types-hide {
    display: none;
  }

  &__accordion {
    display: none;
    pointer-events: auto;

    &.collapsed {
      transform: rotate(0);
    }
  }

  &::after {
    top: 0;
    right: -1px;
  }

  &::before {
    top: 0;
    left: -1px;
  }

  &-fixed-height {
    // sass-lint:disable no-important
    height: 280px !important;
  }
}

.delivery-type {
  padding-top: 10px;

  & + & {
    border-top: 1px solid $gray-light;
    margin-top: 5px;
  }
}

.calendar__row {
  display: block;

  &:not(&_names):not(:last-child) {
    padding-bottom: 6px;
  }

  &_days,
  &_names {
    display: flex;
  }

  &_extended {
    position: relative;
    border-top: 1px solid $gray;
    border-bottom: 1px solid $gray;
    height: auto;
    overflow-y: scroll;
    text-align: left;

    &-hide {
      display: none;

      & .delivery-types {
        display: none;
      }
    }
  }

  &_names {
    pointer-events: none;
    user-select: none;
  }
}

@include media-breakpoint-up(md) {
  .date-selection__inner {
    grid-gap: 10px;
  }

  .delivery-date {
    width: 100%;

    .date-selection_selected & {
      &::after {
        top: 20px;
        bottom: 20px;
      }
    }
  }

  .delivery-time {
    width: 100%;

    &__rapid-hint {
      border-top: 0;
      background: $white;
      height: 100%;
    }
  }

  .date-selection {
    .delivery-time {
      background: initial;
    }

    &__inner {
      display: flex;
    }
  }
}

@include media-breakpoint-only(lg) {
  .delivery-date,
  .delivery-time {
    max-width: 50%;
    flex: 1 1 50%;
  }
}

@include media-breakpoint-down(md) {
  .delivery-types {
    margin: 10px;
  }

  .delivery-types {
    padding: 20px;
  }
}

@include media-breakpoint-down(sm) {
  .delivery-date {
    @include make-col(12);
    height: 271px;
  }

  .delivery-time {
    @include make-col(12);
    height: auto;

    .date-selection_time-visible & {
      display: block;
    }
  }

  .delivery-types {
    height: auto;
    margin: -3px 7px 7px;
  }

  .delivery-types {
    height: auto;
    padding: 10px 20px 20px;
    margin: 0;

    &__date {
      padding-top: 10px;
    }

    &__slot {
      justify-content: space-between;
    }

    &__confirm {
      margin: 5px 0 0;
    }

    &__accordion {
      display: block;
      position: absolute;
      z-index: 1;
      top: 20px;
      right: 20px;
      font-size: 1.125rem;
      color: $blue;
      transition: all 0.5s ease;
      transform: rotate(180deg);
    }
  }

  .calendar__row {
    &_extended {
      overflow-y: inherit;

      &-hide {
        & .delivery-types {
          display: block;
        }
      }
    }
  }

  .delivery {
    &-date {
      height: auto;
    }

    &-type {
      padding-top: 10px;
      text-align: left;
    }

    &-types {
      &__name {
        text-align: left;
      }
    }
  }

  .rbn {
    text-align: left;
  }
}

@include media-breakpoint-down(xs) {
  .delivery-types {
    &__error {
      margin-right: 10px;
    }
  }
}
