/**
 * Buscador instantáneo del header.
 *
 * CSS propio a propósito: el Tailwind del tema viene precompilado por Vite y
 * purga las clases que no encuentra en el build, así que utilidades nuevas
 * escritas en PHP no existirían en assets/css/index.css.
 *
 * @package Tiendasisimo
 */

.ts-search {
	--ts-purple: var(--color-isimo-purple, #513685);
	--ts-green: var(--color-isimo-green, #93d50a);
	--ts-yellow: var(--color-isimo-yellow, #ffbb3a);

	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 1rem;
	font-family: inherit;
}

.ts-search[hidden] {
	display: none;
}

/* --- Fondo ---------------------------------------------------------------- */

.ts-search__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(24, 14, 44, 0.55);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.ts-search.is-open .ts-search__backdrop {
	opacity: 1;
}

/* --- Diálogo -------------------------------------------------------------- */

.ts-search__dialog {
	position: relative;
	width: 100%;
	max-width: 44rem;
	margin-top: 6vh;
	background: #fff;
	border-radius: 1rem;
	box-shadow: 0 25px 60px -12px rgba(24, 14, 44, 0.45);
	overflow: hidden;
	display: flex;
	flex-direction: column;
	max-height: 82vh;
	opacity: 0;
	transform: translateY(-0.75rem) scale(0.985);
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.ts-search.is-open .ts-search__dialog {
	opacity: 1;
	transform: translateY(0) scale(1);
}

/* --- Barra de búsqueda ---------------------------------------------------- */

.ts-search__bar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.9rem 1.1rem;
	border-bottom: 1px solid #ececf1;
}

.ts-search__icon {
	flex: 0 0 auto;
	width: 1.35rem;
	height: 1.35rem;
	color: var(--ts-purple);
}

.ts-search__input {
	flex: 1 1 auto;
	min-width: 0;
	border: 0;
	outline: 0;
	background: transparent;
	font-size: 1.15rem;
	line-height: 1.4;
	color: #1f1636;
	padding: 0.15rem 0;
	appearance: none;
}

.ts-search__input::placeholder {
	color: #9b93ad;
}

/* Fuera la "x" nativa del input[type=search]: ya hay botón de cerrar. */
.ts-search__input::-webkit-search-decoration,
.ts-search__input::-webkit-search-cancel-button {
	-webkit-appearance: none;
	appearance: none;
}

.ts-search__spinner {
	flex: 0 0 auto;
	width: 1.1rem;
	height: 1.1rem;
	border: 2px solid rgba(81, 54, 133, 0.2);
	border-top-color: var(--ts-purple);
	border-radius: 50%;
	animation: ts-search-spin 0.6s linear infinite;
}

.ts-search__spinner[hidden] {
	display: none;
}

@keyframes ts-search-spin {
	to {
		transform: rotate(360deg);
	}
}

.ts-search__close {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 2rem;
	height: 2rem;
	border: 0;
	border-radius: 0.5rem;
	background: #f4f2f8;
	color: #5f5875;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.ts-search__close svg {
	width: 1.05rem;
	height: 1.05rem;
}

.ts-search__close:hover {
	background: var(--ts-purple);
	color: #fff;
}

/* --- Resultados ----------------------------------------------------------- */

.ts-search__body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.ts-search__results {
	margin: 0;
	padding: 0.4rem;
	list-style: none;
}

.ts-search__item {
	list-style: none;
}

.ts-search__link {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 0.7rem 0.75rem;
	border-radius: 0.65rem;
	text-decoration: none;
	color: inherit;
	transition: background-color 0.12s ease;
}

.ts-search__item.is-active .ts-search__link,
.ts-search__link:hover,
.ts-search__link:focus-visible {
	background: #f4f1fb;
	outline: none;
}

.ts-search__thumb {
	flex: 0 0 auto;
	width: 3rem;
	height: 3rem;
	border-radius: 0.5rem;
	object-fit: cover;
	background: #efedf4;
}

.ts-search__text {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

.ts-search__title {
	font-weight: 600;
	font-size: 1rem;
	color: var(--ts-purple);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.ts-search__title mark {
	background: rgba(255, 187, 58, 0.45);
	color: inherit;
	padding: 0 0.1em;
	border-radius: 0.2em;
}

.ts-search__excerpt {
	font-size: 0.85rem;
	line-height: 1.45;
	color: #6b6480;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.ts-search__type {
	flex: 0 0 auto;
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: #6d6486;
	background: #f0eef6;
	border-radius: 999px;
	padding: 0.2rem 0.6rem;
}

/* --- Estante de tiendas ---------------------------------------------------- */
/* Sección aparte, con fondo y tarjetas propias, para que se lea claramente
   distinta de la lista de páginas de arriba. */

.ts-search__shelf {
	border-top: 1px solid #ececf1;
	background: #faf9fc;
	padding: 0.9rem 1.1rem 1.15rem;
}

.ts-search__shelf[hidden] {
	display: none;
}

.ts-search__shelf-head {
	display: flex;
	align-items: baseline;
	gap: 0.6rem;
	margin-bottom: 0.7rem;
}

.ts-search__shelf-title {
	margin: 0;
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: var(--ts-purple);
}

.ts-search__shelf-count {
	font-size: 0.75rem;
	color: #8a8399;
}

.ts-search__shelf-all {
	margin-left: auto;
	font-size: 0.78rem;
	font-weight: 600;
	color: var(--ts-purple);
	text-decoration: none;
	white-space: nowrap;
}

.ts-search__shelf-all:hover {
	text-decoration: underline;
}

.ts-search__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
	gap: 0.6rem;
}

.ts-search__store {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
	padding: 0.75rem 0.85rem;
	background: #fff;
	border: 1px solid #e8e5f0;
	border-radius: 0.6rem;
	text-decoration: none;
	color: inherit;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ts-search__store:hover,
.ts-search__store:focus-visible {
	border-color: #cfc6e4;
	box-shadow: 0 6px 16px -10px rgba(81, 54, 133, 0.4);
	outline: none;
}

.ts-search__store-name {
	font-weight: 700;
	font-size: 0.9rem;
	line-height: 1.3;
	color: var(--ts-purple);
}

.ts-search__store-city {
	font-size: 0.72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #6f8f1d;
}

.ts-search__store-address {
	font-size: 0.8rem;
	line-height: 1.35;
	color: #5f5875;
}

.ts-search__store-hours {
	font-size: 0.72rem;
	color: #8a8399;
	margin-top: 0.15rem;
}

.ts-search__store mark {
	background: rgba(147, 213, 10, 0.35);
	color: inherit;
	padding: 0 0.1em;
	border-radius: 0.2em;
}

/* --- Estados vacíos ------------------------------------------------------- */

.ts-search__state {
	padding: 2.25rem 1.5rem;
	text-align: center;
}

.ts-search__state[hidden] {
	display: none;
}

.ts-search__state-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	color: #443b5c;
}

.ts-search__state-hint {
	margin: 0.35rem 0 0;
	font-size: 0.875rem;
	color: #857d99;
}

/* --- Pie ------------------------------------------------------------------ */

.ts-search__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.7rem 1.1rem;
	border-top: 1px solid #ececf1;
	background: #fbfafd;
}

.ts-search__hint {
	font-size: 0.78rem;
	color: #8a8399;
}

.ts-search__all {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--ts-purple);
	text-decoration: none;
	white-space: nowrap;
}

.ts-search__all:hover {
	text-decoration: underline;
}

.ts-search__all[hidden] {
	display: none;
}

/* --- Solo lectores de pantalla -------------------------------------------- */

.ts-search__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* --- Bloqueo del scroll de fondo ------------------------------------------ */

body.ts-search-open {
	overflow: hidden;
}

/* --- Móvil ---------------------------------------------------------------- */

@media (max-width: 640px) {
	.ts-search {
		padding: 0;
	}

	.ts-search__dialog {
		margin-top: 0;
		max-width: none;
		height: 100%;
		max-height: none;
		border-radius: 0;
	}

	.ts-search__hint {
		display: none;
	}

	.ts-search__foot {
		justify-content: flex-end;
	}

	/* En móvil el estante baja a una sola columna. */
	.ts-search__grid {
		grid-template-columns: 1fr;
	}

	.ts-search__shelf-all {
		font-size: 0.72rem;
	}
}

/* --- Respeto por quien pide menos movimiento ------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.ts-search__backdrop,
	.ts-search__dialog,
	.ts-search__link,
	.ts-search__close {
		transition: none;
	}

	.ts-search__spinner {
		animation-duration: 2s;
	}
}
