/*
 * Hotwire Combobox style overrides.
 *
 * Loaded from app/views/layouts/application.html.erb as a plain stylesheet.
 * IMPORTANT: the app uses the Tailwind browser runtime (@tailwindcss/browser),
 * which scans the DOM for utility classes but does NOT process @apply inside
 * standalone <link>-loaded CSS. So any `@apply` directive below compiles to
 * an empty rule. Use plain CSS (daisyUI tokens via CSS variables are fine).
 */

/* Hotwire Combobox Styles */
.hw-combobox {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
}

/* Multiselect fieldset: stack label on top, then a flex row of chips + input. */
.hw-combobox--multiple .hw-combobox__main__wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-base-300, #d4d4d4);
  border-radius: 0.5rem;
  background: var(--color-base-100, white);
  min-height: 2.5rem;
}

.hw-combobox--multiple .hw-combobox__input {
  flex: 1 1 8rem;
  min-width: 8rem;
  width: auto !important;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0.25rem 0;
}

/* Single-select wrapper keeps its own block layout. */
.hw-combobox:not(.hw-combobox--multiple) .hw-combobox__main__wrapper {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  position: relative;
}

.hw-combobox__input {
  border: 1px solid var(--color-base-300, #d4d4d4);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  background: var(--color-base-100, white);
}

.hw-combobox__input[data-queried] {
  border-color: var(--color-primary, #1a6b3f);
}

.hw-combobox__input--invalid {
  border-color: var(--color-error, #d63939);
}

.hw-combobox__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.hw-combobox__handle {
  position: absolute;
  right: 2rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
}

.hw-combobox__listbox {
  position: absolute;
  z-index: 50;
  max-height: 15rem;
  overflow-y: auto;
  opacity: 0.9;
  background-color: var(--color-base-100, white);
  border-radius: 0.5rem;
  border: 1px solid var(--color-base-300, #e0e0e0);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  padding: 0.5rem;
  width: fit-content;
}

.hw-combobox-bottom .hw-combobox__listbox {
  position: absolute;
  bottom: 100%;
}

.hw-combobox-inline .hw-combobox__listbox {
  position: absolute;
  opacity: 1;
  right: 0;
  z-index: 10;
}

.hw-combobox__option {
  cursor: pointer;
  padding: 0.5rem;
  background-color: var(--color-base-100, white);
  border-radius: 0.5rem;
  width: max-content;
  font-size: 0.8rem;
  border: 1px solid var(--color-base-300, #e0e0e0);
  margin-bottom: 0.25rem;
}

.hw-combobox__option:hover {
  background-color: var(--color-base-200, #f5f5f4);
}

.hw-combobox__option--selected {
  background-color: color-mix(in srgb, var(--color-primary) 20%, white);
}

.hw-combobox__option--blank {
  color: color-mix(in srgb, var(--color-base-content, #1f1f1f) 60%, transparent);
}

.hw-combobox__group {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hw-combobox__group__label {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--color-base-content, #1f1f1f) 60%, transparent);
}

/* Selected-pill chips that appear inline with the input in multiselect mode.
 * The gem wraps each chip in <div data-hw-combobox-chip> which itself
 * contains a child <div class="hw-combobox__chip"> holding the label span
 * and remover span. Style both so chips render as flex pills regardless
 * of which layer Tailwind might have tried to decorate. */
[data-hw-combobox-chip] {
  display: inline-flex;
  flex: 0 0 auto;
}

.hw-combobox__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  background: var(--color-base-200, #ece9e2);
  color: var(--color-base-content, #1f1f1f);
  font-size: 0.8125rem;
  line-height: 1.2;
  white-space: nowrap;
}

.hw-combobox__chip__remover {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--color-base-content, #1f1f1f);
  opacity: 0.6;
}

.hw-combobox__chip__remover::before {
  content: "×";
}

.hw-combobox__chip__remover:hover {
  opacity: 1;
  color: var(--color-error, #d63939);
}

.hw-combobox__dialog {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: var(--color-base-100, white);
}

.hw-combobox__dialog__wrapper {
  display: none;
}

.hw-combobox__dialog[open] .hw-combobox__dialog__wrapper {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  height: 100%;
}

.hw-combobox__dialog__label {
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.hw-combobox__dialog__input {
  border: 1px solid var(--color-base-300, #d4d4d4);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
  margin-bottom: 1rem;
}

.hw-combobox__dialog__listbox {
  flex: 1;
  overflow-y: auto;
}

.hw_combobox__pagination__wrapper {
  margin-top: 0.5rem;
}

/* Filter bar combobox overrides - dropdown appears below, ghost styling */
.filter-combobox .hw-combobox {
  width: 100%;
  min-width: 0;
  min-inline-size: 0;
}

.filter-combobox .hw-combobox__main__wrapper {
  width: 100%;
  position: relative;
  z-index: 100;
}

.filter-combobox .hw-combobox__input {
  border: none !important;
  background: transparent !important;
  width: 100% !important;
  box-shadow: none !important;
}

.filter-combobox .hw-combobox__input:focus,
.filter-combobox .hw-combobox__input[data-queried] {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  box-shadow: none !important;
}

.filter-combobox .hw-combobox__listbox {
  bottom: auto;
  top: 100%;
  z-index: 100;
  position: absolute;
}
