/*
 * SPDX-FileCopyrightText: 2025-present Tobias Kunze
 * SPDX-License-Identifier: Apache-2.0
 */

.choices {
  width: 100%;
  margin-bottom: 0;

  .choices__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: 2px 5px;
    color: var(--color-text-input);
    caret-color: var(--color-text-input);
    background-color: var(--color-bg);
    background-clip: padding-box;
    border: 1px solid var(--color-border);
    border-radius: var(--size-border-radius);
    min-height: 2.5rem;
    transition:
      border-color 0.15s ease-in-out,
      box-shadow 0.15s ease-in-out;
    .choices__item {
      font-size: 1rem;
      display: inline-flex;
      align-items: center;
      border-radius: var(--size-border-radius);
      color: var(--color-text-input);
      background-color: var(--color-bg);
      border: 0;
      margin: 2px;
      padding-right: 5px;

      &.choices__item--selectable {
        button {
          color: var(--color-danger) !important;
        }
      }

      button {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        margin: 0;
        padding: 0;
        width: 18px;
        height: 22px;
        color: var(--color-text-input);
        font-size: 1rem;
        font-weight: bold;
        text-indent: 0;
        background-image: none;
      }
    }

    &:has(input:focus) {
      border-color: var(--color-primary-light);
      outline: 0;
      box-shadow: var(--shadow-focus);
    }
  }

  &[data-type*="select-one"] {
    .choices__inner {
      padding-bottom: 0;
    }
    &:after {
      border-color: var(--color-grey) transparent transparent;
    }
    &.is-open:after {
      border-color: transparent transparent var(--color-grey);
    }
  }
  .has-no-choices {
    display: none;
  }

  input[type="search"] {
    height: 28px !important;
    font-size: 1rem;
    display: inline;
    padding: 0;
    margin-left: 8px;
    margin-bottom: 0;
    height: calc(1.5em + 0.5rem + 2px);
    &,
    &:focus,
    &:active,
    &:focus-visible {
      border: none;
      box-shadow: none;
    }
  }
  .choices__list.choices__list--multiple {
    .choices__item {
      padding: 2px 5px 2px 2px;
      box-shadow: var(--shadow-checkbox);
      &.choice-item-color:before {
        margin-left: 5px;
      }
    }
  }
  .choices__list.choices__list--dropdown {
    z-index: 500;
    border-bottom-right-radius: var(--size-border-radius);
    border-bottom-left-radius: var(--size-border-radius);
    border-color: var(--color-border);
    /* Make the corner radius look slightly less silly */
    margin-top: -2px;
    margin-bottom: -2px;

    .choices__item {
      font-size: 1rem;
      color: var(--color-text-input);

      &.choice-item-color:before {
        margin-right: 5px;
      }

      .choice-item-description {
        color: var(--color-grey);
        font-style: italic;
        font-size: 0.8rem;
      }
    }
  }

  .choices__item.choice-item-color:before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--choice-color);
    margin-top: 2px;
  }
  .choices__item.choice-item-color:not([data-deletable]):before {
    margin-right: 5px;
    margin-top: 2px;
  }

  .choices__inner .choices__item.choice-item-highlight {
    background-color: var(--color-primary-lighter);
  }

  .choices__list.choices__list--dropdown .choices__item.choice-item-highlight {
    color: var(--color-success);
  }
}

.submit-group .choices {
  align-self: flex-start;
}
