/* Dropdown component styles */
.ihub-dropdown-field {
  position: relative;
  width: 100%;
  font-family: var(--Nunito);
  outline: none;
}
.ihub-dropdown-field.active {
  z-index: var(--z-navigation);
}

.ihub-dropdown:focus {
  outline: none;
}

.ihub-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  min-height: 42px;
  border: var(--borderDefault);
  border-radius: 4px;
  background-color: var(--White);
  cursor: pointer;
  transition: all 0.2s ease;
}

.ihub-dropdown-trigger:hover {
  border-color: var(--DarkCyan);
}

.ihub-dropdown-open {
  border-color: var(--DarkCyan);
}

.ihub-dropdown:focus .ihub-dropdown-trigger {
  border-color: var(--DarkCyan);
  box-shadow: 0 0 0 2px rgba(0, 131, 143, 0.2);
}

.ihub-dropdown-value {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: .8rem;
}

.ihub-dropdown-placeholder {
  color: #757575;
  font-size: 14px;
}

.ihub-dropdown-indicator {
  display: flex;
  align-items: center;
  margin-left: 8px;
}

.ihub-dropdown-chevron-up {
  transform: rotate(180deg);
  transition: transform 0.2s ease;
}

.ihub-dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background-color: var(--White);
  border: var(--borderDefault);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: ihub-dropdown-appear 0.2s ease;
}

/*
 * Portalled variant: the menu is a child of <body>, so it is positioned from
 * the trigger's viewport rect instead of its own offset parent. Keeping the
 * absolute rule above means any consumer still rendering the menu inline
 * behaves as before.
 */
.ihub-dropdown-menu-portal {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 1200;
  /*
   * The menu's max-height is set inline from the space the trigger actually
   * has. Laying it out as a column lets the search box keep its natural height
   * and hands the remainder to the options list, which then scrolls. Without
   * this the list kept its own flat 250px and the menu's `overflow: hidden`
   * clipped whatever the search box pushed past the bottom, with no way to
   * reach it.
   */
  display: flex;
  flex-direction: column;
}

.ihub-dropdown-menu-portal .ihub-dropdown-search {
  flex: 0 0 auto;
}

.ihub-dropdown-menu-portal .ihub-dropdown-options {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
}

@keyframes ihub-dropdown-appear {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ihub-dropdown-search {
  display: flex;
  align-items: center;
  padding: 8px;
  border-bottom: var(--borderDefault);
}

.ihub-dropdown-search-icon {
  color: #757575;
  margin-right: 8px;
}

.ihub-dropdown-search-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 6px 8px;
  font-size: 14px;
  background: transparent;
  font-family: var(--Nunito);
}

.ihub-dropdown-options {
  max-height: 250px;
  overflow-y: auto;
  /* Do not chain to the page at the ends of the list: that would scroll the
     trigger out from under the menu the user is still reading. */
  overscroll-behavior: contain;
}

.ihub-dropdown-option {
  padding: 10px 15px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  font-size: .8rem;
}

.ihub-dropdown-option:hover:not(.ihub-dropdown-disabled-option) {
  background-color: rgba(0, 131, 143, 0.1);
}

.ihub-dropdown-selected {
  background-color: rgba(0, 131, 143, 0.15);
  font-weight: 600;
}

.ihub-dropdown-selected:hover {
  background-color: rgba(0, 131, 143, 0.2) !important;
}

.ihub-dropdown-disabled-option {
  opacity: 0.5;
  cursor: not-allowed;
}

.ihub-dropdown-no-options {
  padding: 15px;
  text-align: center;
  color: #757575;
  font-style: italic;
}

.ihub-dropdown-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 100%;
}

.ihub-dropdown-tag {
  display: flex;
  align-items: center;
  background-color: rgba(0, 131, 143, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.ihub-dropdown-tag-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0;
  margin-left: 4px;
  cursor: pointer;
  color: #555;
  transition: color 0.2s;
}

.ihub-dropdown-tag-remove:hover {
  color: var(--Danger);
}

.ihub-dropdown-disabled {
  opacity: 0.7;
  pointer-events: none;
}

/* Ensure scrollbar styling is consistent */
.ihub-dropdown-options::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.ihub-dropdown-options::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.ihub-dropdown-options::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.ihub-dropdown-options::-webkit-scrollbar-thumb:hover {
  background: #a1a1a1;
}
