/* Styled dropdowns (js/enhanced-select.js, Tom Select). Closed, the control
   looks like the theme's selects (light fill, rounded, primary chevron);
   open, the list is a card under it. */

.ts-wrapper.enhanced-select {
  min-width: 0;
  max-width: 100%;
  /* Room for the chevron: Tom Select sets the control's right padding from
     this variable, so the text never runs under the chevron. */
  --ts-pr-caret: 2.75rem;
}

/* The original select stays in the form, hidden and 1px wide. Theme rules
   giving selects width: 100% !important would stretch it (absolutely
   positioned) across the page and add a horizontal scroll. */
html body select.tomselected.ts-hidden-accessible {
  max-width: 1px !important;
  min-width: 0 !important;
  width: 1px !important;
}

.enhanced-select .ts-control {
  align-items: center;
  background: #F4F6FB;
  border: 1px solid rgba(75, 88, 166, 0.18);
  border-radius: 0.625rem;
  box-shadow: none;
  box-sizing: border-box;
  color: #21272A;
  cursor: pointer;
  flex-wrap: nowrap;
  font-family: Poppins, sans-serif;
  font-size: 0.9rem;
  height: 3rem;
  line-height: 1.2;
  padding: 0 2.75rem 0 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.enhanced-select:not(.dropdown-active) .ts-control:hover {
  border-color: rgba(75, 88, 166, 0.4);
}

/* Pointer cursor everywhere on the closed control (searching happens in the
   field inside the list). */
.enhanced-select .ts-control,
.enhanced-select .ts-control *,
.ts-wrapper.single.input-active.enhanced-select .ts-control {
  cursor: pointer !important;
}

/* Chevron as a pseudo-element, so it can flip when the list is open. */
.enhanced-select .ts-control::after {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%234B58A6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 12px 8px;
  border: none;
  content: '';
  height: 8px;
  margin: 0;
  pointer-events: none;
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.15s ease;
  width: 12px;
}

.enhanced-select.dropdown-active .ts-control::after {
  transform: translateY(-50%) rotate(180deg);
}

.enhanced-select .ts-control:focus,
.enhanced-select .ts-control:focus-visible,
.enhanced-select:focus,
.enhanced-select:focus-visible {
  outline: none !important;
}

.enhanced-select.focus .ts-control,
.enhanced-select.dropdown-active .ts-control {
  background: #fff;
  border-color: var(--perivallon-primary, #4B58A6);
  box-shadow: 0 0 0 3px rgba(75, 88, 166, 0.12);
}

/* The selected text ends in "…" before the chevron; Tom Select's own
   (hidden) search input takes no room. */
.enhanced-select .ts-control > .item {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enhanced-select .ts-control > input {
  flex: 0 0 0 !important;
  min-width: 0 !important;
  width: 0 !important;
}

/* Open list */
@keyframes enhanced-select-open {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.ts-dropdown.enhanced-select-dropdown {
  animation: enhanced-select-open 0.15s ease-out;
  background: #fff;
  border: 1px solid rgba(75, 88, 166, 0.14);
  border-radius: 0.625rem;
  box-shadow: 0 12px 28px rgba(29, 33, 67, 0.12), 0 2px 6px rgba(29, 33, 67, 0.06);
  color: #21272A;
  font-family: Poppins, sans-serif;
  font-size: 0.9rem;
  margin-top: 0.375rem;
  overflow: hidden;
  padding: 0.375rem;
  z-index: 1100;
}

.enhanced-select-dropdown .ts-dropdown-content {
  max-height: 18rem;
  padding: 0 0.25rem 0 0;
}

/* Slim scrollbar in the theme's colours, without arrows. Chrome and Safari
   use the ::-webkit-scrollbar rules (the standard properties would bring the
   arrows back on Windows); Firefox the standard ones. */
@supports not selector(::-webkit-scrollbar) {
  .enhanced-select-dropdown .ts-dropdown-content {
    scrollbar-width: thin;
    scrollbar-color: rgba(75, 88, 166, 0.35) transparent;
  }
}

.enhanced-select-dropdown .ts-dropdown-content::-webkit-scrollbar {
  width: 6px;
}

.enhanced-select-dropdown .ts-dropdown-content::-webkit-scrollbar-button {
  display: none;
  height: 0;
}

.enhanced-select-dropdown .ts-dropdown-content::-webkit-scrollbar-track {
  background: transparent;
}

.enhanced-select-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb {
  background: rgba(75, 88, 166, 0.35);
  border-radius: 3px;
}

.enhanced-select-dropdown .ts-dropdown-content::-webkit-scrollbar-thumb:hover {
  background: rgba(75, 88, 166, 0.6);
}

.enhanced-select-dropdown .option,
.enhanced-select-dropdown .no-results {
  border-radius: 0.5rem;
  line-height: 1.35;
  padding: 0.6rem 0.75rem;
}

.enhanced-select-dropdown .option.active {
  background: rgba(75, 88, 166, 0.07);
  color: var(--perivallon-primary, #4B58A6);
}

.enhanced-select-dropdown .option.selected {
  background: rgba(75, 88, 166, 0.12);
  color: var(--perivallon-primary, #4B58A6);
  font-weight: 500;
}

.enhanced-select-dropdown .no-results {
  color: var(--perivallon-muted, #5f6e8d);
}

/* Search field at the top of a long list. */
.enhanced-select-dropdown .dropdown-input-wrap {
  padding: 0 0 0.375rem;
}

.enhanced-select-dropdown .dropdown-input {
  background: #F4F6FB;
  border: 1px solid rgba(75, 88, 166, 0.18);
  border-radius: 0.5rem;
  box-shadow: none;
  /* Its padding and border inside the 100%, not past the list's edge. */
  box-sizing: border-box;
  font-family: inherit;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  width: 100%;
}

/* !important: style.css gives every focused input "border-color: inherit
   !important", which here is the black of the text. */
.enhanced-select-dropdown .dropdown-input:focus {
  border-color: var(--perivallon-primary, #4B58A6) !important;
  outline: none;
}

/* A short list needs no search box; it stays (hidden) so the keys still go
   through it. */
.enhanced-select-dropdown.is-short .dropdown-input-wrap {
  height: 0;
  overflow: hidden;
  padding: 0;
}

/* The chart's metric select is moved into the chart card after the page
   loads (js/stations-filters.js), so its width comes from here. */
.perivallon-chart-card__filters .ts-wrapper.enhanced-select {
  min-width: 14rem !important;
}

@media (max-width: 768px) {
  .perivallon-chart-card__filters .ts-wrapper.enhanced-select {
    min-width: 0 !important;
    width: 100%;
  }
}
