@import '../../style/themes/index';
@import '../../style/mixins/index';

//== Style for input-group: input with label, with button or dropdown...
.@{mk-prefix}-input-group {
  &-wrapper {
    &-rtl {
      direction: rtl;
    }
  }
  &-rtl {
    direction: rtl;
  }
}

// affix
@input-affix-margin: 4px;

.@{mk-prefix}-input {
  &-affix-wrapper&-affix-wrapper-rtl {
    > input.@{mk-prefix}-input {
      border: none;
      outline: none;
    }
  }

  &-affix-wrapper-rtl {
    .@{mk-prefix}-input-prefix {
      margin: 0 0 0 @input-affix-margin;
    }

    .@{mk-prefix}-input-suffix {
      margin: 0 @input-affix-margin 0 0;
    }
  }
}

// allow-clear
.@{mk-prefix}-input-clear-icon {
  &:last-child {
    .@{mk-prefix}-input-affix-wrapper-rtl & {
      margin-right: @input-affix-margin;
      margin-left: 0;
    }
  }
}

.@{mk-prefix}-input-textarea-clear-icon {
  .@{mk-prefix}-input-affix-wrapper-rtl & {
    right: auto;
    left: 0;
    margin: 8px 0 0 8px;
  }
}

// mixin
@input-rtl-cls: ~'@{mk-prefix}-input-rtl';

.active() {
  .@{input-rtl-cls} & {
    border-right-width: 0;
    border-left-width: @border-width-base !important;
  }
}

.hover() {
  .@{input-rtl-cls} & {
    border-right-width: 0;
    border-left-width: @border-width-base !important;
  }
}

.input() {
  &-rtl {
    direction: rtl;
  }
}

// label input
.input-group(@inputClass) {
  > .@{inputClass}-rtl:first-child,
  &-rtl &-addon:first-child {
    border-radius: 0 @border-radius-base @border-radius-base 0;
  }

  &-addon:first-child {
    .@{inputClass}-group-rtl & {
      border-right: @border-width-base @border-style-base @input-border-color;
      border-left: 0;
    }
  }

  &-addon:last-child {
    .@{inputClass}-group-rtl & {
      border-right: 0;
      border-left: @border-width-base @border-style-base @input-border-color;
    }
  }

  > .@{inputClass}:last-child,
  &-addon:last-child {
    .@{inputClass}-group-rtl & {
      border-radius: @border-radius-base 0 0 @border-radius-base;
    }
  }

  .@{inputClass}-affix-wrapper {
    &:not(:first-child) {
      .@{inputClass}-group-rtl& {
        border-radius: @border-radius-base 0 0 @border-radius-base;
      }
    }

    &:not(:last-child) {
      .@{inputClass}-group-rtl& {
        border-radius: 0 @border-radius-base @border-radius-base 0;
      }
    }
  }

  &&-compact {
    & > *:not(:last-child) {
      .@{inputClass}-group-rtl& {
        margin-right: 0;
        margin-left: -@border-width-base;
        border-left-width: @border-width-base;
      }
    }

    & > *:first-child,
    & > .@{mk-prefix}-select:first-child > .@{mk-prefix}-select-selector,
    & > .@{mk-prefix}-calendar-picker:first-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-select-auto-complete:first-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-cascader-picker:first-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-mention-wrapper:first-child .@{mk-prefix}-mention-editor,
    & > .@{mk-prefix}-time-picker:first-child .@{mk-prefix}-time-picker-input {
      .@{inputClass}-group-rtl& {
        border-radius: 0 @border-radius-base @border-radius-base 0;
      }
    }

    & > *:last-child,
    & > .@{mk-prefix}-select:last-child > .@{mk-prefix}-select-selector,
    & > .@{mk-prefix}-calendar-picker:last-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-select-auto-complete:last-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-cascader-picker:last-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-cascader-picker-focused:last-child .@{mk-prefix}-input,
    & > .@{mk-prefix}-mention-wrapper:last-child .@{mk-prefix}-mention-editor,
    & > .@{mk-prefix}-time-picker:last-child .@{mk-prefix}-time-picker-input {
      .@{inputClass}-group-rtl& {
        border-left-width: @border-width-base;
        border-radius: @border-radius-base 0 0 @border-radius-base;
      }
    }
  }
}

// search-input
@search-prefix: ~'@{mk-prefix}-input-search';
@search-rtl-cls: ~'@{search-prefix}-rtl';

.@{search-prefix} {
  &-rtl {
    direction: rtl;
  }

  &-icon {
    .@{search-rtl-cls} & {
      margin-right: 0.5em;
      margin-left: 0;
    }

    &::before {
      .@{search-rtl-cls} & {
        border-left: none;
      }
    }

    &::after {
      .@{search-rtl-cls} & {
        right: auto;
        left: 0;
        border-right: @border-width-base @border-style-base @input-border-color;
        transition: all 0.3s;
      }
    }
  }

  &:not(&-enter-button) {
    .@{search-rtl-cls}& {
      padding-right: @input-padding-horizontal-base;
      padding-left: 0;
    }
  }

  &-enter-button {
    input {
      .@{search-rtl-cls}& {
        border-right: @border-width-base @border-style-base @input-border-color;
        border-left: 0;
      }

      &:hover,
      &:focus {
        .@{search-rtl-cls}& {
          border-color: @input-hover-border-color;
        }
      }
    }

    &.@{mk-prefix}-input-affix-wrapper {
      .@{search-rtl-cls}& {
        border-right: @border-width-base @border-style-base @input-border-color;
        border-left: 0;
      }

      &:hover,
      &:focus {
        .@{search-rtl-cls}& {
          border-color: @input-hover-border-color;
        }
      }
    }

    & + .@{mk-prefix}-input-group-addon,
    input + .@{mk-prefix}-input-group-addon {
      .@{search-rtl-cls}& {
        .@{search-prefix}-button {
          width: 100%;
          border-radius: @border-radius-base 0 0 @border-radius-base;
        }
      }
    }
  }
}
