/*
 * serviNec: buscador predictivo del header (inc/snec-buscador.php · assets/js/buscador.js)
 * assets/css/buscador.css
 */

.snec-sr {
	--sr-blue: #1565e8;
	--sr-ink: #111827;
	--sr-soft: #6b7280;
	--sr-line: #eef0f3;
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	right: 0;
	z-index: 60;
	min-width: 360px;
	max-height: min(70vh, 560px);
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: 10px;
	box-sizing: border-box;
	border: 1px solid #e8ebf0;
	border-radius: 16px;
	background: #ffffff;
	box-shadow: 0 18px 44px -12px rgba(17, 24, 39, .22);
	font-family: 'Inter', system-ui, -apple-system, sans-serif;
	text-align: left;
	animation: snec-sr-in .16s ease-out;
}

.snec-sr[hidden] {
	display: none;
}

@keyframes snec-sr-in {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: none; }
}

.snec-sr.is-loading .snec-sr__list {
	opacity: .5;
	transition: opacity .15s;
}

/* El campo del header con el desplegable abierto. */
.snec-search form.snec-sr-open .snec-search__input {
	background: #ffffff;
	box-shadow: 0 0 0 2px var(--sr-blue, #1565e8);
}

.snec-sr__label {
	margin: 4px 8px 8px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: .06em;
	text-transform: uppercase;
	color: #9aa0aa;
}

.snec-sr__list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.snec-sr__item {
	border-radius: 10px;
}

.snec-sr__item.is-active {
	background: #f1f6fe;
}

.snec-sr__link {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
	color: var(--sr-ink);
	text-decoration: none;
}

.snec-sr__img {
	flex: none;
	display: grid;
	place-items: center;
	width: 52px;
	height: 52px;
	overflow: hidden;
	border-radius: 8px;
	background: #f6f7f9;
}

.snec-sr__img img {
	width: 46px;
	height: 46px;
	object-fit: contain;
	mix-blend-mode: multiply;
}

.snec-sr__txt {
	display: flex;
	flex-direction: column;
	gap: 3px;
	flex: 1;
	min-width: 0;
}

.snec-sr__name {
	display: -webkit-box;
	overflow: hidden;
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.3;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
}

.snec-sr__name mark,
.snec-sr__meta mark {
	padding: 0;
	background: none;
	color: var(--sr-blue);
	font-weight: 700;
}

.snec-sr__meta {
	overflow: hidden;
	font-size: 11.5px;
	color: var(--sr-soft);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.snec-sr__price {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 2px;
	flex: none;
	text-align: right;
}

.snec-sr__now {
	font-size: 14px;
	font-weight: 700;
	color: var(--sr-blue);
	white-space: nowrap;
}

.snec-sr__was {
	font-size: 11.5px;
	color: #9aa0aa;
	white-space: nowrap;
}

.snec-sr__out {
	padding: 2px 6px;
	border-radius: 4px;
	background: #fdecec;
	font-size: 10.5px;
	font-weight: 600;
	color: #b42318;
}

/* «Ver todos» */
.snec-sr__all {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 8px 0 0;
	padding: 12px;
	border-top: 1px solid var(--sr-line);
	font-size: 13px;
	font-weight: 600;
	color: var(--sr-blue);
	text-decoration: none;
}

.snec-sr__all:hover,
.snec-sr__all:focus-visible {
	text-decoration: underline;
}

/* Categorías (al enfocar y sin resultados) */
.snec-sr__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 0 8px 6px;
}

.snec-sr__cat {
	padding: 8px 12px;
	border-radius: 999px;
	background: #f1f5fd;
	font-size: 12.5px;
	font-weight: 500;
	color: #1d4ed8;
	text-decoration: none;
	transition: background .15s;
}

.snec-sr__cat:hover {
	background: #e2ebfc;
}

/* Sin resultados */
.snec-sr__empty {
	padding: 14px 8px 12px;
}

.snec-sr__empty-title {
	margin: 0 0 4px;
	font-size: 14px;
	font-weight: 600;
	color: var(--sr-ink);
}

.snec-sr__empty-sub {
	margin: 0;
	font-size: 12.5px;
	color: var(--sr-soft);
}

/* Cargando */
.snec-sr__skel {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px;
}

.snec-sr__skel > span:first-child {
	flex: none;
	width: 52px;
	height: 52px;
	border-radius: 8px;
}

.snec-sr__skel > span:last-child {
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1;
}

.snec-sr__skel i {
	display: block;
	height: 10px;
	border-radius: 4px;
}

.snec-sr__skel i:last-child {
	width: 45%;
}

.snec-sr__skel > span:first-child,
.snec-sr__skel i {
	background: linear-gradient(90deg, #f1f3f6 25%, #e7eaef 50%, #f1f3f6 75%) 0 0 / 200% 100%;
	animation: snec-sr-shine 1.1s linear infinite;
}

@keyframes snec-sr-shine {
	to { background-position: -200% 0; }
}

.snec-sr__live {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.snec-sr a:focus-visible {
	outline: 2px solid var(--sr-blue);
	outline-offset: 2px;
	border-radius: 8px;
}

/* Móvil: a lo ancho de la pantalla, bajo el campo. */
@media (max-width: 640px) {
	.snec-sr {
		position: fixed;
		left: 12px;
		right: 12px;
		min-width: 0;
		max-height: calc(100vh - 170px);
		max-height: calc(100dvh - 170px);
	}

	.snec-sr__link {
		gap: 10px;
	}

	.snec-sr__name {
		font-size: 14px;
	}
}

/* ── Buscador inteligente: recientes, tendencias, autocompletado y corrección ── */
.snec-sr svg {
	width: 16px;
	height: 16px;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.snec-sr__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.snec-sr__clear {
	margin: 0 8px 4px;
	padding: 2px 4px;
	border: 0;
	background: none;
	font: inherit;
	font-size: 12px;
	color: var(--sr-soft);
	cursor: pointer;
}

.snec-sr__clear:hover {
	color: var(--sr-ink);
	text-decoration: underline;
}

.snec-sr__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 10px;
	padding: 0 8px;
	list-style: none;
}

.snec-sr__chipwrap {
	border-radius: 999px;
}

.snec-sr__chip {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 7px 12px;
	border: 1px solid #e6e9ef;
	border-radius: 999px;
	background: #fff;
	font-size: 12.5px;
	font-weight: 500;
	color: var(--sr-ink);
	cursor: pointer;
	transition: border-color .15s, background .15s, transform .15s;
}

.snec-sr__chip svg {
	width: 14px;
	height: 14px;
	color: #9aa0aa;
}

.snec-sr__chip.is-trend svg {
	color: var(--sr-blue);
}

.snec-sr__chipwrap:hover .snec-sr__chip,
.snec-sr__chipwrap.is-active .snec-sr__chip {
	border-color: #c9d8f8;
	background: #f1f6fe;
}

.snec-sr__chip.is-hot {
	border-color: transparent;
	background: linear-gradient(#fff, #fff) padding-box, linear-gradient(120deg, #1565e8, #7c5cff 55%, #ff7a59) border-box;
}

.snec-sr__chip.is-hot svg {
	color: #7c5cff;
}

.snec-sr__hot {
	padding: 1px 6px;
	border-radius: 999px;
	background: linear-gradient(120deg, #1565e8, #7c5cff);
	font-size: 10px;
	font-style: normal;
	font-weight: 600;
	letter-spacing: .02em;
	color: #fff;
}

.snec-sr__chipx {
	display: grid;
	place-items: center;
	width: 18px;
	height: 18px;
	margin: 0 -4px 0 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: none;
	color: #9aa0aa;
	cursor: pointer;
}

.snec-sr__chipx:hover {
	background: #e6e9ef;
	color: var(--sr-ink);
}

.snec-sr__chipx svg {
	width: 12px;
	height: 12px;
}

/* Autocompletado: búsquedas populares que completan lo escrito */
.snec-sr__sugs {
	margin: 0 0 6px;
	padding: 0;
	list-style: none;
}

.snec-sr__sug {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 9px 10px;
	border-radius: 10px;
	font-size: 14px;
	color: var(--sr-soft);
	cursor: pointer;
}

.snec-sr__sug.is-active {
	background: #f1f6fe;
}

.snec-sr__sugtxt {
	flex: 1;
	min-width: 0;
	overflow: hidden;
	color: var(--sr-soft);
	text-overflow: ellipsis;
	white-space: nowrap;
}

.snec-sr__sugtxt b {
	font-weight: 600;
	color: var(--sr-ink);
}

.snec-sr__sugfill {
	display: grid;
	place-items: center;
	color: #b6bbc4;
	opacity: 0;
	transition: opacity .15s;
}

.snec-sr__sug.is-active .snec-sr__sugfill,
.snec-sr__sug:hover .snec-sr__sugfill {
	opacity: 1;
}

/* Categorías que encajan con lo escrito */
.snec-sr__catrow {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 0 0 10px;
	padding: 0 8px;
}

.snec-sr__cat--match {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.snec-sr__cat--match mark {
	padding: 0;
	background: none;
	color: inherit;
	font-weight: 700;
}

.snec-sr__cat--match em {
	font-size: 11px;
	font-style: normal;
	color: #6b8fd6;
}

/* «Mostrando resultados para…» (corrección automática) */
.snec-sr__fix {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 0 0 10px;
	padding: 10px 12px;
	border-radius: 12px;
	background: linear-gradient(120deg, #eef4ff, #f4f0ff);
	font-size: 13px;
	color: var(--sr-ink);
}

.snec-sr__fix svg {
	margin-top: 1px;
	color: #7c5cff;
}

.snec-sr__fix small {
	display: block;
	margin-top: 2px;
	font-size: 11.5px;
	color: var(--sr-soft);
}

@media (prefers-reduced-motion: reduce) {
	.snec-sr__chip,
	.snec-sr__sugfill {
		transition: none;
	}

	.snec-sr,
	.snec-sr__skel > span:first-child,
	.snec-sr__skel i {
		animation: none;
	}
}
