@import 'theme/default';
@import 'theme/font';
@import 'mixins/index';

.zent-select {
  cursor: pointer;
  display: inline-block;
  font-size: 0;
  line-height: 1.5;
  margin-right: 10px;
  outline: none;
  position: relative;
  text-align: left;
  user-select: none;
  width: 240px;
  vertical-align: middle;

  &--disabled {
    @include theme-color(color, stroke, 5);
    cursor: not-allowed;

    .zent-select-input,
    .zent-select-text,
    .zent-select-tags {
      @include theme-color(border-color, stroke, 5);
      @include theme-color(background-color, stroke, 8);

      &::after {
        opacity: 0.25;
      }
    }
  }

  .zent-select-text,
  .zent-select-popup,
  .zent-select-input,
  .zent-select-tags {
    font-size: $font-size-normal;
    line-height: 18px;
  }

  &__popover {
    width: 240px;
    line-height: 1.5;
    cursor: pointer;
    text-align: left;
    user-select: none;

    &.zent-select-auto-width {
      width: auto;
    }
  }
}

.zent-select-input,
.zent-select-text,
.zent-select-tags {
  @include theme-color(border-color, stroke, 5);
  @include theme-color(background-color, stroke, 9);
  box-sizing: border-box;
  border-width: 1px;
  border-style: solid;
  border-radius: 2px;
  display: inline-block;
  min-height: 30px;
  max-height: 76px;
  outline: none;
  padding: 5px 10px;
  transition: border-color 0.25s;
  width: 100%;
  position: relative;

  &::after {
    // This component will be removed soon, update base64 image for now
    background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4IiB2aWV3Qm94PSIwIDAgMTYgMTYiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+CiAgICA8dGl0bGU+ZG93bjwvdGl0bGU+CiAgICA8ZyBpZD0iZG93biIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBvbHlnb24gaWQ9Iui3r+W+hCIgZmlsbD0iIzk5OTk5OSIgZmlsbC1ydWxlPSJub256ZXJvIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4LjAwMzMwMSwgNi4xOTk3NDcpIHJvdGF0ZSg0NS4wMDAwMDApIHRyYW5zbGF0ZSgtOC4wMDMzMDEsIC02LjE5OTc0NykgIiBwb2ludHM9IjExLjc1MzMwMDkgMi40NDk3NDc0NyAxMS43NTMzMDA5IDkuOTQ5NzQ3NDcgNC4yNTMzMDA4NiA5Ljk0OTc0NzQ3IDQuMjUzMzAwODYgOC45NDk3NDc0NyAxMC43NTI1NTM0IDguOTQ5IDEwLjc1MzMwMDkgMi40NDk3NDc0NyI+PC9wb2x5Z29uPgogICAgPC9nPgo8L3N2Zz4=');
    background-repeat: no-repeat;
    background-position: center;
    top: 50%;
    right: 8px;
    width: 16px;
    content: '';
    height: 16px;
    position: absolute;
    transform: translateY(-50%);
    transition: transform 0.25s;
  }

  &.zent-select--visible {
    @include theme-color(border-color, primary, 4);
    box-shadow: $shadow-spec-focus;

    &::after {
      transform: rotate(180deg) translateY(50%);
    }
  }
}

.zent-select-placeholder {
  @include theme-color(color, stroke, 4);
}

.zent-select-simple {
  @include theme-color(color, primary, 4);

  &::after {
    @include theme-color(border-top-color, primary, 4);
    content: '';
    border-left: 4px solid transparent;
    border-top-width: 6px;
    border-top-style: solid;
    border-right: 4px solid transparent;
    display: inline-block;
    margin-left: 5px;
    height: 1px;
    transition: transform 0.25s;
  }
}

.zent-select-text {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding: 6px 25px 6px 12px;
}

.zent-select-tags {
  padding: 4px 25px 4px 12px;
  max-height: none;

  // sass-lint:disable no-vendor-prefixes
  &::-webkit-scrollbar {
    display: none;
  }

  // sass-lint:enable no-vendor-prefixes

  &__empty {
    padding: 6px 25px 6px 12px;
    line-height: 18px;
  }

  .zent-select-inner {
    border: 0;
    display: inline-block;
    outline: none;
  }

  .zent-select-tag {
    @include theme-color(border-color, stroke, 4);
    border-width: 1px;
    border-style: solid;
    border-radius: 2px;
    display: inline-block;
    margin: 2px 4px 2px 0;
    padding: 0 18px 0 4px;
    line-height: 16px;
    font-size: $font-size-small;
    position: relative;
  }

  .zent-select-delete {
    @include theme-color(color, stroke, 3);
    display: block;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
  }
}

.zent-select-popup {
  @include popup;

  .zent-select-option,
  .zent-select-filter,
  .zent-select-empty {
    @include popup-menu-item-common;
  }

  .zent-select-search {
    position: relative;
    box-sizing: border-box;
    border-width: 0 0 1px;
    padding-left: 20px;

    &.zent-input--has-focus {
      @include theme-color(border-color, stroke, 6);
      box-shadow: none;
    }

    &::before {
      background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAMAAADXqc3KAAAAM1BMVEUAAABmZmZmZmZnZ2dnZ2dmZmZnZ2dmZmZsbGxnZ2dmZmZoaGhnZ2dmZmZnZ2dmZmZmZmYOy3DdAAAAEHRSTlMAVttEnOWJNwzzpVHsz8ZQ9cP58AAAAItJREFUKM+FkdsSgCAIRFXEa7f//9okSsqRaZ8WjrOoGJYtLmdXrPmquuOWq+9+OF4KQ39C6lX6mFL0l33SKB+BPSDNYW/pEPWZUMV3K5QjAymt9KQoIPas3FwSkFqZNbBoUZs23GvXBeWBq/YlQT5xkP0nsqg1dCKrXTYPzQkZxGTXCJoZ0YDZEeEEs9MNoPE7LN4AAAAASUVORK5CYII=);
      background-repeat: no-repeat;
      background-position: center;
      background-size: 12px;
      content: '';
      height: 100%;
      left: 10px;
      position: absolute;
      width: 12px;
    }
  }

  .zent-select-filter {
    @include theme-color(border-color, stroke, 6);
    border-style: solid;
    border-width: 0 0 1px;
    padding-left: 30px;
    width: 100%;
    box-sizing: border-box;
    height: 30px;
  }

  .zent-select-option {
    @include popup-menu-item-specific;

    &.current {
      @include theme-color(background-color, stroke, 8);
    }

    &.active {
      @include theme-color(background-color, primary, 8);
    }

    &.active.current {
      @include theme-color(background-color, primary, 8);
    }
  }

  .zent-select-empty {
    @include theme-color(color, stroke, 3);
  }
}

.has-error {
  :not(.no-error) {
    & > .zent-select-input,
    & > .zent-select-text,
    & > .zent-select-tags {
      @include theme-color(border-color, error, 2);
      border-width: 1px;
      border-style: solid;
    }
  }
}
