/* Header search box and its autocomplete dropdown
   (Views/Shared/Components/SearchBox/Default.cshtml). Loaded after the theme's
   styles.css and uses the --mechan-* tokens from mechan.brand.css.

   The view wraps the input and its min-length warning in `.search-box-field`, so the field
   and the submit button stay on one row and the warning can hang below the
   field without growing the header's height. */
#small-search-box-form {
	display: flex;
	align-items: flex-start;
}

#small-search-box-form .search-box-field {
	display: flex;
	align-items: center;
	flex: 1 1 auto;
	position: relative;
}

#small-search-box-form .search-box-field input.search-box-text {
	width: 100%;
}

#small-search-box-form #min-length-warning {
	position: absolute;
	top: 100%;
	left: 0;
	margin-top: 2px;
	color: red;
	font-size: 0.85em;
}

/* jQuery UI's autocomplete widget appends its `<ul class="ui-autocomplete">`
   near the end of <body>, not inside `.search-box-store-search-box` - so it
   can't be scoped under that ancestor. Each row the search box renders is
   `<li><div><img><div><span>name</span><div class="autocomplete-item-sku">`
   `<div class="autocomplete-item-replacements"></div></div></li>`. */
.ui-autocomplete {
	padding: 4px 0;
	z-index: 2000;
	border: 1px solid var(--mechan-rule);
	border-radius: 3px;
	box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.15);
	background: var(--mechan-white);
}

.ui-autocomplete .ui-menu-item {
	border-bottom: 1px solid var(--mechan-rule);
}

.ui-autocomplete .ui-menu-item:last-child {
	border-bottom: none;
}

.ui-autocomplete .ui-state-active,
.ui-autocomplete .ui-menu-item-wrapper.ui-state-active {
	background: var(--mechan-surface-soft);
	border: none;
	margin: 0;
}

/* jQuery UI's menu widget turns the row's first `<div>` into
   `.ui-menu-item-wrapper` itself rather than nesting it underneath - so the
   image sits directly under `.ui-menu-item-wrapper`, not under an
   intermediate div. */
.ui-autocomplete .ui-menu-item-wrapper {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 14px;
	cursor: pointer;
}

.ui-autocomplete .ui-menu-item-wrapper > img {
	width: 64px;
	height: 64px;
	object-fit: contain;
	background: var(--mechan-white);
	border: 1px solid var(--mechan-rule);
	margin-right: 0;
	margin-left: 10px;
}

.ui-autocomplete .ui-menu-item-wrapper > div {
	flex: 1 1 auto;
	min-width: 0;
}

.ui-autocomplete .ui-menu-item-wrapper > div span {
	display: block;
	font-size: var(--mechan-size-ui);
	font-weight: 600;
	text-transform: uppercase;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.ui-autocomplete .autocomplete-item-sku,
.ui-autocomplete .autocomplete-item-replacements {
	font-size: var(--mechan-size-small);
	color: var(--mechan-text-subtle);
	text-transform: none;
}

/* Replacement codes can be long part numbers; let them wrap rather than
   widen the dropdown. */
.ui-autocomplete .autocomplete-item-replacements {
	overflow-wrap: anywhere;
}

.ui-autocomplete .autocomplete-search-link .ui-menu-item-wrapper {
	font-weight: 600;
}

/* Empty state: an informational row, not a suggestion - jQuery UI's
   `.ui-state-disabled` would fade it to 35%, and hovering it must not look
   like it can be picked. */
.ui-autocomplete .ui-menu-item.ui-state-disabled {
	opacity: 1;
}

.ui-autocomplete .ui-menu-item-wrapper.autocomplete-no-results,
.ui-autocomplete .ui-menu-item-wrapper.autocomplete-no-results.ui-state-active {
	gap: 12px;
	padding: 16px;
	background: var(--mechan-white);
	cursor: default;
}

.ui-autocomplete .autocomplete-no-results-icon {
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	color: var(--mechan-text-subtle);
}

.ui-autocomplete .autocomplete-no-results-title {
	font-size: var(--mechan-size-ui);
	color: var(--mechan-text);
}

.ui-autocomplete .autocomplete-no-results-title strong {
	font-weight: 600;
	overflow-wrap: anywhere;
}

.ui-autocomplete .autocomplete-no-results-hint {
	margin-top: 2px;
	font-size: var(--mechan-size-small);
	color: var(--mechan-text-subtle);
}
