/**
 * PropGlen Premium Select — shared presentation helpers.
 * Base chrome comes from .listing-custom-select / .form-custom-select in style.css.
 */

select.native-filter-select[data-pg-premium-select="1"],
select.native-form-select[data-pg-premium-select="1"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* First-paint shell: hide native #upm-area until enhancer mounts, reserve height. */
.upm-field:has(#upm-area) {
  position: relative;
}

.upm-field #upm-area:not([data-pg-premium-select="1"]) {
  width: 100%;
  min-height: 48px;
  opacity: 0;
  color: transparent;
  border-color: var(--border, #d0d5dd);
  border-radius: var(--button-radius, 12px);
  pointer-events: none;
}

.upm-filters .listing-custom-select,
.upm-field .listing-custom-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.upm-filters .listing-custom-select .custom-select-trigger,
.upm-field .listing-custom-select .custom-select-trigger {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 48px;
  padding-inline: 13px 34px;
  font-size: 0.9rem;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: var(--button-radius, 12px);
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(16, 24, 40, 0.05));
  color: var(--heading, #101828);
}

.upm-filters .listing-custom-select .custom-select-trigger:hover,
.upm-field .listing-custom-select .custom-select-trigger:hover {
  border-color: rgba(11, 163, 96, 0.45);
}

.upm-filters .listing-custom-select .custom-select-trigger:focus-visible,
.upm-field .listing-custom-select .custom-select-trigger:focus-visible {
  outline: none;
  border-color: rgba(11, 163, 96, 0.55);
  box-shadow: 0 0 0 4px rgba(11, 163, 96, 0.12);
}

.upm-filters .listing-custom-select.is-filtered .custom-select-trigger,
.upm-filters .listing-custom-select.is-active-value .custom-select-trigger,
.upm-field .listing-custom-select.is-filtered .custom-select-trigger,
.upm-field .listing-custom-select.is-active-value .custom-select-trigger {
  border-color: rgba(11, 163, 96, 0.55);
  box-shadow: 0 0 0 3px rgba(11, 163, 96, 0.1);
}

.upm-filters .listing-custom-select .custom-select-menu,
.upm-field .listing-custom-select .custom-select-menu {
  z-index: 80;
  max-height: 280px;
  overflow: auto;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border, #d0d5dd);
  background: #fff;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
}

.upm-filters .listing-custom-select .custom-select-menu button,
.upm-field .listing-custom-select .custom-select-menu button {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  text-align: left;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--heading, #101828);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.upm-filters .listing-custom-select .custom-select-menu button:hover,
.upm-filters .listing-custom-select .custom-select-menu button.is-keyboard-focus,
.upm-field .listing-custom-select .custom-select-menu button:hover,
.upm-field .listing-custom-select .custom-select-menu button.is-keyboard-focus {
  background: rgba(11, 163, 96, 0.1);
}

.upm-filters .listing-custom-select .custom-select-menu button.is-selected,
.upm-field .listing-custom-select .custom-select-menu button.is-selected {
  background: rgba(11, 163, 96, 0.14);
  color: #067647;
}

/* Sale channel accents */
.pg-premium-select--sale .custom-select-trigger:hover,
.pg-premium-select--sale.is-filtered .custom-select-trigger,
.pg-premium-select--sale.is-active-value .custom-select-trigger {
  border-color: rgba(6, 43, 91, 0.45);
  box-shadow: 0 0 0 3px rgba(6, 43, 91, 0.1);
}

.pg-premium-select--sale .custom-select-trigger:focus-visible {
  border-color: rgba(6, 43, 91, 0.55);
  box-shadow: 0 0 0 4px rgba(6, 43, 91, 0.12);
}

.pg-premium-select--sale .custom-select-menu button:hover,
.pg-premium-select--sale .custom-select-menu button.is-keyboard-focus {
  background: rgba(29, 79, 145, 0.1);
}

.pg-premium-select--sale .custom-select-menu button.is-selected {
  background: rgba(29, 79, 145, 0.14);
  color: #062b5b;
}

/* Fixed panel escapes sidebar / Leaflet overflow clipping */
.custom-select-menu.is-pg-premium-fixed {
  position: fixed !important;
  right: auto !important;
  z-index: 1200 !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transform: none !important;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
}

.pg-premium-select__search {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 0 0 8px;
  margin: 0 0 4px;
  background: #fff;
}

.pg-premium-select__search-input {
  width: 100%;
  min-height: 40px;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 10px;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--heading, #101828);
  background: #f8fafc;
}

.pg-premium-select__search-input:focus {
  outline: none;
  border-color: rgba(11, 163, 96, 0.55);
  box-shadow: 0 0 0 3px rgba(11, 163, 96, 0.12);
  background: #fff;
}

.pg-premium-select--sale .pg-premium-select__search-input:focus {
  border-color: rgba(6, 43, 91, 0.55);
  box-shadow: 0 0 0 3px rgba(6, 43, 91, 0.12);
}

.pg-premium-select__options {
  display: grid;
  gap: 2px;
}

.pg-premium-select__empty {
  margin: 8px 4px 4px;
  padding: 10px 8px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
  color: #667085;
  text-align: center;
}

/* Location / Near compact menu height (200–240px) */
.upm-near-locality-picker .custom-select-menu.is-pg-premium-fixed,
.upm-location .listing-custom-select .custom-select-menu.is-pg-premium-fixed,
.upm-location-picker .custom-select-menu.is-pg-premium-fixed {
  max-height: 240px !important;
}

@media (max-width: 960px) {
  .upm-filters .listing-custom-select .custom-select-menu,
  .upm-field .listing-custom-select .custom-select-menu,
  .custom-select-menu.is-pg-premium-fixed {
    max-height: min(52vh, 320px);
  }

  .upm-filters .listing-custom-select .custom-select-trigger,
  .upm-field .listing-custom-select .custom-select-trigger,
  .form-custom-select .custom-select-trigger {
    min-height: 44px;
  }
}

/* Location picker: reserve pin column — do not reuse generic 13px inline padding */
.upm-filters .upm-location .listing-custom-select .custom-select-trigger,
.upm-location .listing-custom-select .custom-select-trigger {
  padding-inline: 38px 34px;
}
