.date-selection {
  position: relative;

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

  &__inner {
    @include make-row;
  }
}

.delivery-date {
  @include make-col-ready;
  height: 324px;
}

.delivery-time {
  @include make-col-ready;
  height: 324px;

  &__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;
    }
  }

  &__show-calendar {
    display: none;
  }
}

.calendar {
  height: 100%;
  padding: 20px 20px 0;
  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;
    padding: 6px 20px;

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

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

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

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

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

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

.delivery-selection,
.delivery-types {
  display: none;
  height: 304px;
  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;
  }

  &__inner {
    height: 74%;
  }

  &__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,
  &::before {
    display: inline-block;
    position: absolute;
    content: '';
    width: 1px;
    height: 100%;
    background: $blue-transparent5-rgb;
  }

  &::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;
  }
}

.delivery-selection {
  justify-content: center;
  align-items: center;
  flex-direction: column;


  &__date,
  &__time {
    font-weight: 500;
    font-size: 1.125rem;
    line-height: 1.5rem;
  }

  &-show {
    display: flex;
  }


  &-mobile {
    display: none;
    margin-bottom: 8px;
  }

  &__show-calendar {
    display: none;
  }
}

.calendar__row {
  display: block;
  padding: 6px 0 0;

  &_days,
  &_names {
    display: flex;
    padding: 0 10px;
  }

  &_days {
    padding-bottom: 6px;
  }

  &_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;
      }
    }
  }
}

@include media-breakpoint-up(lg) {
  .delivery-date {
    @include make-col(5, 9);

    &::after {
      content: '';
      position: absolute;
      top: 0;
      right: 15px;
      bottom: 0;
      border: .5px solid $gray;
    }

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

  .delivery-time {
    @include make-col(4, 9);
  }

  .calendar {
    border-right: 0;

    &__row {
      &_names {
        padding-top: 1px;
        padding-bottom: 1px;
      }
    }
  }

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

@include media-breakpoint-up(md) {
  .delivery-selection-mobile,
  .calendar__row_extended {
    // sass-lint:disable no-important
    display: none !important;
  }

}

@include media-breakpoint-only(md) {
  .date-selection {
    &_selected {
      .shown-time {
        .date-selection__inner {
          .delivery-date {
            display: none;
          }

          .delivery-time {
            display: block;
          }
        }
      }
    }
  }

  .delivery-selection,
  .delivery-time {
    &__show-calendar {
      display: block;
      position: absolute;
      font-size: .875rem;
      line-height: 1rem;
    }
  }

  .delivery-time {
    &__show-calendar {
      bottom: 20px;
      right: 20px;
    }
  }

  .delivery-selection {
    &__show-calendar {
      bottom: 40px;
    }
  }
}

@include media-breakpoint-down(md) {
  .delivery-date {
    @include make-col(12);

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

  .delivery-time {
    @include make-col(12);
    display: none;

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

  .delivery-selection,
  .delivery-types {
    margin: 10px;
  }

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

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

  .delivery-time {
    height: 330px;
  }

  .calendar {
    padding: 10px 0 0;

    &__month {
      margin-bottom: 8px;
    }
  }

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

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

    &__date {
      padding-top: 10px;
    }

    &__inner {
      height: 80%;
      padding-bottom: 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 .5s ease;
      transform: rotate(180deg);
    }
  }

  .delivery-selection {
    &-mobile {
      position: relative;
      padding: 5px 0;
      margin-bottom: 17px;

      &::after {
        content: '';
        position: relative;
        display: block;
        width: 100%;
        height: 1px;
        bottom: -13px;
        background: $white;
        border-bottom: 1px solid $gray;
      }
    }

    &__date,
    &__time {
      font-weight: 400;
    }

    &__caption {
      display: block;
    }
  }

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

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

    &_days,
    &_names {
      padding-left: 20px;
      padding-right: 20px;
    }
  }

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

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

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

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

  .rbn {
    text-align: left;
  }

  .date-selection_time-visible {
    .date-selection__inner {
      .delivery-date {
        display: block;
      }

      .delivery-time {
        display: none;
      }
    }
  }
}

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