@use "sass:math";

.cobalt-CalendarDayPicker {
  $calendar-day-inner-height: 24px;
  $calendar-day-padding: 6px;
  $calendar-day-size: $calendar-day-inner-height + ($calendar-day-padding * 2);
  $calendar-selected-size: $calendar-day-inner-height + 8px;

  @mixin disk {
    position: absolute;
    z-index: -1;
    top: math.div($calendar-day-inner-height - $calendar-selected-size, 2);
    left: 0;
    right: 0;

    margin: auto;

    height: $calendar-selected-size;
    width: $calendar-selected-size;

    content: "";

    @apply c-rounded-full;
  }

  position: relative;

  @include breakpoint($until: sm) {
    &__months-container {
      flex-direction: column;

      @apply c-gap-sm;
    }
  }

  &__months-container {
    display: flex;
  }

  &__months-container > &__month {
    margin: 0 8px;
  }

  &__month {
    @apply c-bg-surfaceBright;
    flex: 1;
  }

  &__month-header {
    @apply c-text-title-sm c-text-onSurface;
    margin-bottom: 12px;
    padding: 4px;

    text-align: center;
    font-weight: 600;
    text-transform: capitalize;
  }

  &__month__week {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin: 0;
  }

  &__month__week ~ &__month__week {
    justify-content: flex-start;
  }

  &__month__week-header {
    display: flex;
    margin-bottom: 6px;
  }

  &__month__day-header {
    @apply c-text-onSurfaceVariant;
    flex: 1;

    text-align: center;
    text-transform: capitalize;
    font-weight: 400;
    font-size: 14px;
  }

  &__day {
    position: relative;

    z-index: 1;

    box-sizing: border-box;

    flex-basis: calc(100% / 7);

    min-width: $calendar-selected-size;

    padding: $calendar-day-padding 0;

    border: unset;

    font-size: 13px;

    line-height: $calendar-day-inner-height;

    text-align: center;

    background: unset;
    cursor: pointer;

    .cobalt-CalendarDayPicker__day-inner {
      position: relative;

      z-index: 1;
    }

    &--today {
      @apply c-text-primary;
      font-weight: 600;
    }

    &:not(&--disabled):not(&--selected):hover
      .cobalt-CalendarDayPicker__day-inner {
      font-weight: 600;
    }

    &:not(&--disabled):not(&--selected):hover
      .cobalt-CalendarDayPicker__day-inner:after {
      @include disk;
      @apply c-bg-primaryContainer;
    }

    &--selected .cobalt-CalendarDayPicker__day-inner:after {
      @include disk;
      @apply c-bg-primary;

      box-shadow: theme("colors.primaryContainer") 0 2px 6px 0;
    }

    &--selected .cobalt-CalendarDayPicker__day-inner {
      @apply c-text-surfaceFixed;
      font-weight: 600;
    }

    &--disabled {
      @apply c-text-outline;

      cursor: auto;
    }
  }

  &__message {
    display: flex;
    justify-content: center;
    align-items: center;

    margin: 0;

    @apply c-py-none c-px-sm;

    height: 0;

    opacity: 0;

    transition:
      height 350ms,
      opacity 350ms;

    &--show {
      height: 40px;

      opacity: 1;
    }

    .cobalt-Hint {
      margin: 0;
    }
  }
}
