@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(
      var(--sg-color-white),
      1px solid var(--sg-datepicker-border-color),
      var(--sg-box-shadow-light)
    );
  }
}

@include b(date-editor) {
  @include set-component-css-var('date-editor', $date-editor);

  position: relative;
  display: inline-block;
  text-align: left;

  &.#{$namespace}-input,
  &.#{$namespace}-input__inner {
    width: var(--sg-date-editor-width);
  }

  @include m((monthrange)) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--sg-date-editor-monthrange-width);
    }
  }

  @include m((daterange, timerange, datenoonrange)) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--sg-date-editor-daterange-width);
    }
  }

  @include m(datetimerange) {
    &.#{$namespace}-input,
    &.#{$namespace}-input__inner {
      width: var(--sg-date-editor-datetimerange-width);
    }
  }

  @include m(dates) {
    .#{$namespace}-input__inner {
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .close-icon {
    cursor: pointer;
  }

  .clear-icon {
    cursor: pointer;
    margin-right: 20px;
    color: var(--sg-text-color-secondary);
  }
  .sg-range__close-icon {
    cursor: pointer;
    margin-right: 20px;
    color: var(--sg-text-color-secondary);
  }
  .sg-input__inner {
    padding-left: 12px;
  }
  .sg-input__prefix {
    left: auto;
    right: 10px;
  }
  .prefix-icon {
    color: var(--sg-text-color-secondary);
  }
  .sg-popper.is-light {
    border: none;
  }
  .#{$namespace}-range__icon {
    height: inherit;
    font-size: 14px;
    color:  var(--sg-text-color-secondary);
    position: absolute;
    right: 10px;
    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(--sg-font-size-base);
    color: var(--sg-text-color-regular);

    &::placeholder {
      color: var(--sg-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: var(--sg-text-color-primary);
  }

  .#{$namespace}-range__close-icon {
    font-size: 14px;
    color: var(--sg-text-color-secondary);
    height: inherit;
    width: unset;
    cursor: pointer;

    &:hover {
      color: var(--sg-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(--sg-color-primary);

    &:hover {
      border-color: var(--sg-color-primary);
    }
  }

  @each $size in (large, 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');
    }
  }
}
