@import "../../style/index";
@import "../../style/mixins/index";

@tag-prefix-cls: ~"@{ant-prefix}-tag";

@tag-input-cls: ~"@{ant-prefix}-tag-input";

.@{tag-prefix-cls} {
  .reset-component();

  display: inline-flex;
  align-items: center;
  height: auto;
  margin-right: 8px;
  padding: 0 @tag-padding-base;
  font-size: @tag-font-size;
  font-weight: 500;
  line-height: @tag-line-height;
  white-space: nowrap;
  background: @tag-default-bg;
  border-radius: @tag-border-radius;
  opacity: 1;
  transition: all 0.3s;

  &.@{tag-prefix-cls}-border {
    border: @border-width-base dashed @color-neutral-line;
    color: @primary-color;
    height: @tag-line-height;
    cursor: pointer;

    &:hover {
      background: @color-neutral-line;
    }
  }

  &,
  a,
  a:hover {
    color: @tag-default-color;
  }

  > a:first-child:last-child {
    display: inline-block;
    margin: 0 -8px;
    padding: 0 8px;
  }

  &-close-icon {
    &.anticon {
      display: inline-flex;
    }

    align-items: center;
    justify-content: center;
    margin: 0 (4px - @tag-padding-base) 0 4px;
    color: @text-color;
    font-size: @tag-close-font-size;
    cursor: pointer;
    transition: all 0.3s;
    width: @tag-close-size;
    height: @tag-close-size;
    border-radius: @tag-close-border-radius;

    &:hover {
      background-color: @tag-close-bg;
    }
  }

  &-has-color {
    border-color: transparent;
    &,
    a,
    a:hover,
    .@{iconfont-css-prefix}-close,
    .@{iconfont-css-prefix}-close:hover {
      color: @text-color-inverse;
    }
  }

  &-checkable {
    cursor: pointer;
    user-select: none;

    &:not(&-checked):hover {
      background-color: @tag-checkable-hover-bg;
    }

    &:active,
    &-checked {
      color: @primary-color;
      background-color: @primary-2 !important;
    }

    &-checked {
      background-color: @primary-2;
    }

    &:active {
      background-color: @primary-2;
    }
  }

  &-hidden {
    display: none;
  }

  // sm
  &.@{tag-prefix-cls}-sm {
    border-radius: @border-radius-base;
    padding: 0 @tag-padding-sm;

    .@{tag-prefix-cls}-close-icon {
      border-radius: 1px;
      margin: 0 (4px - @tag-padding-sm) 0 4px;
    }
  }

  // mixin to iterate over colors and create CSS class for each one
  .make-color-classes(@i: length(@preset-colors)) when (@i > 0) {
    .make-color-classes(@i - 1);
    @color: extract(@preset-colors, @i);
    @lightColor: "@{color}-1";
    @lightBorderColor: "@{color}-3";
    @darkColor: "@{color}-6";
    @textColor: "@{color}-7";
    &-@{color} {
      color: @@textColor;
      background: @@lightColor;
      border-color: @@lightBorderColor;
    }
    &-@{color}-inverse {
      color: @text-color-inverse;
      background: @@darkColor;
      border-color: @@darkColor;
    }
  }

  .make-status-color-classes(@status, @cssVariableType) {
    @bgColor: "@{cssVariableType}-color-deprecated-bg";
    @borderColor: "@{cssVariableType}-color-deprecated-border";
    @textColor: "@{cssVariableType}-color";
    &-@{status} {
      color: @@textColor;
      background: @@bgColor;
      border-color: @@borderColor;
    }
  }

  .make-color-classes();

  .make-status-color-classes(success, success);
  .make-status-color-classes(processing, info);
  .make-status-color-classes(error, error);
  .make-status-color-classes(warning, warning);

  // To ensure that a space will be placed between character and `Icon`.
  > .@{iconfont-css-prefix} + span,
  > span + .@{iconfont-css-prefix} {
    margin-left: 4px;
  }
}

.@{tag-input-cls} {
  transition: all @animation-duration-base;

  caret-color: @primary-color;
  border-color: @primary-color;
  border-radius: @height-sm / 2;
}

@import "./rtl";
