@import './var.less';

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

.glm-calendar {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--glm-calendar-background-color);

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

    &.glm-popup--left,
    &.glm-popup--right {
      height: 100%;
    }

    .glm-popup__close-icon {
      top: 11px;
    }
  }

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

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

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

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

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

  &__weekdays {
    display: flex;
  }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  &__top-info {
    top: 6px;
  }

  &__bottom-info {
    bottom: 6px;
  }

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

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

  &__confirm {
    height: var(--glm-calendar-confirm-button-height);
    margin: var(--glm-calendar-confirm-button-margin);
  }
}
