@use '../common/var' as *;
@use '../mixins/mixins' as *;

@include b(date-table) {
  font-size: 12px;
  user-select: none;

  @include when(week-mode) {
    .#{$namespace}-date-table__row {
      &:hover {
        .#{$namespace}-date-table-cell {
          background-color: getCssVar('datepicker-inrange-bg-color');
        }
        td.available:hover {
          color: getCssVar('datepicker-text-color');
        }
      }

      &.current .#{$namespace}-date-table-cell {
        background-color: getCssVar('datepicker-inrange-bg-color');
      }
    }
  }

  td {
    padding: 4px 0;
    box-sizing: border-box;
    text-align: center;
    cursor: pointer;
    position: relative;

    @include b(date-table-cell) {
      height: 32px;
      box-sizing: border-box;
      @include b(date-table-cell__text) {
        width: 32px;
        height: 32px;
        display: block;
        margin: 0 auto;
        line-height: 32px;
        position: absolute;
        left: 50%;
        border-radius: getCssVar('border-radius', 'small');
        transform: translateX(-50%);
      }
    }
    &:not(.in-range) {
      @include b(date-table-cell__text) {
        &:hover {
          background-color: getCssVar('bg-color-hover');
        }
      }
    }
    &.next-month,
    &.prev-month {
      color: getCssVar('datepicker-off-text-color');
    }

    &.today {
      position: relative;
      .#{$namespace}-date-table-cell__text {
        // color: getCssVar('color-primary');
        border: 1px solid getCssVar('border-color', 'primary');
        line-height: 30px;
        // font-weight: bold;
      }
      &.start-date .#{$namespace}-date-table-cell__text,
      &.end-date .#{$namespace}-date-table-cell__text {
        color: $color-white;
      }
    }

    &.in-range .#{$namespace}-date-table-cell {
      background-color: getCssVar('datepicker-inrange-bg-color');
      &:hover {
        background-color: getCssVar('datepicker-inrange-hover-bg-color');
      }
    }

    &.current:not(.disabled) {
      .#{$namespace}-date-table-cell__text {
        color: $color-white;
        background-color: getCssVar('datepicker-active-color');
      }
      &:focus-visible {
        .#{$namespace}-date-table-cell__text {
          outline: 2px solid getCssVar('datepicker-active-color');
          outline-offset: 1px;
        }
      }
    }
    &.start-date .#{$namespace}-date-table-cell,
    &.end-date .#{$namespace}-date-table-cell {
      color: $color-white;
    }

    &.start-date .#{$namespace}-date-table-cell__text,
    &.end-date .#{$namespace}-date-table-cell__text {
      background-color: getCssVar('datepicker-active-color');
    }

    &.start-date .#{$namespace}-date-table-cell {
      margin-left: 5px;
    }

    &.end-date .#{$namespace}-date-table-cell {
      margin-right: 5px;
    }

    &.disabled .#{$namespace}-date-table-cell {
      background-color: getCssVar('fill-color', 'light');
      opacity: 1;
      cursor: not-allowed;
      color: getCssVar('text-color', 'placeholder');
    }

    &.selected .#{$namespace}-date-table-cell {
      margin-left: 5px;
      margin-right: 5px;
      background-color: getCssVar('datepicker-inrange-bg-color');
    }

    &.selected .#{$namespace}-date-table-cell__text {
      background-color: getCssVar('datepicker-active-color');
      color: $color-white;
      &:hover {
        background-color: getCssVar('datepicker-active-color');
      }
    }

    &.week {
      font-size: 80%;
      color: getCssVar('datepicker-header-text-color');
    }

    &:focus {
      outline: none;
    }
  }

  th {
    padding: 5px;
    color: getCssVar('datepicker-header-text-color');
    font-weight: 400;
    border-bottom: solid 1px getCssVar('border-color-light');
  }
}
