/**Variable**/
@import './helpers/mixin.scss';

$iconWidth: 1.6em;

.s-input--inner {
  border-radius: 0.25em;
  outline: 0;
  padding: 0 0.6em;
  color: $s-font-color;
  border: 1px solid $s-input-border-color;
  background-color: #FFF;
  &[disabled] {
    cursor: not-allowed;
    background-color: $s-input-disabled-background-color;
  }
}

.s-input--inner {
  width: 100%;
  height: 100%;
  &::placeholder {
    color: $s-input-placeholder-color;
  }
  &[type="number"]::-webkit-outer-spin-button,
  &[type="number"]::-webkit-inner-spin-button {
    appearance: none;
  }
  &[type="number"] {
    appearance: textfield;
  }
}

.s-input {
  display: inline-block;
  position: relative;
  width: 180px;
  &.is--disabled {
    .s-input--date-picker-suffix,
    .s-input--suffix,
    .s-input--password-suffix,
    .s-input--number-suffix {
      cursor: no-drop;
    }
  }
  &:not(.is--disabled) {
    .s-input--date-picker-suffix,
    .s-input--clear-icon,
    .s-input--password-suffix,
    .s-input--number-suffix {
      cursor: pointer;
    }
    &.is--active {
      .s-input--inner {
        border: 1px solid $s-primary-color;
      }
    }
  }
  .s-input--prefix,
  .s-input--suffix,
  .s-input--extra-suffix {
    display: flex;
    position: absolute;
    top: 0;
    width: $iconWidth;
    height: 100%;
    user-select: none;
    align-items: center;
    justify-content: center;
    color: $s-table-column-icon-border-color;
  }
}

// 前缀图标
.s-input {
  .s-input--prefix {
    left: 0.2em;
  }
  &.is--prefix {
    .s-input--inner {
      padding-left: #{$iconWidth + 0.2em};
    }
  }
}

// 后缀图标
.s-input {
  .s-input--clear-icon {
    display: none;
  }
  .s-input--suffix,
  .s-input--extra-suffix {
    right: 0.2em;
  }
  &.is--suffix,
  &.type--password,
  &.type--number,
  &.type--integer,
  &.type--date,
  &.type--week,
  &.type--month,
  &.type--year {
    .s-input--inner {
      padding-right: #{$iconWidth + 0.2em};
    }
  }
  &.type--password,
  &.type--number,
  &.type--integer,
  &.type--date,
  &.type--week,
  &.type--month,
  &.type--year   {
    .s-input--suffix {
      right: $iconWidth;
    }
  }
  &.is--suffix {
    &.type--password,
    &.type--number,
    &.type--integer,
    &.type--date,
    &.type--week,
    &.type--month,
    &.type--year {
      .s-input--inner {
        padding-right: #{$iconWidth * 2};
      }
    }
  }
  &.is--suffix {
    &:hover {
      .s-input--suffix {
        &.is--clear {
          .s-input--suffix-icon {
            display: none;
          }
          .s-input--clear-icon {
            display: inline;
          }
        }
      }
    }
  }
  &:not(.is--disabled) {
    &:not(.is--readonly) {
      .s-input--suffix {
        &:hover {
          .s-input--clear-icon {
            color: $s-primary-color;
          }
        }
      }
      .s-input--extra-suffix {
        &:hover {
          .s-input--password-suffix {
            color: $s-primary-color;
          }
        }
      }
      .s-input--number-prev,
      .s-input--number-next {
        &:hover {
          color: $s-primary-color;
        }
      }
    }
  }
}

.s-input--password-suffix,
.s-input--number-suffix,
.s-input--date-picker-suffix {
  position: relative;
  width: 100%;
  height: 100%;
}

.s-input--date-picker-icon,
.s-input--pwd-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.s-input--date-picker-suffix {
  display: flex;
  align-items: center;
  justify-content: center;
  .s-input--panel-icon {
    @include animatTransition(transform, .2s);
  }
}

.s-input--number-suffix {
  .s-input--number-prev,
  .s-input--number-next {
    position: absolute;
    left: 0;
    height: 50%;
    width: 100%;
    text-align: center;
  }
  .s-input--number-prev {
    top: 0;
  }
  .s-input--number-next {
    bottom: 0;
  }
  .s-input--number-prev-icon,
  .s-input--number-next-icon {
    position: absolute;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  .s-input--number-prev-icon {
    top: 65%;
  }
  .s-input--number-next-icon {
    top: 35%;
  }
}

.s-input--panel {
  display: none;
  position: absolute;
  left: 0;
  padding: 0.2em 0;
  color: $s-font-color;
  font-size: $s-font-size;
  text-align: left;
  &:not(.is--transfer) {
    min-width: 100%;
  }
  &.is--transfer {
    position: fixed;
  }
  &.animat--leave {
    display: block;
    opacity: 0;
    transform: scaleY(0.5);
    transition: transform 0.2s, opacity 0.2s;
    transform-origin: 0% 0%;
    &[data-placement="top"] {
      transform-origin: 0% 100%;
    }
  }
  &.animat--enter {
    opacity: 1;
    transform: scaleY(1);
  }
}

.s-input--panel-wrapper {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.2em 0;
  max-height: 22em;
  border-radius: 4px;
  background-color: #fff;
  border: 1px solid $s-table-popup-border-color;
  box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.s-input--panel {
  &.type--date,
  &.type--week,
  &.type--month,
  &.type--year {
    user-select: none;
    .s-input--panel-wrapper {
      padding: 0.8em;
      width: 22em;
    }
  }
  &.type--week {
    .s-input--panel-wrapper {
      width: 24em;
    }
  }
  &.type--date{
    .s-input--date-picker-body {
      th {
        width: 14.28571%;
      }
    }
  }
  &.type--week {
    .s-input--date-picker-body {
      table {
        th {
          width: 12%;
          &:first-child {
            width: 16%;
          }
        }
      }
    }
  }
  &.type--month,
  &.type--year {
    .s-input--date-picker-body {
      td {
        width: 25%;
      }
    }
  }
}

.s-input--date-picker-header {
  display: flex;
  flex-direction: row;
  padding-bottom: 0.8em;
  .s-input--date-picker-type-wrapper {
    flex-grow: 1;
  }
  .s-input--date-picker-btn-wrapper {
    flex-shrink: 0;
    text-align: center;
  }
}
.s-input--date-picker-type-wrapper {
  .s-input--date-picker-label,
  .s-input--date-picker-btn {
    padding: 0 0.6em;
    display: inline-block;
  }
}
.s-input--date-picker-btn-wrapper {
  display: flex;
  flex-direction: row;
  .s-input--date-picker-btn {
    width: 2em;
    margin-left: 0.5em;
  }
}
.s-input--date-picker-label,
.s-input--date-picker-btn {
  display: inline-block;
  height: 2em;
  line-height: 2em;
  display: flex;
  border-radius: 0.2em;
  border: 1px solid $s-input-border-color;
  align-items: center;
  justify-content: center;
  background-color: $s-button-default-background-color;
}
.s-input--date-picker-btn {
  cursor: pointer;
  &:active {
    background-color: darken($s-button-default-background-color, 3%);
  }
}
.s-input--date-picker-body {
  border-radius: 0.2em;
  border: 1px solid $s-table-popup-border-color;
  table {
    border: 0;
    width: 100%;
    height: 14em;
    border-spacing: 0;
    border-collapse: separate;
    text-align: center;
    th {
      height: 2.2em;
    }
    th,
    td {
      font-size: 0.9em;
      font-weight: normal;
    }
    th {
      box-shadow: inset 0 -1px 0 0 $s-table-popup-border-color;
    }
    td {
      &.is--prev,
      &.is--next {
        color: $s-disabled-color;
      }
      &.is--today {
        box-shadow: inset 0 0 0 1px $s-table-popup-border-color;
        &:not(.is--selected) {
          &.is--current {
            color: $s-primary-color;
          }
        }
      }
      &.is--hover {
        background-color: $s-input-date-picker-hover-background-color;
      }
      &.is--selected {
        color: #fff;
        background-color: $s-input-date-picker-selected-background-color;
      }
      &:not(.is--disabled) {
        cursor: pointer;
      }
      &.is--disabled {
        cursor: no-drop;
        color: $s-input-disabled-color;
        background-color: $s-input-disabled-background-color;
      }
    }
  }
  .s-input--date-week-view {
    th {
      &:first-child {
        box-shadow: inset -1px -1px 0 0 $s-table-popup-border-color;
      }
    }
    td {
      &:first-child {
        box-shadow: inset -1px 0 0 0 $s-table-popup-border-color;
      }
    }
  }
}

.s-input {
  font-size: $s-font-size;
  height: $s-input-height-default;
  .s-input--inner {
    &[type="date"]::-webkit-inner-spin-button {
      margin-top: 6px;
    }
    &[type="date"]::-webkit-inner-spin-button,
    &[type="number"]::-webkit-inner-spin-button {
      height: 24px;
    }
  }
  &.size--medium {
    font-size: $s-font-size-medium;
    height: $s-input-height-medium;
    .s-input--inner {
      &[type="date"]::-webkit-inner-spin-button {
        margin-top: 4px;
      }
    }
  }
  &.size--small {
    font-size: $s-font-size-small;
    height: $s-input-height-small;
    .s-input--inner {
      &[type="date"]::-webkit-inner-spin-button {
        margin-top: 2px;
      }
    }
  }
  &.size--mini {
    font-size: $s-font-size-mini;
    height: $s-input-height-mini;
    .s-input--inner {
      &[type="date"]::-webkit-inner-spin-button {
        margin-top: 0;
      }
    }
  }
}

.s-dropdown--panel {
  font-size: $s-font-size;
  &.size--medium {
    font-size: $s-font-size-medium;
  }
  &.size--small {
    font-size: $s-font-size-small;
  }
  &.size--mini {
    font-size: $s-font-size-mini;
  }
}
