@use '../variables.scss' as *;

.searchBar {
  position: relative;
  font-size: 13px;
}

.open {
  border-bottom-left-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  box-shadow: 0 1px 0 1px var(--theme-search-dropdown-border);
}

.menu {
  color: var(--theme-text);
  margin: 0;
  border-top: 0;
  background: var(--theme-search-dropdown-bg);
  position: absolute;
  z-index: 1;
  list-style: none;
  padding: 0;
  left: 0;
  right: 0;
  // Add a top offset for the 1px inset box-shadow/border
  // This avoids an unwanted dividing line between the search box + dropdown when open
  top: calc($search-bar-height - 1px);
  border-bottom-left-radius: $theme-corner-radius-search;
  border-bottom-right-radius: $theme-corner-radius-search;
  box-shadow: inset 0 0 0 1px var(--theme-search-dropdown-border);
  overflow: hidden;
  overscroll-behavior: none;

  @include phone-portrait {
    top: 100%;
    // Fallback to allow either fully or semi-transparent search box borders
    // Add a margin and change to outset shadows for clearer outlining on mobile
    // Fill the 1px margin with re-stacked fills/borders to accurately colour-match
    margin: 0 1px;
    box-shadow:
      0 0 0 1px var(--theme-search-dropdown-border),
      0 0 0 1px var(--theme-sheet-search-bg),
      0 0 0 1px var(--theme-mobile-background),
      0 1px 4px 1px rgb(0, 0, 0, 0.5);
    max-height: calc(var(--viewport-height) - var(--header-height)) !important;
  }

  &:empty {
    display: none !important;
  }
}

.invalid {
  color: var(--theme-text-secondary) !important;
}

.openButton {
  composes: resetButton from '../dim-ui/common.m.scss';
  display: inline-block;
  color: #999;
  font-size: 12px !important;
}

.menuItem {
  composes: flexRow from '../dim-ui/common.m.scss';
  align-items: flex-start;
  padding: 6px 9px 6px 9px;
  gap: 6px;

  @include interactive($hover: true) {
    cursor: pointer;
  }

  @include phone-portrait {
    padding: 10px 10px 10px 9px;
  }
}

.menuItemIcon {
  font-size: 12px !important;
  margin-top: 4px;
  color: #999;
}

.armoryItemIcon {
  margin-right: 6px;
  margin-top: 5px;
  width: 24px;
  height: 24px;
}

.openInArmoryLabel {
  font-style: italic;
  opacity: 0.5;
  margin-left: 2px;
  margin-right: 4px;
}

.deleteIcon {
  composes: resetButton from '../dim-ui/common.m.scss';
  font-size: 10px !important;
  margin-top: 4px;
  color: #999;
  padding: 0 2px;
  visibility: hidden;

  @media (hover: none) {
    visibility: visible;
  }
}

.namedQueryBody {
  display: block;
  font-size: 10.5px;
  opacity: 0.5;
}

.highlightedItem {
  background-color: var(--theme-accent-primary);
  color: var(--theme-text-invert) !important;
  .menuItemIcon,
  .openInArmoryLabel {
    color: var(--theme-text-invert);
  }
  .deleteIcon {
    color: #333;
    visibility: visible;
  }
  .namedQueryBody,
  .openInArmoryLabel {
    opacity: 1;
  }
}

.menuItemQuery {
  white-space: normal;
  margin: 0 auto 0 0;
  padding: 1px 0;
  overflow: hidden;
  max-height: 4em;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Highlighted spans of text in the autocompleter */
.textHighlight {
  display: inline-block;
  white-space: pre;
  border-bottom: 1px dotted #ddd;
  margin-bottom: -1px;
  .highlightedItem & {
    border-bottom-color: #222;
  }
}

.keyHelp {
  margin-top: 2px;
  .highlightedItem & {
    color: var(--theme-text-invert);
    border-color: var(--theme-text-invert);
  }
}

.saveSearchButton > :global(.app-icon) {
  color: var(--theme-accent-primary) !important;
}

.filterHelp {
  max-width: 800px;
  margin: 0 auto;
}

.filterBarButton {
  margin: 0 6px;
  padding: 0;
  appearance: none;
  display: inline-block;
  background: transparent;
  border: 0;
  cursor: pointer;

  @include interactive($hover: true) {
    > span,
    > :global(.app-icon),
    button > :global(.app-icon) {
      color: var(--theme-accent-primary);
    }
  }

  &:focus-visible {
    outline: 1px solid var(--theme-accent-primary);
  }

  > :global(.app-icon),
  > button > :global(.app-icon) {
    font-size: 14px !important;
    color: #999;
    // Increase touch target size
    padding: 4px;
    margin: -4px;
    margin-left: 4px;
    &:first-child {
      margin-left: -4px;
    }
    :global(.mobile-search-link) & {
      font-size: 18px !important;
    }
  }

  > span,
  > a {
    margin: 0 !important;
  }
}
