@use '../../sass/variables' as *;

select.browser-default {
  opacity: 1;
  color: var(--md-sys-color-on-background);
}

// TODO: Change to ".select" and not use tag name directly
// Keep selects useable without javascript

select {
  background-color: var(--md-sys-color-surface);
  width: 100%;
  padding: 5px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: 2px;
  height: 3rem;
}

.select-wrapper:focus-within {
  outline: 2px solid var(--md-sys-color-primary);
  border-radius: 4px;
}

.select-wrapper {
  position: relative;

  .caret {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    margin: auto 0;
    z-index: 0;
    fill: var(--md-sys-color-on-background);
    pointer-events: none;
  }

  // Hide select with overflow hidden instead of using display none
  // (this prevents form validation errors with hidden form elements)
  .hide-select {
    width: 0;
    height: 0;
    overflow: hidden;
    position: absolute;
    top: 0;
    z-index: -1;
  }
}

select:disabled {
  color: var(--md-sys-color-on-surface);
}

.select-wrapper.disabled {
  + label {
    color: var(--md-sys-color-on-surface);
  }
  .caret {
    fill: var(--md-sys-color-on-surface);
  }
}

.select-wrapper input.select-dropdown:disabled {
  color: var(--md-sys-color-on-surface);
  cursor: default;
  user-select: none;
}

.select-wrapper i {
  color: var(--md-sys-color-on-surface);
}

.select-dropdown li.disabled,
.select-dropdown li.disabled > span,
.select-dropdown li.optgroup {
  color: var(--md-sys-color-on-surface);
  //background-color: transparent;
}

// Icons
.select-dropdown li {
  img {
    height: $dropdown-item-height - 10;
    width: $dropdown-item-height - 10;
    margin: 5px 15px;
    object-fit: cover;
    float: right;
  }
}

// Optgroup styles
.select-dropdown li.optgroup {
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  &.selected > span {
    color: var(--md-sys-color-on-background);
  }
  & > span {
    color: var(--md-sys-color-on-surface-variant);
  }
  & ~ li.optgroup-option {
    padding-left: 1rem;
  }
}
