@import './config.scss';

.w-picker {
  border: 1px solid $normal-border;
  border-radius: $border-radius-base;
  box-shadow: 0 2px 8px $shadow;
  position: absolute;
  width: 280px;
  background: $white;

  &-header {
    height: 40px;
    line-height: 40px;
    font-size: 14px;
    font-family: $family;
    color: $text-color;
    border-bottom: 1px solid $normal-border;
    position: relative;
    display: flex;
    justify-content: center;
    user-select: none;

    &-text {
      padding: 0 2px;
      cursor: pointer;
      transition: color 0.3s;
      font-family: $family;
      color: $text-color;
      font-size: 14px;

      &:hover {
        color: $blue-5;
      }
    }
  }

  &-btn {
    position: absolute;
    top: 0;
    padding: 0 4px;
    background: none;
    border: none;
    width: 24px;
    cursor: pointer;

    &::after,
    &::before {
      position: relative;
      top: -1px;
      display: inline-block;
      width: 8px;
      height: 8px;
      vertical-align: middle;
      border: 0 solid $text-color;
      border-width: 1.5px 0 0 1.5px;
      border-radius: 1px;
      transform: rotate(-45deg) scale(0.8);
      box-sizing: border-box;
      content: '';
      transition: border-color 0.3s;
    }

    &:focus {
      outline: none;
    }

    &:hover {
      &::after,
      &::before {
        border-color: $blue-5;
      }
    }
  }

  &-date {
    width: 24px;
    height: 24px;
    margin: 0 auto;
    line-height: 22px;
    border: 1px solid transparent;
    background: none;
    border-radius: $border-radius-base;
    text-align: center;
    padding: 0;
    cursor: pointer;
    transition: background 0.3s, color 0.3s;

    &:hover {
      background: $blue-5;
      color: $white;
    }
  }

  &-year {
    @extend .w-picker-month;

    &-next {
      @extend .w-picker-btn;

      right: 9px;
      height: 100%;

      &::after,
      &::before {
        transform: rotate(135deg) scale(0.8);
      }

      &::after {
        left: -3px;
      }

      &::before {
        left: 0;
      }
    }

    &-prev {
      @extend .w-picker-btn;

      left: 9px;
      height: 100%;

      &::before {
        left: 3px;
      }

      &::after {
        left: 0;
      }
    }
  }

  &-month {
    @extend .w-picker-date;

    width: auto;
    display: inline-block;
    padding: 0 8px;

    &-next {
      @extend .w-picker-btn;

      right: 29px;
      height: 100%;

      &::before {
        transform: rotate(135deg) scale(0.8);
        left: -1px;
      }

      &::after {
        content: none;
      }
    }

    &-prev {
      @extend .w-picker-btn;

      left: 29px;
      height: 100%;

      &::before {
        content: none;
      }

      &::after {
        left: 1px;
      }
    }
  }

  &-body {
    padding: 8px;
  }

  &-table {
    min-width: auto;
    width: 100%;
    margin: 0;
    font-size: 14px;
    font-family: $family;
    padding: 4px 0;
    table-layout: fixed;

    &-td {
      text-align: center;
      padding: 16px 0;
      border: none;
      font-family: $family;
      font-size: 14px;
      font-weight: normal;
      color: $disabled-color;

      &-date,
      &-week {
        padding: 4px 0;
      }

      &-current {
        color: $text-color;
      }
    }

    &-th {
      @extend .w-picker-table-td;

      background: none;

      &-date {
        @extend .w-picker-table-td-date;
      }
    }

    &-tr-week-active,
    &-tr-week:hover {
      & .w-picker-table-td-week:first-child {
        & .w-picker-week {
          border-top-left-radius: $border-radius-base;
          border-bottom-left-radius: $border-radius-base;
        }
      }

      & .w-picker-table-td-week:last-child {
        & .w-picker-week {
          border-top-right-radius: $border-radius-base;
          border-bottom-right-radius: $border-radius-base;
        }
      }

      & .w-picker-week {
        background: #edf3f8;
        padding: 0;
        width: auto;
        border-radius: 0;
      }
    }

    &-tr-week-active {
      & .w-picker-table-td-week:first-child,
      & .w-picker-table-td-week:last-child {
        position: relative;

        & .w-picker-week::before {
          border-radius: $border-radius-base;
          position: absolute;
          left: 50%;
          top: 50%;
          transform: translate(
            -50%,
            -50%
          );
          content: '';
          border: 1px solid $blue-7;
          width: 20px;
          height: 20px;
        }
      }
    }
  }

  &-week {
    @extend .w-picker-date;

    transition: none;

    &:hover {
      background: none;
      color: inherit;
    }
  }

  &-age {
    @extend .w-picker-month;
  }

  &-active {
    background: $blue-7;
    color: $white;
  }

  &-disabled {
    background: $disabled-bg;
    color: $disabled-color;
    cursor: not-allowed;

    &:hover {
      background: $disabled-bg;
      color: $disabled-color;
      cursor: not-allowed;
    }
  }

  &-today {
    border-color: $blue-7;
    border-radius: $border-radius-base;

    &.w-picker-disabled {
      border-color: $disabled-border;
      background: rgba(
        0,
        0,
        0,
        0.1
      );
    }
  }

  &-clear {
    cursor: pointer;
    opacity: 0;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 0;

    &-show {
      opacity: 1;
    }
  }

  &-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;

    // 上下 start
    &-horbottom {
      top: -5px;
      border-width: 0 5px 5px;
      border-bottom-color: $normal-bg;
    }

    &-hortop {
      bottom: -5px;
      border-width: 5px 5px 0;
      border-top-color: $normal-bg;
    }

    &-vercenter {
      left: 50%;
      margin-left: -5px;
    }

    &-verendright {
      right: 16px;
    }

    &-verendleft {
      left: 16px;
    }
    // 上下 end
  }

  &-calendar {
    position: static;
  }

  &-footer {
    border-top: 1px solid $normal-border;
    text-align: right;
    padding: 8px;
    font-size: 0;

    &-btn {
      margin-left: 8px;
    }
  }

  &-time {
    text-align: center;
    font-size: 14px;
    color: $text-color;
    line-height: 40px;
    height: 40px;
    box-sizing: border-box;
    font-family: $family;
    border-bottom: 1px solid $normal-border;
    cursor: pointer;

    &:hover {
      color: $blue-5;
    }
  }
}
