@import '../../scss/_bootstrap-extended/functions';

@mixin flatpickr-theme($background, $color: null) {
  $in-range-bg: rgba-to-hex(rgba($background, 0.16), $card-bg);
  $color: if($color, $color, color-contrast($background));

  .flatpickr-day {
    &.today,
    &.today:hover {
      color: $color !important;
      border-color: $background;
      background-color: $background !important;
      box-shadow: 0 0.125rem 0.25rem 0 rgba($background, 0.4);
    }

    &.selected,
    &.selected:focus,
    &.selected:hover,
    &.inRange,
    &.nextMonthDay.inRange,
    &.prevMonthDay.inRange,
    &.today.inRange,
    &.prevMonthDay.today.inRange,
    &.nextMonthDay.today.inRange {
      color: $background !important;
      background: $in-range-bg !important;
      border-color: $in-range-bg !important;
    }

    &.selected.inRange,
    &.selected.nextMonthDay,
    &.selected.prevMonthDay,
    &.startRange,
    &.startRange.inRange,
    &.startRange:focus,
    &.startRange:hover,
    &.startRange.nextMonthDay,
    &.startRange.prevMonthDay,
    &.endRange,
    &.endRange.inRange,
    &.endRange:focus,
    &.endRange:hover,
    &.endRange.nextMonthDay,
    &.endRange.prevMonthDay,
    &.week.selected {
      color: $color !important;
      background: $background !important;
      border-color: $background !important;
      box-shadow: 0 0.125rem 0.25rem 0 rgba($background, 0.4);
    }
  }
}

@mixin flatpickr-dark-theme($background, $color: null) {
  $color: if($color, $color, color-contrast($background));
  $in-range-bg: rgba-to-hex(rgba($background, 0.16), $card-bg);

  .flatpickr-calendar .numInputWrapper span {
    &.arrowUp:after {
      border-bottom-color: $color;
    }

    &.arrowDown:after {
      border-top-color: $color;
    }
  }

  .flatpickr-day {
    &.today,
    &.today:hover,
    &.inRange {
      color: $color !important;
      border-color: $background !important;
      background-color: $background !important;
      box-shadow: 0 0.125rem 0.25rem 0 rgba($background, 0.4);
    }

    &.selected,
    &.selected:focus,
    &.selected:hover,
    &.inRange,
    &.nextMonthDay.inRange,
    &.prevMonthDay.inRange,
    &.today.inRange,
    &.nextMonthDay.today.inRange,
    &.prevMonthDay.today.inRange {
      border-color: $in-range-bg !important;
      background: $in-range-bg !important;
      color: $background !important;
    }

    &.selected.inRange,
    &.selected.prevMonthDay,
    &.selected.nextMonthDay,
    &.startRange,
    &.startRange.inRange,
    &.startRange:focus,
    &.startRange:hover,
    &.startRange.prevMonthDay,
    &.startRange.nextMonthDay,
    &.endRange,
    &.endRange.inRange,
    &.endRange:focus,
    &.endRange:hover,
    &.endRange.nextMonthDay,
    &.endRange.prevMonthDay,
    &.week.selected {
      background: $background !important;
      border-color: $background !important;
      color: $color !important;
    }
  }
}
