@use "../../style/index" as mixins;

$prefix: "adui-select";

.#{$prefix} {
  position: relative;
  display: inline-block;
  min-width: 77px;
  height: 36px;
  transform: translate3d(0, 0, 0);

  &-allow-clear {
    &:not(.#{$prefix}-disabled) {
      &:hover {
        .#{$prefix} {
          &-clear {
            opacity: 1;
            visibility: visible;
          }
        }
      }
    }
  }

  &-value_is_empty_string {
    .#{$prefix}-selection-item {
      color: var(--gray-700);
    }

    .#{$prefix}-clear {
      display: none;
    }
  }

  &-selector {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    color: var(--gray-900);
    background-color: #fff;
    border-radius: 4px;
    box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.03), 0 0 0 1px var(--gray-400);
    outline: none;
    user-select: none;
    cursor: pointer;
    transition: color var(--adui-motion-duration-base)
        var(--adui-motion-ease-base),
      background-color var(--adui-motion-duration-base)
        var(--adui-motion-ease-base),
      background-image var(--adui-motion-duration-base)
        var(--adui-motion-ease-base),
      box-shadow var(--adui-motion-duration-base) var(--adui-motion-ease-base);

    &:hover {
      background-color: var(--gray-100);
      box-shadow: 0 3px 3px 0 rgba(0, 0, 0, 0.03), 0 0 0 1px var(--gray-500);
    }

    &:active {
      background-color: var(--gray-200);
      box-shadow: inset 0 1px 2px 0 rgba(0, 0, 0, 0.04),
        0 0 0 1px var(--gray-500);
    }

    &::before {
      content: "\00a0";
      opacity: 0;
      width: 0;
      line-height: 0;
    }
  }

  &-selection-placeholder {
    flex: 1;
    margin-left: 11px;
    margin-right: 25px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    color: var(--transparent-gray-700);
  }

  &-placeholder-text {
    position: fixed;
    top: 0;
    right: 25px;
    bottom: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &-selection-search {
    position: absolute;
    top: 0;
    right: 25px;
    bottom: 0;
    left: 11px;

    input {
      display: none;
      width: 100%;
      height: 100%;
      background-color: transparent;
      border: none;
      outline: none;
      cursor: pointer;
    }
  }

  &-item-option {
    flex: none;
    position: relative;
    padding-left: 12px;
    padding-right: 12px;
    font-size: var(--font-size-small);
    line-height: 32px;
    white-space: nowrap;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color var(--adui-motion-duration-base)
      var(--adui-motion-ease-base);

    &-content {
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    &:hover {
      background-color: var(--gray-200);
    }

    &:active {
      background-color: var(--gray-300);
    }

    &-active {
      background-color: var(--gray-200);
    }

    &-disabled {
      color: var(--gray-700);
      cursor: not-allowed;

      &:hover {
        background-color: #fff;
        cursor: not-allowed;
      }
    }

    &-group-list {
      padding: 0;
      list-style: none;
    }
  }

  &-item-group {
    color: var(--transparent-gray-700);
  }

  &-disabled {
    .#{$prefix} {
      &-selection-search input {
        cursor: not-allowed;
      }

      &-selector {
        color: var(--gray-700);
        background-color: rgba(0, 0, 0, 0.03);
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
        cursor: not-allowed;

        &:hover,
        &:active {
          background-color: rgba(0, 0, 0, 0.03);
          box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
        }
      }

      &-arrow {
        cursor: not-allowed;

        svg {
          fill: var(--gray-700);
        }
      }
    }
  }

  &-light {
    .#{$prefix} {
      &-placeholder-text {
        color: var(--gray-800);
        font-weight: 500;
      }

      &-selector {
        color: var(--gray-800);
        font-weight: 500;
        background-color: transparent;
        box-shadow: none;

        &::after {
          opacity: 0;
          content: "";
          position: absolute;
          top: 0;
          left: 0;
          width: 100%;
          height: 100%;
          background-color: var(--gray-800);
          border-radius: 4px;
          transform: scale(0.94);
          transition: all var(--adui-motion-ease-base)
            var(--motion-duration-base);
        }

        &:hover {
          color: var(--gray-900);

          &::after {
            opacity: 0.1;
            transform: scale(1);
          }
        }

        &:active {
          &::after {
            opacity: 0.2;
            transform: scale(1);
          }
        }
      }
    }

    &.#{$prefix}-disabled {
      .#{$prefix}-selector {
        color: var(--gray-700);
        background-color: transparent;
        box-shadow: none;

        svg {
          fill: var(--gray-700);
        }

        &:hover,
        &:active {
          &::after {
            opacity: 0;
          }
        }
      }
    }
  }

  &-selection-item {
    position: relative;
    z-index: 1;
    max-width: 100%;
    height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &-selection__placeholder,
  &-selection-selected-value {
    margin-right: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  &-arrow,
  &-clear {
    position: absolute;
    top: 50%;
    margin-top: -9px;
    right: 6px;
    line-height: 0;

    svg {
      display: block;
    }
  }

  &-arrow {
    pointer-events: none;
  }

  &-clear {
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
  }

  &-dropdown {
    position: absolute;
    top: -9999px;
    left: -9999px;
    z-index: var(--z-index-dropdown);
    background-color: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: var(--box-shadow-elevation-2);

    [role*="listbox"] + div {
      @include mixins.scrollbar();
      padding: 4px 0;
    }

    .rc-virtual-list-scrollbar {
      width: 14px !important;

      &-thumb {
        left: 6px !important;
        width: 6px !important;
        background-color: rgba(0, 0, 0, 0.15) !important;

        &:hover {
          background-color: rgba(0, 0, 0, 0.4) !important;
        }
      }
    }

    &-large {
      .#{$prefix} {
        &-item {
          padding-left: 16px;
          line-height: 40px;

          &-group {
            font-size: var(--font-size-medium);
          }

          &-option {
            font-size: var(--font-size-large);
          }
        }
      }
    }

    &-medium {
      .#{$prefix} {
        &-item {
          padding-left: 16px;
          line-height: 36px;

          &-group {
            font-size: var(--font-size-mini);
          }

          &-option {
            font-size: var(--font-size-medium);
          }
        }
      }
    }

    &-small,
    &-mini {
      .#{$prefix} {
        &-item {
          padding-left: 12px;
          line-height: 32px;

          &-group {
            font-size: var(--font-size-mini);
          }

          &-option {
            font-size: var(--font-size-medium);
          }
        }
      }
    }
  }

  &-dropdown-searchable {
    max-height: initial;

    .#{$prefix}-dropdown {
      max-height: 250px;
    }
  }

  &-dropdown-hidden {
    display: none;
  }

  &-item-empty {
    position: relative;
    padding: 4px 16px;
    font-size: var(--font-size-small);
    line-height: 32px;
    color: var(--gray-700);
    white-space: nowrap;
    cursor: not-allowed;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color var(--adui-motion-duration-base)
      var(--adui-motion-ease-base);
  }

  &-open {
    &.adui-select-light {
      .adui-select-selector {
        &::after {
          opacity: 0.1;
          transform: scale(1);
        }

        &:active {
          &::after {
            opacity: 0.2;
            transform: scale(1);
          }
        }
      }
    }
  }

  &-large {
    height: 42px;

    .#{$prefix} {
      &-placeholder-text,
      &-selector {
        font-size: var(--font-size-large);
      }

      &-placeholder-text {
        left: 16px;
      }

      &-placeholder-text,
      &-selection-item {
        line-height: 42px;
      }

      &-selection-item,
      &-selection-placeholder {
        margin-left: 16px;
        margin-right: 32px;
      }
    }
  }
  &-medium {
    height: 36px;

    .#{$prefix} {
      &-placeholder-text,
      &-selector {
        font-size: var(--font-size-medium);
      }

      &-placeholder-text {
        left: 12px;
      }

      &-placeholder-text,
      &-selection-item {
        line-height: 36px;
      }

      &-selection-item,
      &-selection-placeholder {
        margin-left: 12px;
        margin-right: 28px;
      }
    }
  }
  &-small {
    height: 30px;

    .#{$prefix} {
      &-placeholder-text,
      &-selector {
        font-size: var(--font-size-small);
      }

      &-placeholder-text {
        left: 10px;
      }

      &-placeholder-text,
      &-selection-item {
        line-height: 30px;
      }

      &-selection-item,
      &-selection-placeholder {
        margin-left: 10px;
        margin-right: 26px;
      }
    }
  }
  &-mini {
    height: 26px;

    .#{$prefix} {
      &-placeholder-text,
      &-selector {
        font-size: var(--font-size-mini);
      }

      &-placeholder-text {
        left: 8px;
      }
      &-placeholder-text,
      &-selection-item {
        line-height: 26px;
      }

      &-selection-item,
      &-selection-placeholder {
        margin-left: 8px;
        margin-right: 24px;
      }
    }
  }

  &-select_placeholderShow {
    .#{$prefix}-selection__placeholder {
      display: block !important;
    }
  }
  &-search {
    position: relative;
    height: 44px;
    box-shadow: 0 1px 0 0 var(--gray-300);

    .#{$prefix}-icon {
      position: absolute;
      z-index: 0;
      top: 50%;
      left: 12px;
      margin-top: -9px;
      fill: var(--gray-700);
      transition: fill var(--motion-duration-base) var(--adui-motion-ease-base);
    }

    input {
      position: relative;
      z-index: 1;
      padding: 10px 12px 10px 34px;
      width: 100%;
      font-size: 14px;
      line-height: 24px;
      background-color: transparent;
      border: none;
      outline: none;
      @include mixins.placeholder();

      &:hover {
        + .#{$prefix}-icon {
          fill: var(--gray-800);
        }
      }

      &:focus {
        + .#{$prefix}-icon {
          fill: var(--gray-900);
        }
      }
    }
  }
}
