@import './theme/default.pcss';
$c-border: $theme-stroke-5;
$c-light-border: $theme-stroke-7;
$c-white: $theme-stroke-10;
$c-blue: $theme-primary-2;
$c-light-gray: $theme-stroke-4;
$c-bg-gray: $theme-stroke-9;
$c-light-blue: $theme-primary-4;
$c-half-black: $theme-mask-2;
$errorBorderColor: $theme-error-2;

.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: 160px;
  vertical-align: middle;

  &.disabled {
    color: $theme-stroke-6;
    cursor: not-allowed;

    .zent-select-input,
    .zent-select-text,
    .zent-select-tags {
      border-color: $theme-stroke-7;
      background-color: $c-bg-gray;

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

  .zent-select-text,
  .zent-select-popup,
  .zent-select-input,
  .zent-select-tags {
    font-size: 12px;
  }
}

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

.zent-select-simple {
  color: $c-blue;

  &::after {
    content: '';
    border-left: 4px solid transparent;
    border-top: 6px solid $c-blue;
    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: 5px 20px 5px 10px;

  &::after {
    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAMAAAC38k/IAAAAM1BMVEUAAAAzMzMzMzMzMzMzMzMzMzM0NDQ0NDQ1NTU1NTU9PT1VVVU0NDQzMzMzMzM1NTUzMzOoQ7gOAAAAEHRSTlMA99vkxpd9STUhCgPOzGhlqqcGJgAAAEBJREFUCNdFy8kRwCAMwEDZ3JDD/VebCXhgf3qIR83pi9gmXCduyokCyVwCuvrfAarMuzLlPzLLiGZx4FoIDeADc4gEoYNfTDsAAAAASUVORK5CYII=) no-repeat;
    background-size: 6px 5px;
    content: '';
    height: 5px;
    margin-top: -3px;
    position: absolute;
    right: 10px;
    top: 50%;
    transition: transform 0.25s;
    width: 6px;
  }
}

.zent-select-tags {
  padding: 2px 5px;
  overflow-y: auto;
  margin-bottom: -5px;
  line-height: 24px;

  &::-webkit-scrollbar {
    display: none;
  }

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

  .zent-select-tag {
    background-color: $c-bg-gray;
    border: 1px solid $c-border;
    border-radius: 2px;
    display: inline-block;
    margin: 2px 0;
    margin-right: 2px;
    padding: 0 4px;
    line-height: 18px;
  }

  .zent-select-delete {
    background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAgMAAABinRfyAAAADFBMVEUAAACampqbm5uZmZn/DnGVAAAAA3RSTlMAnUqokJgHAAAAPklEQVQI12PQYACivQwMdQz7HRj/MchfYP/CwP5F/gID4996BwaG+r8MDAzyXyAEmAuWACsBKwZrAxsANgoAoL4XU6vB5h4AAAAASUVORK5CYII=) no-repeat;
    background-size: 8px;
    display: inline-block;
    height: 8px;
    margin-left: 2px;
    width: 8px;
  }
}

.zent-select-popup {
  box-shadow: 0 1px 4px $c-half-black;
  left: 0;
  outline: none;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  z-index: 2000;
  margin-top: 2px;
  background-color: $c-white;
  max-height: 224px;

  .zent-select-option,
  .zent-select-filter,
  .zent-select-empty {
    background-color: $c-white;
    display: block;
    outline: none;
    padding: 5px 10px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  .zent-select-search {
    position: relative;
    box-sizing: border-box;

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

  .zent-select-filter {
    border-color: $c-light-border;
    border-style: solid;
    border-width: 0 0 1px;
    padding-left: 30px;
    width: 100%;
    box-sizing: border-box;
    height: 30px;
  }

  .zent-select-option {
    &.current,
    &:hover {
      background-color: $c-blue;
      border-color: $c-blue;
      color: $c-white;
    }

    &.active {
      color: $c-blue;
    }

    &.active:hover,
    &.active.current {
      color: $c-white;
    }
  }

  .zent-select-empty {
    color: $c-light-gray;
  }
}

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