src/components/Dropdown/Dropdown.scss
@import '../../constants/styles';

.Dropdown {
  &__wrapper {
    position: relative;

    &[disabled] {
      cursor: not-allowed;
    }
  }

  @include button-reset;
  display: flex;
  user-select: none;
  justify-content: space-between;
  align-items: center;
  z-index: 80;
  border-radius: 4px;
  height: 28px;
  border: 1px solid var(--border);
  padding-inline-start: 8px;
  padding-inline-end: 4px;
  position: relative;
  background: var(--component-background);

  cursor: pointer;

  @include mobile {
    height: 32px;
  }

  .arrow {
    width: 12px;
    height: 16px;
    margin-top: 2px;
  }

  .picked-option {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;

    .picked-option-text {
      flex: 0.8;
      width: 100%;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;

      .Dropdown__input {
        width: 100%;
        border: none;
      }
    }
  }

  &.text-left {
    .picked-option {
      text-align: start;
    }
  }

  &.disabled {
    background: none;
    border: 1px solid var(--gray-4);
    color: var(--disabled-icon);
    pointer-events: none;
  }

  &:focus {
    outline: var(--focus-visible-outline) !important;
  }

  &:focus-visible {
    outline: var(--focus-visible-outline) !important;
  }
}

.Dropdown__items {
  z-index: 81; // Needed to not trigger mouse events underneath the dropdown
  display: flex;
  flex-direction: column;
  position: absolute;
  inset-block-start: 30px;
  inset-inline-end: 0px;
  border-radius: 4px;
  box-shadow: 0px 0px 3px 0px var(--document-box-shadow);
  width: 100%;

  background: var(--component-background);
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow-x: hidden; // necessary so that children respect border-radius on hover
  overflow-y: auto; // necessary so that children respect border-radius on hover

  &.hide {
    // Required to get width for positioning.
    visibility: hidden;
  }

  &.dropdown-items-with-custom-display {
    inset-inline-end: inherit;
    width: auto;
  }

  &.dropdown-items-with-label {
    .Dropdown__item {
      padding-inline-start: 20px;
    }
  }
}

.Dropdown__label {
  font-weight: bold;
  min-height: 28px;
  padding-inline-start: 8px;
  align-items: center;
  display: flex;
  border-radius: 0px;
  padding-inline-end: 32px;
}

.Dropdown__item {
  @include button-reset;
  height: 28px;
  padding-inline-start: 8px;
  align-items: center;
  display: flex;
  border-radius: 0px;
  padding-inline-end: 32px;
  line-height: 28px;
  cursor: pointer;

  &.selected,
  &:hover {
    color: var(--dropdown-item-active-text);

    .Icon,
    .Icon svg * {
      color: var(--dropdown-item-active-icon);
    }
  }

  &.selected {
    background-color: var(--dropdown-item-active);
  }

  &.active {
    outline-offset: -2px;
    outline: var(--focus-visible-outline) !important;
  }

  &:hover {
    background-color: var(--dropdown-item-hover);
  }

  &:first-child {
    border-top-right-radius: 4px;
    border-top-left-radius: 4px;
  }

  &:last-child {
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 4px;
  }
}

[data-element='endLineStyleDropdown'] .picked-option-text {
  flex: 0.95 !important;
}

[data-element='endLineStyleDropdown'] .picked-option .arrow {
  width: 11px !important;
}
