@import "./variables/_variables.scss";

.comboboxWrapper {
  position: relative;
  display: flex !important;
  align-items: center;
  justify-content: center;

  .combobox {
    border: 0;
    outline: 0;
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-radius: $base-gap;
    text-overflow: ellipsis;
  }

  .combobox:focus {
    border: $bsr-black-90;
  }

  .combobox[data-focus-visible] {
    outline: $bsr-black-90;
  }

  input {
    height: 100%;
    text-overflow: ellipsis;
  }

  input:focus {
    border: $bsr-black-90;
  }

  button {
    height: 100%;
    //width: $input-button-width;
    border-radius: 0.125rem;
    padding: 0px !important;
    background-color: transparent !important;

    &.comboboxCancel {
      svg {
        width: 1.25rem;
        height: 100%;
        color: $bsr-grey-100;
        stroke-width: 1.25pt;
      }
      &:focus {
        background-color: transparent !important;
      }
    }

    &:active {
      box-shadow: none !important;
    }
  }

  // BMSK-AddresdField
  &.focused,
  &:focus,
  &:focus-within {
    box-shadow: $bsr-shadow-default !important;
    background-color: $white;
  }

  &.dark {
    background-color: $bsr-light-brown-100;
  }
}

.comboboxCancel {
  width: fit-content;
  background-color: transparent !important;
  svg {
    width: 1.25rem;
    height: 100%;
    color: $bsr-grey-100;
    stroke-width: 1.25pt;
  }
}

.comboboxPopoverWrapper {
  // popover darf kein outline haben
  background: $bsr-white-100;

  :focus-visible {
    outline: 0;
    border: 0;
  }

  .popover {
    position: absolute;
    top: -3px;
    left: 0;
    z-index: 1000;
    display: block;
    max-width: none;
    box-shadow: $bsr-shadow-default;
    border-radius: $border-radius;
  }

  div[role="listbox"] {
    overflow-x: hidden;
    background: $bsr-white-100;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
    padding-inline: 0;
    padding-block: 4px;
    transform: translateY(0.6rem);

    div[role="option"] {
      font-weight: $fontweight-normal;
      white-space: normal;

      &:active,
      &:hover {
        color: $bsr-black-90 !important;
      }

      &[aria-selected="true"],
      &[aria-selected="true"].selected {
        box-shadow: 0 0 0 2px #fff, 0 0 0 4px $primary;
        border-color: $primary;
        outline: 0;

        &:active,
        &:hover {
          color: $white;
        }
      }

      &[aria-selected="true"].selected {
        background-color: $bsr-black-30 !important;
        color: $bsr-black-90;
      }
      &.selected {
        box-shadow: none;
        background-color: $bsr-black-30 !important;
        color: $bsr-black-90;
      }
    }
  }
}

.rowDark {
  .comboboxWrapper {
    .comboboxArrow,
    .comboboxCancel {
      background-color: transparent;
    }
  }
}

.disabled {
  pointer-events: none;
  background-color: $bsr-grey-100;
}

// Tags for MultiSelectField
.tagGrid {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: fit-content;
  min-height: 3rem;
  padding: 0;

  &.focused,
  &:focus-within,
  &:focus {
    box-shadow: $bsr-shadow-default !important;
    background-color: $white;
  }

  .inputRow {
    width: 100%;
    overflow: auto;
    display: flex;
    flex-wrap: wrap;
    max-height: 3rem;

    .tag {
      background-color: $bsr-grey-100;
      border: 0;
      border-radius: 1rem;
      margin-inline: 0.25rem;
      margin-block: 0.25rem;

      &:first-child {
        margin-inline-start: 0.5rem;
      }
    }

    .tagRemove {
      padding-inline-start: 0.5rem;
      font-weight: 600;
      font-size: 0.8rem;
    }

    .combobox {
      border: 0;
      padding: 0.375rem 0.75rem;
      border-radius: 0.25rem;
      flex-grow: 1;

      &:focus,
      &:active,
      &:hover {
        outline: none;
      }
    }
  }
}

.comboboxMultiSelectPopover {
  position: relative;
  top: -2px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  overflow: auto;
  overscroll-behavior: contain;
  //border: 1px solid $popover-border-color !important;
  border-radius: $border-radius;

  background-color: $white;
  padding: 0.4rem;
  padding-top: 0.4rem;
  color: hsl(204 4% 0%);
  outline: 2px solid transparent;
  outline-offset: 2px;
  //box-shadow: $popover-box-shadow;
  //max-height: $popover-max-height;

  div[data-active-item="true"] {
    box-shadow: $bsr-shadow-default;
    border-color: $primary;
    outline: 0;
  }
  div[role="option"] {
    font-weight: 600;
    border-radius: 0.25rem;
    padding: 0.25rem;

    &:focus,
    &:hover {
      background-color: $bsr-black-10;
      color: $bsr-black-90;
      cursor: pointer;
    }

    &[aria-selected="true"] {
      background-color: $primary;
      color: $white;
      border-color: $primary;
      outline: 0;
    }

    &:not(:last-child) {
      margin-bottom: 0.25rem;
    }
  }
}

.pagination {
  button[role="combobox"] {
    height: fit-content;
  }
}
