.date-input-spacer {
  & > .inner {
    position: relative;

    &.with-time {
      & > .fields-track {
        display: grid;
        grid-template-columns: 1fr 80px;
        column-gap: var(--spacing-s);

        & > .react-datepicker-wrapper {
          &:first-child {
            grid-row: 1;
            grid-column: 1 / 2;
          }

          &:last-child {
            grid-row: 1;
            grid-column: 2 / 3;
          }
        }
      }
    }

    & > .label {
      user-select: none;
      @include typography(app-wizard-1);
      color: var(--text-body-tertiary);
      padding-bottom: var(--spacing-xs);
    }
  }
}

.date-input-container {
  position: relative;

  &.clearable {
    & > .date-input {
      padding: 8px 42px 8px 20px;
    }

    &:hover {
      & > .interaction-box {
        visibility: visible;
      }
    }
  }

  .interaction-box {
    visibility: hidden;
    width: 24px;
    height: 24px;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);

    &:hover {
      svg path {
        fill: var(--surface-alert-primary);
      }
    }
  }

  .date-input {
    display: flex;
    flex-flow: row;
    align-items: center;
    justify-content: flex-start;
    background-color: var(--surface-frame-bg);
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    box-sizing: border-box;
    width: 100%;
    min-height: 50px;
    margin: 0;
    padding: 8px 20px;
    cursor: pointer;
    opacity: 1;

    @include animate-field;
    transition-property: border-color, opacity;

    span {
      width: 100%;
      text-align: left;
      @include typography(app-input);
    }
  }

  &.disabled {
    cursor: not-allowed;

    & > .date-input {
      cursor: not-allowed;
      opacity: var(--disabled-opacity);
    }
  }

  &.error {
    & > .date-input {
      border-color: var(--border-alert);
    }
  }
}

.react-datepicker-popper {
  z-index: 2;
}

.react-datepicker {
  border-radius: 10px;
  background-color: var(--surface-default-modal);
  border: 1px solid var(--border-primary);
  box-sizing: border-box;
  padding: var(--spacing-s);
  width: 100%;
  max-width: 360px;
}

.react-datepicker__triangle {
  color: var(--border-primary);
}

.react-datepicker__day-names {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto;
  column-gap: var(--spacing-s);
  align-items: center;
  border-bottom: 1px solid var(--border-primary);
}

.react-datepicker__aria-live {
  display: none;
}

.react-datepicker-wrapper {
  width: 100%;
}

.react-datepicker__month {
  display: flex;
  flex-flow: column;
  row-gap: var(--spacing-xs);
}

.react-datepicker__week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  column-gap: var(--spacing-s);
}

.react-datepicker__day {
  width: 100%;
  cursor: pointer;

  .custom-day {
    display: flex;
    flex-flow: row;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;

    @include typography(app-modal-1);

    &:hover {
      background-color: var(--surface-main-primary);

      span {
        color: var(--white);
      }
    }
  }
}

.react-datepicker__day--selected {
  & > .custom-day {
    background-color: var(--surface-main-primary);

    span {
      color: var(--white);
    }
  }
}

.react-datepicker__header {
  padding: 0 0 var(--spacing-xs) 0;

  .date-picker-custom-header {
    display: grid;
    width: 100%;
    grid-template-rows: auto;
    grid-template-columns: 22px 1fr 22px;
    align-items: center;
    justify-items: start;
    column-gap: 10px;
    border: 0;
    padding-bottom: var(--spacing-xs);

    button {
      display: flex;
      flex-flow: row;
      align-items: center;
      justify-content: center;
      margin: 0;
      padding: 0;
      background: none;
      border: none;
      width: 22px;
      height: 22px;
      cursor: pointer;

      svg {
        width: 100%;
        height: 100%;
      }

      &:last-child {
        svg {
          transform: rotateZ(-180deg);
        }
      }
    }

    p {
      width: 100%;
      text-align: center;
      @include typography(modal-title);
      user-select: none;
    }

    .icon-container {
      svg {
        path {
          fill: var(--surface-icon-primary);
        }
      }
    }
  }
}

.react-datepicker-time__header {
  color: var(--text-body-primary);
  @include typography(modal-title);
  border-bottom: 1px solid var(--border-primary);
  padding-bottom: var(--spacing-xs);
}

.react-datepicker__time-list {
  display: flex;
  flex-flow: column;
  row-gap: var(--spacing-xs);
  list-style: none;
  padding-right: 10px;
  scrollbar-gutter: stable;
  max-height: min(250px, 75dvh);
  overflow: auto;

  .react-datepicker__time-list-item {
    @include typography(app-modal-1);
    color: var(--text-body-primary);
    padding: 3px;
    border-radius: 5px;
    cursor: pointer;
    background-color: transparent;

    &:hover,
    &.react-datepicker__time-list-item--selected {
      color: var(--white);
      background-color: var(--surface-main-primary);
    }
  }
}
