@use 'sass:map';

@use '../mixins/mixins' as *;
@use '../mixins/var' as *;
@use '../common/var' as *;
@use '../common/transition' as *;

@include b(picker) {
  @include e(popper) {
    @include picker-popper(
      var(--el-color-white),
      1px solid var(--el-datepicker-border-color),
      var(--el-box-shadow-regular)
    );
  }
}

@include b(date-editor) {
  @include set-component-css-var('date-editor', $date-editor);
  @include set-component-css-var('input', $input);
  position: relative;
  display: inline-block;
  text-align: left;

  &.#{$namespace}-input,
  &.#{$namespace}-input__inner {
    width: var(--el-date-editor-width);
  }
  // &.#{$namespace}-input__inner {
  //   padding-left: var(--el-date-editor-suffix-padding);
  // }

  @include m((monthrange)) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--el-date-editor-monthrange-width);
    }
  }

  @include m((daterange, timerange)) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--el-date-editor-daterange-width);
    }
  }

  @include m(datetimerange) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--el-date-editor-datetimerange-width);
    }
  }
  // @include m ((step)) {
  //   &.#{$namespace}-input__inner{
  //     // --el-input-suffix-padding: var(--el-date-editor-step-suffix-padding)
  //     padding-left: var(--el-date-editor-step-suffix-padding)
  //   }
  // }
  @include m(dates) {
    .#{$namespace}-input__inner {
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .el-date-editor-step {
    align-self: center;
    // fix hover overly
    height: calc(100% - 2px);
  }
  .close-icon,
  .el-date-editor-step {
    cursor: pointer;
  }

  .clear-icon {
    cursor: pointer;

    &:hover {
      color: var(--el-text-color-secondary);
    }
  }
  .el-date-editor-step-left {
    border-right: var(--el-border-base);
  }
  .el-date-editor-step-right {
    border-left: var(--el-border-base);
  }
  .#{$namespace}-range__icon {
    height: inherit;
    font-size: 14px;
    margin-left: -5px;
    color: var(--el-text-color-placeholder);
    float: left;

    svg {
      vertical-align: middle;
    }
  }

  .#{$namespace}-range-input {
    appearance: none;
    border: none;
    outline: none;
    display: inline-block;
    height: 100%;
    margin: 0;
    padding: 0;
    width: 39%;
    text-align: center;
    font-size: var(--el-font-size-base);
    color: var(--el-text-color-regular);

    &::placeholder {
      color: var(--el-text-color-placeholder);
    }
  }

  .#{$namespace}-range-separator {
    flex: 1;
    display: inline-block;
    height: 100%;
    padding: 0 5px;
    margin: 0;
    text-align: center;
    line-height: 24px;
    font-size: 14px;
    word-break: keep-all;
    color: var(--el-text-color-primary);
  }

  .#{$namespace}-range__close-icon {
    font-size: 14px;
    color: var(--el-text-color-placeholder);
    height: inherit;
    width: unset;
    cursor: pointer;

    &:hover {
      color: var(--el-text-color-secondary);
    }

    svg {
      vertical-align: middle;
    }

    &--hidden {
      opacity: 0;
      visibility: hidden;
    }
  }
}

@include b(range-editor) {
  &.#{$namespace}-input__inner {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
  }

  .#{$namespace}-range-input {
    line-height: 1;
  }

  @include when(active) {
    border-color: var(--el-color-primary);

    &:hover {
      border-color: var(--el-color-primary);
    }
  }

  @each $size in (medium, small) {
    @include m($size) {
      line-height: map.get($input-height, $size);

      &.#{$namespace}-input__inner {
        height: map.get($input-height, $size);
      }

      .#{$namespace}-range-separator {
        line-height: map.get($input-line-height, $size);
        font-size: map.get($input-font-size, $size);
      }

      .#{$namespace}-range-input {
        font-size: map.get($input-font-size, $size);
      }
    }
  }

  @include when(disabled) {
    background-color: map.get($input-disabled, 'fill');
    border-color: map.get($input-disabled, 'border');
    color: map.get($input-disabled, 'text-color');
    cursor: not-allowed;

    &:hover,
    &:focus {
      border-color: map.get($input-disabled, 'border');
    }

    input {
      background-color: map.get($input-disabled, 'fill');
      color: map.get($input-disabled, 'text-color');
      cursor: not-allowed;
      &::placeholder {
        color: map.get($input-disabled, 'placeholder-color');
      }
    }

    .#{$namespace}-range-separator {
      color: map.get($input-disabled, 'text-color');
    }
  }
}
