@mixin align-chip($border-radius, $font-size, $margin) {
  border-radius: $border-radius;
  font-size: $font-size;
  margin: $margin;
  align-items: center;
  justify-content: center;
  @if ($skin-name == 'bootstrap5.3') {
    line-height: 12px;
  }
  
  @else {
    line-height: 1;
  }
}

@mixin icon-position {
  background-size: cover;
  display: flex;
  overflow: hidden;
}

@mixin icon-style($height, $width) {
  height: $height;
  width: $width;
}

@mixin bigger-style($height, $width, $margin) {
  height: $height;
  width: $width;
  margin: $margin;
}

.e-clone-chip {
  z-index: 2000;
}

@include export-module('chip-layout') {
  .e-chip-list {
    display: flex;
    padding: $chip-list-padding;

    &.e-chip,
    .e-chip {
      -webkit-tap-highlight-color: transparent;
      border: $chip-border-size solid;
      @include align-chip($chip-border-radius, $chip-font-size, $chip-margin);
      box-shadow: $chip-box-shadow;
      box-sizing: border-box;
      cursor: pointer;
      display: inline-flex;
      font-weight: $chip-font-weight;
      height: $chip-height;
      line-height: $chip-line-height;
      outline: none;
      overflow: $chip-overflow;
      padding: $chip-padding;
      position: relative;
      transition: box-shadow 300ms cubic-bezier(.4, 0, .2, 1);
      user-select: none;

      .e-chip-avatar {
        @include icon-position;
        @include icon-style($chip-avatar-size, $chip-avatar-size);
        @include align-chip($chip-avatar-border-radius, $chip-avatar-content-font-size, $chip-avatar-margin);
      }

      .e-chip-avatar-wrap,
      &.e-chip-avatar-wrap {
        border-radius: $chip-avatar-wrapper-border-radius;
      }

      .e-chip-icon {
        @include icon-position;
        @include icon-style($chip-leading-icon-size, $chip-leading-icon-size);
        @include align-chip($chip-leading-icon-border-radius, $chip-leading-icon-font-size, $chip-leading-icon-margin);
        @if ($skin-name == 'tailwind3') {
          font-weight: normal;
        }
      }

      .e-chip-drag {
        &.e-drag-and-drop,
        &.e-error-treeview {
          margin: $chip-leading-icon-margin;
        }
      }

      .e-chip-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        @if ($skin-name == 'bootstrap5' or $skin-name == 'bootstrap5dark') {
          height: $chip-text-height;
        }
      }

      .e-chip-delete {
        @include icon-position;
        @include icon-style($chip-delete-icon-size, $chip-delete-icon-size);
        @include align-chip($chip-delete-icon-border-radius, $chip-delete-icon-font-size, $chip-delete-icon-margin);
        @if $skin-name == 'Material3' {
          line-height: $chip-delete-icon-size;
          width: $chip-delete-icon-font-size;
        }
        &.e-dlt-btn::before {
          font-family: 'e-icons';
        }
      }

      .image-url {
        @include icon-position;
        @include icon-style($chip-leading-icon-size, $chip-leading-icon-size);
        @include align-chip($chip-leading-icon-border-radius, $chip-leading-icon-font-size, $chip-leading-icon-margin);
      }

      .trailing-icon-url {
        @include icon-position;
        @include icon-style($chip-delete-icon-size, $chip-delete-icon-size);
        @include align-chip($chip-delete-icon-border-radius, $chip-delete-icon-font-size, $chip-delete-icon-margin);
        font-family: 'e-icons';
      }

      .e-chip-template {
        display: inline-flex;
      }
    }

    .e-chip.e-outline {
      .e-chip-avatar {
        @if ($skin-name == 'FluentUI') {
          @include icon-style($chip-outline-avatar-size, $chip-outline-avatar-size);
          border-radius: $chip-avatar-wrapper-border-radius;
        }
      }
    }

    &:not(.e-chip) {
      flex-wrap: wrap;
    }

    &.e-multi-selection .e-chip {
      &::before {
        align-items: center;
        justify-content: center;
        line-height: 1;
        display: flex;
        font-family: 'e-icons';
        @include icon-style($chip-leading-icon-size, $chip-leading-icon-size);
        margin: $chip-multi-selection-icon-margin;
        margin-top: $chip-multi-selection-icon-margin-top;
        overflow: hidden;
        transition: width 300ms cubic-bezier(.4, 0, .2, 1);
      }

      &:not(.e-chip-icon-wrap):not(.e-chip-avatar-wrap) {
        &::before {
          width: 0;
        }
      }

      &.e-chip-icon-wrap,
      &.e-chip-avatar-wrap {
        &::before {
          display: none;
        }
      }

      &.e-chip-avatar-wrap {
        &::before {
          @include icon-style($chip-avatar-size, $chip-avatar-size);
          margin: $chip-avatar-margin;
          margin-top: $chip-multi-selection-icon-margin-top;
        }
      }

      &.e-active {
        & .e-chip-icon,
        & .e-chip-avatar {
          display: none;
        }

        &.e-chip-icon-wrap,
        &.e-chip-avatar-wrap {
          &::before {
            display: flex;
          }
        }

        &:not(.e-chip-icon-wrap):not(.e-chip-avatar-wrap) {
          &::before {
            width: $chip-leading-icon-size;
          }
        }
      }
    }

    &.e-rtl {
      &.e-chip,
      & .e-chip {
        .e-chip-avatar {
          margin: $chip-rtl-avatar-margin;
        }

        .e-chip-icon {
          margin: $chip-rtl-leading-icon-margin;
        }

        .e-chip-drag {
          &.e-drag-and-drop,
          &.e-error-treeview {
            margin: $chip-rtl-leading-icon-margin;
          }
        }

        .e-chip-delete {
          margin: $chip-rtl-delete-icon-margin;
        }

        .e-chip-avatar-wrap,
        &.e-chip-avatar-wrap {
          border-radius: $chip-rtl-avatar-wrapper-border-radius;
        }

        .trailing-icon-url {
          margin: $chip-rtl-delete-icon-margin;
        }
      }

      &.e-multi-selection .e-chip {
        &::before {
          margin: $chip-rtl-leading-icon-margin;
          margin-top: $chip-multi-selection-icon-margin-top;
        }

        &.e-chip-avatar-wrap {
          &::before {
            margin: $chip-rtl-avatar-margin;
            margin-top: $chip-multi-selection-icon-margin-top;
          }
        }
      }
    }
  }
}
