@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 set-css-var-type('datepicker', 'border-color', $datepicker);
    @include picker-popper(
      getCssVar('bg-color', 'overlay'),
      1px solid getCssVar('datepicker', 'border-color'),
      getCssVar('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__wrapper {
    @include inset-input-border(
      var(
        #{getCssVarName('input-border-color')},
        map.get($input, 'border-color')
      )
    );

    &:hover {
      @include inset-input-border(#{getCssVar('input', 'hover-border-color')});
    }
  }

  &.#{$namespace}-input,
  &.#{$namespace}-input__wrapper {
    width: getCssVar('date-editor-width');
    height: var(#{getCssVarName('input-height')}, getCssVar('component-size'));
  }
  // &.#{$namespace}-input__inner {
  //   padding-left: var(--el-date-editor-suffix-padding);
  // }

  @include m((monthrange)) {
    @include css-var-from-global(
      'date-editor-width',
      'date-editor-monthrange-width'
    );
  }

  @include m((daterange, timerange)) {
    @include css-var-from-global(
      'date-editor-width',
      'date-editor-daterange-width'
    );
  }

  @include m(datetimerange) {
    @include css-var-from-global(
      'date-editor-width',
      '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__wrapper {
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .qd-date-editor-step {
    align-self: center;
    // fix hover overly
    height: calc(100% - 2px);
  }
  .close-icon,
  .qd-date-editor-step {
    cursor: pointer;
  }

  .clear-icon {
    cursor: pointer;

    &:hover {
      color: getCssVar('text-color', 'secondary');
    }
  }
  .qd-date-editor-step-left {
    border-right: getCssVar('border-base');
  }
  .qd-date-editor-step-right {
    border-left: getCssVar('border-base');
  }
  .#{$namespace}-range__icon {
    height: inherit;
    font-size: 14px;
    color: getCssVar('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: getCssVar('font-size', 'base');
    color: getCssVar('text-color', 'regular');
    background-color: transparent;

    &::placeholder {
      color: getCssVar('text-color', 'placeholder');
    }
  }

  .#{$namespace}-range-separator {
    flex: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 0 5px;
    margin: 0;
    font-size: 14px;
    word-break: keep-all;
    color: getCssVar('text-color', 'primary');
  }

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

    &:hover {
      color: getCssVar('text-color', 'secondary');
    }

    svg {
      vertical-align: middle;
    }

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

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

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

  @include when(active) {
    @include inset-input-focus-border(
      #{getCssVar('input', 'focus-border-color')}
    );
    &:hover {
      @include inset-input-focus-border(
        #{getCssVar('input', 'focus-border-color')}
      );
    }
  }

  @each $size in (large, small) {
    @include m($size) {
      line-height: getCssVar('component-size', $size);

      &.#{$namespace}-input__wrapper {
        height: getCssVar('component-size', $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');
    }
  }
}
