.custom-select {
  position: relative;
  display: inline-block;
  width: 68rem;
}
.select-button {
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.675em 1em;
  border: 1px solid #caced1;
  border-radius: 1rem;
  background-color: white;
  cursor: pointer;
  color: black;
}
.select-button:disabled {
  background-color: #ccc;
}
.arrow {
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #000;
  transition: transform cubic-bezier(0.4, 0, 0.2, 1) 0.15s;
}

.custom-select:not(:has(.select-dropdown.select-hidden)) .arrow {
  transform: rotateZ(-180deg);
}

.custom-select:not(:has(.select-dropdown.select-hidden)):has(.select-as-list)
  .arrow {
  transform: rotateZ(180deg);
}

.select-button.select-as-list {
  border: none;
  font-weight: 700;

  /* put the arrow first */
  flex-direction: row-reverse;
  justify-content: start;
  gap: 1rem;
}

.select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 68rem;
  border: 1px solid #caced1;
  border-radius: 1rem;
  background-color: white;
  list-style: none;
  padding: 10px;
  margin: 10px 0 0;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  max-height: 200px;
  overflow-y: auto;
  z-index: 2001;

  transition: all cubic-bezier(0.4, 0, 0.2, 1) 300ms;
}

/* unset the styles that make the dropdown a dropdown */
.select-dropdown.select-as-list {
  position: unset;
  top: unset;
  left: unset;
  border: none;
  background: none;
  padding: 0;
  margin: 0;
  box-shadow: none;
  max-height: none !important;
  z-index: 0;

  display: flex;
  flex-direction: column;
  gap: 0.5rem;

  &.select-hidden {
    max-height: 0px !important;
  }
}

@media (width <= 1024px) {
  .custom-select {
    width: calc(100vw - 4rem);
    position: initial;
  }

  .select-dropdown:not(.select-as-list) {
    width: calc(100vw - 4rem) !important;
    max-height: calc(100svh - 20rem) !important;
    top: 10rem;
    left: 2rem;
    position: fixed;

    .arrow {
      /* disable arrow transform on mobile as mobile-teleport breaks it anyway */
      transform: none !important;
    }
  }

  .select-mobile-teleport:not(:has(.select-dropdown.select-hidden))
    .select-mobile-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    background-color: #9997;
    width: 100vw;
    height: 100lvh;
    pointer-events: all;
    opacity: 1;
  }

  body.select-lock-scroll,
  body.select-lock-scroll .header_page_container {
    overflow: hidden !important;
  }

  .custom-select .arrow {
    transform: none !important;
  }
}

/* exist for the transition but not interactable or anything */
.select-mobile-backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.select-dropdown::-webkit-scrollbar {
  width: 7px;
}
.select-dropdown::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 25px;
}
.select-dropdown::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 25px;
}
.select-dropdown li {
  padding: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;

  &.select-desktop-grayedout {
    color: rgb(155, 155, 155);
  }
}
/* Highlight the selected option */
.select-dropdown li.selected {
  background-color: #f2f2f2;
  border-radius: 4px;
  font-weight: bold;
}
.select-dropdown li:hover,
.select-dropdown li:focus {
  background-color: #f2f2f2;
  border-radius: 4px;
}

.select-dropdown li .select-checkbox {
  width: 15px;
  height: 15px;
  outline: solid 1px #99a;
  pointer-events: none;
  border-radius: 3px;
  flex: none;
  transition: all cubic-bezier(0.4, 0, 0.2, 1) 100ms;

  display: flex;
  align-items: center;
  justify-content: center;
}

.select-dropdown li .select-checkbox > svg {
  opacity: 0;
  transition: all cubic-bezier(0.4, 0, 0.2, 1) 100ms;
}

.select-dropdown li.selected .select-checkbox {
  background: #99a;
}

.select-dropdown li.selected .select-checkbox > svg {
  opacity: 1;
}

.select-dropdown li .select-icon {
  max-width: 15px;
  max-height: 15px;
}

.select-hidden {
  opacity: 0;
  max-height: 0 !important;
  pointer-events: none;
}
