@import '../../base.less';

@import '../../mixins/_cursor.less';

@import './_var.less';

.@{prefix}-calendar {
  position: relative;
  z-index: 9999;
  background: @calendar-bg-color;
  overflow-x: hidden;

  &--popup {
    border-top-left-radius: @calendar-radius;
    border-top-right-radius: @calendar-radius;
  }

  &__title {
    display: flex;
    align-items: center;
    justify-content: center;
    font: @calendar-title-font;
    color: @calendar-title-color;
    padding: @spacer-2;

    &:focus {
      outline: 0;
    }
  }

  &__close-btn {
    position: absolute;
    top: @spacer-2;
    right: @spacer-2;
    margin: calc(-1 * @spacer-1);
    padding: @spacer-1;
    color: @calendar-title-color;
  }

  &-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 8px;
    box-sizing: border-box;
    .border(bottom, @border-color);

    &__title {
      flex: 1;
      text-align: center;
      font: @font-title-small;
    }

    &__action {
      display: flex;
      font-size: 20px;
      color: @calendar-switch-mode-icon-color;
    }

    &__icon {
      display: flex;
      padding: 8px;
      cursor: pointer;
    }

    &__icon--disabled {
      color: @calendar-switch-mode-icon-disabled-color;
      cursor: not-allowed;
    }
  }

  &__days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-column-gap: 4px;
    padding: 0 16px;
    text-align: center;
    line-height: 46px;

    &-item {
      height: 46px;
      font-size: 14px;
      color: @calendar-days-color;
    }
  }

  &__content {
    min-height: 200px;
    display: flex;
    flex-direction: column;
  }

  &__month {
    font: @font-title-small;
    color: @calendar-title-color;
    padding: 16px 0 0;

    &s {
      height: 356px;
      padding: 0 16px 16px;
      box-sizing: border-box;

      &::-webkit-scrollbar {
        display: none;
      }
    }
  }

  &__dates {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-column-gap: 4px;

    &-item {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      font: @font-title-medium;
      border-radius: 8px;
      height: 60px;
      margin-top: 8px;
      color: @calendar-dates-color;

      .cursor-pointer();

      &-prefix,
      &-suffix {
        position: absolute;
        font: @font-body-extraSmall;
        width: 100%;
        text-align: center;
      }

      &-prefix {
        top: 4px;
      }

      &-suffix {
        bottom: 4px;
        color: @calendar-item-suffix-color;

        &--selected,
        &--start,
        &--end {
          color: @calendar-selected-color;
        }

        &--disabled {
          color: @calendar-item-disabled-color;
        }
      }

      &--selected,
      &--start,
      &--start-end,
      &--end {
        background: @calendar-active-color;
        color: @calendar-selected-color;
        border-radius: 4px;
      }

      &--start {
        border-radius: 4px 0 0 4px;
      }

      &--end {
        border-radius: 0 4px 4px 0;
      }

      &--start + &--end {
        &::before {
          content: '';
          display: block;
          position: absolute;
          top: 0;
          width: 4px;
          height: 100%;
          background: @calendar-active-color;
        }

        &::before {
          left: -4px;
        }
      }

      &--centre {
        border-radius: 0;
        background-color: @calendar-item-centre-color;

        &::before,
        &::after {
          content: '';
          display: block;
          position: absolute;
          top: 0;
          width: 4px;
          height: 100%;
          background-color: @calendar-item-centre-color;
        }

        &::before {
          left: -4px;
        }

        &::after {
          right: -4px;
        }
      }

      &--disabled {
        color: @calendar-item-disabled-color;
        cursor: default;
      }
    }
  }

  &__footer {
    padding: 16px;
  }
}
