@import "../vars.less";
@import "../mixins/index.less";

@time-options-item-height: 40px;
@item-count: 6;
@item-selected-bg-color: #FBFBFB;

@icon-color: #bfbfbf;

.input-active() {
  z-index: 1;
  border-color: @primary-color;
}

.hive-picker {
  padding: 0;

  &__input {
    min-width: 304px;
    display: inline-flex;
    border: @border-main;
    background: #fff;
    border-radius: @input-border-radius-default;
    width: 100%;
    
    // input active focus 和 disabled不会共存...
    &:hover:not(.hive-picker__input--disabled),
    &--focused:not(.hive-picker__input--disabled) {
      .input-active();

      .hive-picker__input-icon:not(.hive-picker__input-icon--clear) {
        color: @primary-color;
      }
    }

    // input disabled
    &--disabled {
      background: #fbfbfb;
      border-color: @disabled-color;
      cursor: not-allowed;
    }

    // input readonly
    &--readonly {
      cursor: default;
      &:focus {
        .input-active();
      }
    }

    &--error {
      border-color: @error-color;
    }

    // input show clear
    &:not(&--empty):hover&:not(&--disabled):hover&:not(&--readonly):hover {
      .hive-picker__input-icon--suffix {
        visibility: hidden;
      }
      .hive-picker__input-icon--clear {
        visibility: visible;
      }
    }

    &--size-small {
      border-radius: @input-border-radius-small;
      .hive-picker__input-icon {
        height: @input-inner-height-small;
        line-height: @input-inner-height-small;
      }
    }

    .hive-input__input {
      border: none;
    }

    &-separator {
      padding: 0 10px;
      line-height: @input-inner-height-default;
    }

    &-suffixicon {
      position: relative;
      min-width: 24px;
      margin: 0 8px;
    }

    &-icon {
      position: absolute;
      height: @input-inner-height-default;
      line-height: @input-inner-height-default;
      font-size: 0;
      color: @icon-color;

      .hive-icon {
        font-size: 20px;
        vertical-align: middle;
      }

      &--suffix {
        .hive-icon {
          font-size: 20px;
        }
      }

      &--clear {
        visibility: hidden;
        cursor: pointer;

        &:hover {
          color: @primary-color;
        }
      }
    }
  }

  &__popup {
    display: flex;

    &-shortcut {
      width: 101px;
      padding: 6px 0 6px 16px ;
      border-right: @border-main-2;

      &-btn {
        display: block;
        color: #000;
        padding: 0;
        
        + .hive-button {
          margin-left: 0;
        }
        &:hover {
          color: #4088ff;
        }
      }
    }
  }
}

.hive-picker-datetime-range {
  min-width: 408px;
}

// basic
.hive-time-options {
  height: @item-count * @time-options-item-height;
  padding-bottom: (@item-count - 1) * @time-options-item-height + 1;
  overflow-y: hidden;
  overflow-x: hidden;
  font-size: @text-level-1-size;

  &:hover {
    overflow-y: auto;
  }

  &--scrolling {
    overflow-y: hidden;
  }

  &__item {
    display: block;
    height: @time-options-item-height;
    line-height: @time-options-item-height;
    text-align: center;
    cursor: pointer;

    &:hover {
      background: @primary-color-ligher-7;
    }

    &--selected {
      font-weight: bold;
      background: @item-selected-bg-color;
      border-top: @border-main-2;
      border-bottom: @border-main-2;

      &:hover {
        background: @item-selected-bg-color;
      }
    }

    &--disabled,
    &--disabled:hover {
      background: transparent;
      color: @disabled-color;
      cursor: not-allowed;
    }
  }
}

.hive-date-item {
  color: #000;
  font-size: 0;
  
  &__wrapper {
    display: inline-block;
    height: 24px;
    width: 24px;

    box-sizing: content-box;
    border-left: 6px solid #fff;
    border-right: 6px solid #fff;

    text-align: center;
    cursor: pointer;

    &:hover {
      background-color: @primary-color-ligher-7;
    }
  }

  &__text {
    font-size: 14px;
  }

  &--now {
    .hive-date-item__wrapper {
      box-shadow: inset 0px 0px 0px 1px @primary-color;
      color: @primary-color;
    }
  }

  &--highlight {
    .hive-date-item__wrapper {
      background-color: @primary-color-ligher-7;
      border-color: @primary-color-ligher-7;
    }
  }

  &--active {
    .hive-date-item__wrapper {
      color: #fff;
      background-color: @primary-color;
    }

    &-start {
      .hive-date-item__wrapper {
        border-left-color: #fff;
      }
    }

    &-end {
      .hive-date-item__wrapper {
        border-right-color: #fff;
      }
    }
  }

  &--last-day-of-month {
    .hive-date-item__wrapper {
      border-right-color: #fff; 
    }
  }

  &--first-day-of-month {
    .hive-date-item__wrapper {
      border-left-color: #fff; 
    }
  }

  &--disabled {
    .hive-date-item__wrapper {
      cursor: not-allowed;
    }
  }

  &--additional {
    .hive-date-item__wrapper {
      color: #BFBFBF;
      background: #fff;
      border-color: #fff;
    }
  }
}

.hive-date-header {

  display: flex;

  &__text {
    flex: 1;
    justify-content: center;
    display: flex;
    align-items: center;
    
    .hive-date-header__btn {
      color: #000;

      &:hover {
        color: #4088ff;
      }
    }
  }

  &__btn {
    padding: 0;
    color: #999;

    &--prev-month,
    &--next-year {
      margin-left: 4px!important;
    }

    &--next-year {
      transform-origin: center 17px;
      transform: rotate(180deg);
    }

    &--disabled {
      display: none;
    }
  }
}

.hive-date-day {
  tbody {
    tr {
      .hive-date-day__item .hive-date-item__wrapper{
        margin-top: 8px;
      }
      &:first-child{
        .hive-date-day__item .hive-date-item__wrapper{
          margin-top: 6px;
        }
      }
    }
  }
}

.hive-date-year {
  tbody {
    tr {
      .hive-date-year__item .hive-date-item__wrapper {
        margin-top: 28px;
        width: 38px;
        border-left-width: 22px;
        border-right-width: 22px;
      }  
      &:first-child{
        .hive-date-year__item .hive-date-item__wrapper {
          margin-top: 24px;
        } 
      }

      &:last-child {
        .hive-date-year__item{
          text-align: left;
        } 
      }
    }
  }
}

.hive-date-month {
  tbody {
    tr {
      .hive-date-month__item .hive-date-item__wrapper {
        margin-top: 38px;
        width: 40px;
        border-left-width: 15px;
        border-right-width: 15px;
      }  
      &:first-child{
        .hive-date-month__item .hive-date-item__wrapper {
          margin-top: 45px;
        } 
      }
    }
  }
}

// panel
.hive-time {
  display: flex;

  &__item {
    min-width: 56px;
    border-right: @border-main-2;

    &:last-child {
      border-right: none;
    }
  }
}

.hive-time-range {
  display: flex;
  .hive-time:first-child {
    border-right: @border-main-2;
  }
}

.hive-date {

  width: 304px;
  padding: 11px 16px 22px;

  table {
    border-collapse: collapse;
    border: none;
    margin: auto;
    user-select: none;
  }

  tbody {
    margin-top: 2px;
  }

  th {
    border-bottom: 1px solid @border-color;
    padding: 7px 0;
    margin-bottom: 5px;
    font-weight: 500;
  }

  td {
    padding: 0;
    text-align: center;
    border: none;

    &:first-child {
      .hive-date-item__wrapper {
        border-left: none;
      }
    }

    &:last-child {
      .hive-date-item__wrapper {
        border-right: none;
      }
    }
  }

  &__sub-panel {
    &--hide {
      display: none;
    }
  }
}

.hive-date-range {
  width: 608px;
  overflow: hidden;
  display: flex;

  .hive-date:first-child {
    border-right: @border-main-2;;
  }
}

.hive-date-time {
  width: 304px;

  .hive-time,
  .hive-time__item {
    flex: 1;
  }

  .hive-time__item:hover {
    flex: none;
  }

  &__time {
    &-header {
      display: flex;
      height: 51px;
      line-height: 50px;
      border-bottom: @border-main-2;
      &-date {
        flex: 1;
        text-align: center;
        &:first-child {
          border-right: @border-main-2;
        }
      }
    }
  }
  &__footer {
    border-top: @border-main-2;
    .clearfix();
    &-btn {
      float: right;
    }
  }
}

.hive-date-time-range {
  width: 608px;
}
