@import './var.less';

:root {
  --rv-calendar-background-color: @calendar-background-color;
  --rv-calendar-popup-height: @calendar-popup-height;
  --rv-calendar-header-box-shadow: @calendar-header-box-shadow;
  --rv-calendar-header-title-height: @calendar-header-title-height;
  --rv-calendar-header-title-font-size: @calendar-header-title-font-size;
  --rv-calendar-header-subtitle-font-size: @calendar-header-subtitle-font-size;
  --rv-calendar-weekdays-height: @calendar-weekdays-height;
  --rv-calendar-weekdays-font-size: @calendar-weekdays-font-size;
  --rv-calendar-month-title-font-size: @calendar-month-title-font-size;
  --rv-calendar-month-mark-color: @calendar-month-mark-color;
  --rv-calendar-month-mark-font-size: @calendar-month-mark-font-size;
  --rv-calendar-day-height: @calendar-day-height;
  --rv-calendar-day-font-size: @calendar-day-font-size;
  --rv-calendar-range-edge-color: @calendar-range-edge-color;
  --rv-calendar-range-edge-background-color: @calendar-range-edge-background-color;
  --rv-calendar-range-middle-color: @calendar-range-middle-color;
  --rv-calendar-range-middle-background-opacity: @calendar-range-middle-background-opacity;
  --rv-calendar-selected-day-size: @calendar-selected-day-size;
  --rv-calendar-selected-day-color: @calendar-selected-day-color;
  --rv-calendar-info-font-size: @calendar-info-font-size;
  --rv-calendar-info-line-height: @calendar-info-line-height;
  --rv-calendar-selected-day-background-color: @calendar-selected-day-background-color;
  --rv-calendar-day-disabled-color: @calendar-day-disabled-color;
  --rv-calendar-confirm-button-height: @calendar-confirm-button-height;
  --rv-calendar-confirm-button-margin: @calendar-confirm-button-margin;
}

.@{rv-prefix}-calendar {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--rv-calendar-background-color);

  &__popup {
    &.@{rv-prefix}-popup--top,
    &.@{rv-prefix}-popup--bottom {
      height: var(--rv-calendar-popup-height);
    }

    &.@{rv-prefix}-popup--left,
    &.@{rv-prefix}-popup--right {
      height: 100%;
    }

    .@{rv-prefix}-popup__close-icon {
      top: 11 * @hd;
    }
  }

  &__header {
    flex-shrink: 0;
    box-shadow: var(--rv-calendar-header-box-shadow);
  }

  &__month-title,
  &__header-title,
  &__header-subtitle {
    height: var(--rv-calendar-header-title-height);
    font-weight: var(--rv-font-weight-bold);
    line-height: var(--rv-calendar-header-title-height);
    text-align: center;
  }

  &__header-title {
    font-size: var(--rv-calendar-header-title-font-size);
  }

  &__header-subtitle {
    font-size: var(--rv-calendar-header-subtitle-font-size);
  }

  &__month-title {
    font-size: var(--rv-calendar-month-title-font-size);
  }

  &__weekdays {
    display: flex;
  }

  &__weekday {
    flex: 1;
    font-size: var(--rv-calendar-weekdays-font-size);
    line-height: var(--rv-calendar-weekdays-height);
    text-align: center;
  }

  &__body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  &__ranges {
    padding: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }

  &__ranges-btn {
    border-radius: 10px;
    background-color: #fff;
    padding: 5px 10px;
    text-align: center;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    &:hover {
      border-color: #8bc34a;
      color: #8bc34a;
    }
  }

  &__horizontal-body {
    flex: 1;
    // overflow-x: hidden;
    // overflow-y: scroll;
    height: 100%;
  }

  &__days {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    user-select: none;
  }

  &__month-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 0;
    color: var(--rv-calendar-month-mark-color);
    font-size: var(--rv-calendar-month-mark-font-size);
    transform: translate(-50%, -50%);
    pointer-events: none;
    white-space: nowrap;
  }

  &__day,
  &__selected-day {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  &__day {
    position: relative;
    width: 14.285%;
    height: var(--rv-calendar-day-height);
    font-size: var(--rv-calendar-day-font-size);
    cursor: pointer;

    &--end,
    &--start,
    &--start-end,
    &--multiple-middle,
    &--multiple-selected {
      color: var(--rv-calendar-range-edge-color);
      background-color: var(--rv-calendar-range-edge-background-color);
    }

    &--start {
      border-radius: var(--rv-border-radius-md) 0 0 var(--rv-border-radius-md);
    }

    &--end {
      border-radius: 0 var(--rv-border-radius-md) var(--rv-border-radius-md) 0;
    }

    &--start-end,
    &--multiple-selected {
      border-radius: var(--rv-border-radius-md);
    }

    &--middle {
      color: var(--rv-calendar-range-middle-color);

      &::after {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background-color: currentColor;
        opacity: var(--rv-calendar-range-middle-background-opacity);
        content: '';
      }
    }

    &--disabled {
      color: var(--rv-calendar-day-disabled-color);
      cursor: default;
    }
  }

  &__top-info,
  &__bottom-info {
    position: absolute;
    right: 0;
    left: 0;
    font-size: var(--rv-calendar-info-font-size);
    line-height: var(--rv-calendar-info-line-height);

    @media (max-width: 350px) {
      font-size: 9 * @hd;
    }
  }

  &__top-info {
    top: 6 * @hd;
  }

  &__bottom-info {
    bottom: 6 * @hd;
  }

  &__selected-day {
    width: var(--rv-calendar-selected-day-size);
    height: var(--rv-calendar-selected-day-size);
    color: var(--rv-calendar-selected-day-color);
    background-color: var(--rv-calendar-selected-day-background-color);
    border-radius: var(--rv-border-radius-md);
  }

  &__footer {
    flex-shrink: 0;
    padding-right: var(--rv-padding-md);
    padding-left: var(--rv-padding-md);
  }

  &__confirm {
    &.@{rv-prefix}-button {
      height: var(--rv-calendar-confirm-button-height);
      margin: var(--rv-calendar-confirm-button-margin);
    }
  }
}
