/**
 * The styled dropdown drawn in place of a <select data-select-menu> (js/selectMenu.js):
 * the button keeps the select's own classes, so the closed box looks as it did, and
 * the open list matches the date filter's quick-range menu (css/dateRangeFilter.css).
 *
 * Linked after style.css and adminModern.css: it overrides their .form-select
 * arrow (a background image in light mode, arrow-down.png in dark) with a chevron
 * of its own that turns while the list is open.
 */

.hk-select {
  --sm-accent: var(--primary-600, #2044ac);
  --sm-tint: color-mix(in srgb, var(--sm-accent) 10%, transparent);
  --sm-ring: color-mix(in srgb, var(--sm-accent) 18%, transparent);
  --sm-line: var(--border-color, #e5e7eb);
  --sm-ink: var(--text-primary-light, #111827);
  --sm-muted: var(--text-secondary-light, #6b7280);
  /* --white, not --base: the dark theme turns --white dark, while --base stays white in it. */
  --sm-surface: var(--white, #fff);
  --sm-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  --sm-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --sm-magnifier: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");

  position: relative;
  display: block;
  min-width: 0;
}

/* The select it stands in for: still in the form, never seen. */
.hk-select__native {
  display: none !important;
}

/* ---- the box ---- */

.hk-select > .hk-select__button.form-select {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-inline-end: 0.75rem;
  background-image: none;
  text-align: start;
  cursor: pointer;
}

.hk-select > .hk-select__button.form-select:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.hk-select__value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hk-select__button::after {
  content: '';
  flex: none;
  width: 16px;
  height: 16px;
  background-color: var(--sm-muted);
  -webkit-mask: var(--sm-chevron) center / contain no-repeat;
  mask: var(--sm-chevron) center / contain no-repeat;
  transition:
    transform 0.16s ease,
    background-color 0.16s ease;
}

.hk-select > .hk-select__button.form-select:hover {
  border-color: color-mix(in srgb, var(--sm-accent) 40%, var(--sm-line));
}

/* The "any" row chosen reads as a placeholder, so the boxes that do filter stand out. */
.hk-select:not(.is-set) .hk-select__value {
  color: var(--sm-muted);
}

/* A value other than the "any" row: the box says so with its accent, like the date filter. */
.hk-select.is-set > .hk-select__button.form-select {
  border-color: color-mix(in srgb, var(--sm-accent) 45%, var(--sm-line));
  background-color: color-mix(in srgb, var(--sm-accent) 4%, var(--sm-surface));
}

.hk-select.is-set .hk-select__value {
  font-weight: 500;
}

.hk-select.is-open > .hk-select__button.form-select {
  border-color: var(--sm-accent) !important;
  box-shadow: 0 0 0 3px var(--sm-ring) !important;
}

.hk-select.is-open .hk-select__button::after {
  transform: rotate(180deg);
  background-color: var(--sm-accent);
}

/* ---- the list ---- */

/* The popup: the search box (long lists only) over the rows, which scroll on their own. */
.hk-select__menu {
  position: fixed;
  z-index: 1055; /* above Bootstrap's dropdowns; inside a modal it stacks within the modal */
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  max-height: 320px;
  overflow: hidden;
  border: 1px solid var(--sm-line);
  border-radius: 12px;
  background-color: var(--sm-surface);
  box-shadow:
    0 16px 32px -8px rgba(16, 24, 40, 0.2),
    0 2px 6px rgba(16, 24, 40, 0.06);
  transform-origin: top center;
  animation: hk-select-open 0.16s cubic-bezier(0.22, 1, 0.36, 1);
}

.hk-select__menu.is-above {
  transform-origin: bottom center;
}

.hk-select__menu[hidden] {
  display: none;
}

@keyframes hk-select-open {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---- the search box at the top of a long list ---- */

.hk-select__search {
  position: relative;
  flex: none;
  padding: 6px 6px 4px;
  border-bottom: 1px solid var(--sm-line);
}

.hk-select__search[hidden] {
  display: none;
}

/* A magnifier, drawn as a mask in the muted text colour. */
.hk-select__search::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 17px;
  width: 15px;
  height: 15px;
  margin-top: -6px;
  background-color: var(--sm-muted);
  -webkit-mask: var(--sm-magnifier) center / contain no-repeat;
  mask: var(--sm-magnifier) center / contain no-repeat;
  pointer-events: none;
}

.hk-select__search-input {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 10px 0 32px;
  border: 1px solid var(--sm-line);
  border-radius: 8px;
  background-color: var(--sm-surface);
  color: var(--sm-ink);
  font-size: 0.875rem;
  outline: 0;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.hk-select__search-input::placeholder {
  color: var(--sm-muted);
}

.hk-select__search-input:focus {
  border-color: var(--sm-accent);
  box-shadow: 0 0 0 3px var(--sm-ring);
}

/* ---- the rows ---- */

/* position: relative makes a row's offsetTop count from here (scrollToRow in js/selectMenu.js). */
.hk-select__list {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.hk-select__option {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--sm-ink);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.12s ease;
}

/* The row under the pointer or the arrow keys. */
.hk-select__option.is-active {
  background-color: var(--sm-tint);
}

/* The row chosen, with a tick. */
.hk-select__option[aria-selected='true'] {
  color: var(--sm-accent);
  font-weight: 600;
}

.hk-select__option[aria-selected='true']::after {
  content: '';
  flex: none;
  width: 14px;
  height: 14px;
  background-color: currentColor;
  -webkit-mask: var(--sm-tick) center / contain no-repeat;
  mask: var(--sm-tick) center / contain no-repeat;
}

/* A note in the list rather than a choice ("No matches for …", a failed search). */
.hk-select__option[aria-disabled='true'] {
  color: var(--sm-muted);
  font-weight: 400;
  font-style: italic;
  cursor: default;
  background-color: transparent;
}

.hk-select__option[hidden],
.hk-select__divider[hidden] {
  display: none;
}

.hk-select__label {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* The letters a search found. */
.hk-select__hit {
  padding: 0;
  border-radius: 2px;
  background-color: color-mix(in srgb, var(--sm-accent) 18%, transparent);
  color: inherit;
  font-weight: 700;
}

/* Between the "any" row and the real choices. */
.hk-select__divider {
  flex: none;
  height: 1px;
  margin: 3px 6px;
  background-color: var(--sm-line);
}

/* A search that found nothing. */
.hk-select__empty {
  flex: none;
  padding: 4px 16px 14px;
  color: var(--sm-muted);
  font-size: 0.8125rem;
  font-style: italic;
}

.hk-select__empty[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .hk-select__menu {
    animation: none;
  }

  .hk-select__button::after {
    transition: none;
  }
}
