@import "../common/var";
@import "../mixins/mixins";

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

  @include when(week-mode) {
    .el-date-table__row {
      td {
        &.in-range:has(+ .next-month) div{
          border-radius: 0;
        }

        &.in-range.start-date:has(+ .next-month) div{
          border-top-left-radius: 15px;
          border-bottom-left-radius: 15px;
        }

        &.in-range.end-date:has(+ .next-month) div{
          border-top-right-radius: 15px;
          border-bottom-right-radius: 15px;
        }
    
        &.prev-month + .in-range div{
          border-radius: 0;
        }

        &:last-child.in-range div{
          border-top-right-radius: 15px;
          border-bottom-right-radius: 15px;
        }

        &.prev-month + .end-date div{
          border-top-right-radius: 15px;
          border-bottom-right-radius: 15px;
        }

        &.prev-month + .start-date div{
          border-top-left-radius: 15px;
          border-bottom-left-radius: 15px;
        }
      }
      &:hover {
        div {
          background-color: $--datepicker-inrange-background-color;
        }
        td.available:hover {
          color: $--datepicker-font-color;
        }
        td.start-date div{
          border-radius: 0;
        }
        td.end-date div{
          border-radius: 0;
        }
        td.in-range.end-date:has(+ .next-month) div{
          border-radius: 0;
        }
        td:first-child div {
          border-top-left-radius: 15px;
          border-bottom-left-radius: 15px;
        }
        td:last-child div {
          border-top-right-radius: 15px;
          border-bottom-right-radius: 15px;
        }
      }

      &.current div {
        background-color: $--datepicker-inrange-background-color;
      }
    }
  }

  @include when(show-week-number) {
    .el-date-table__row {
      td:first-child div {
        border-radius: 0;
        .cell{
          border-radius: 15px;
          font-size: 12px;
          color: $--color-text-placeholder;
        }
      }
      td.in-range:nth-child(2) div {
        border-top-left-radius: 15px;
        border-bottom-left-radius: 15px;
      }
  
      td.in-range:last-child div {
        border-top-right-radius: 15px;
        border-bottom-right-radius: 15px;
      }
      &:hover {
        div {
          background-color: $--datepicker-inrange-background-color;
        }
        td.available:hover {
          color: $--datepicker-font-color;
        }
        td:first-child div {
          border-radius: 0;
          background: none;
          .cell {
            border-radius: 15px;
            background-color: $--datepicker-inrange-background-color;
          }
        }
        td:nth-child(2) div {
          border-top-left-radius: 15px;
          border-bottom-left-radius: 15px;
        }
        td:last-child div {
          border-top-right-radius: 15px;
          border-bottom-right-radius: 15px;
        }
      }

      &:has(> .in-range){
        .week .cell{
          color: $--color-primary;
          font-weight: $--font-weight-strengthen;
        }
      }

      &.current {
        td:first-child div{
          background: none;
          .cell{
            color: $--color-primary;
          }
        } 
        div {
          background-color: $--datepicker-inrange-background-color;
        }
      }
    }
  }

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

    & div {
      height: 30px;
      padding: 3px 0;
      box-sizing: border-box;
    }

    & span {
      width: 24px;
      height: 24px;
      display: block;
      box-sizing: border-box;
      margin: 0 auto;
      line-height: 24px;
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      border-radius: $--border-radius-semi-circle;
    }

    &.next-month,
    &.prev-month {
      color: $--datepicker-off-font-color;
    }

    &.in-range:has(+ .next-month) div{
      border-top-right-radius: 15px;
      border-bottom-right-radius: 15px;
    }

    &.prev-month + .in-range div{
      border-top-left-radius: 15px;
      border-bottom-left-radius: 15px;
    }

    &.today {
      position: relative;
      span {
        border: 1px solid;
        line-height: 22px;
        color: $--color-primary;
        font-weight: $--font-weight-strengthen;
      }
      &.start-date span,
      &.end-date span {
        color: $--color-white;
      }
      &.disabled{
        span{
          color: $--disabled-color-base;
        }
      }
    }

    &.available:hover {
      color: $--datepicker-hover-font-color;
    }

    &.in-range div {
      background-color: $--datepicker-inrange-background-color;
      &:hover {
        background-color: $--datepicker-inrange-hover-background-color;
      }
    }

    &.current:not(.disabled) span {
      color: $--color-white;
      background-color: $--datepicker-active-color;
    }
    &.start-date div,
    &.end-date div {
      color: $--color-white;
    }

    &.start-date span,
    &.end-date span {
      background-color: $--datepicker-active-color;
    }

    &.start-date {
      &.disabled{
        .cell {
          background-color: $--background-color-base;
        }
      }
      div {
        // margin-left: 5px;
        border-top-left-radius: 15px;
        border-bottom-left-radius: 15px;
      }
    }

    &.end-date {
      &.disabled{
        .cell {
          background-color: $--background-color-base;
        }
      }
      div {
        // margin-right: 5px;
        border-top-right-radius: 15px;
        border-bottom-right-radius: 15px;
      }
    } 

    &.disabled div {
      background-color: $--background-color-base;
      opacity: 1;
      cursor: not-allowed;
      color: $--color-text-disabled;
    }

    &.selected div {
      margin-left: 5px;
      margin-right: 5px;
      background-color: $--datepicker-inrange-background-color;
      border-radius: 15px;
      &:hover {
        background-color: $--datepicker-inrange-hover-background-color;
      }
    }

    &.selected span {
      background-color: $--datepicker-active-color;
      color: $--color-white;
      border-radius: 15px;
    }

    &.week {
      font-size: 80%;
      color: $--datepicker-header-font-color;
    }
  }

  .in-range:first-child div {
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
  }

  .in-range:last-child div {
    border-top-right-radius: 15px;
    border-bottom-right-radius: 15px;
  }

  th {
    padding: 5px;
    color: $--datepicker-header-font-color;
    font-weight: $--font-weight-primary;
    border-bottom: $--border-base;
  }
}
