/* Buscador de productos.
 *
 * Los colores están en variables sobre .swoo: para recolorear todo el buscador
 * alcanza con pisar --swoo-accent y --swoo-dark en tu tema. Nada más.
 */

.swoo {
	--swoo-accent: #ff6f00;   /* naranja de marca */
	--swoo-dark: #333333;     /* gris de marca: borde y botón */
	--swoo-radius: 10px;
	--swoo-bw: 3px;           /* grosor del borde */

	position: relative;
	width: 100%;
	max-width: 720px;
	margin: 0 auto;
}

/* ---------------------------------------------------------------- caja */

.swoo__box {
	display: flex;
	align-items: stretch;
	background: #fff;
	border: var(--swoo-bw) solid var(--swoo-dark);
	border-radius: var(--swoo-radius);
	/* overflow hidden = el botón negro respeta la esquina redondeada sin
	   tener que repetir el radius en el hijo. */
	overflow: hidden;
}

.swoo__input {
	flex: 1;
	min-width: 0;
	border: 0;
	outline: 0;
	background: transparent;
	padding: 14px 18px;
	font-size: 17px;
	line-height: 1.3;
	color: #1a1a1a;
	font-family: inherit;
}

.swoo__input::placeholder {
	color: #9a9a9a;
	opacity: 1;
}

/* La X nativa de Chrome duplica nuestro botón de limpiar. */
.swoo__input::-webkit-search-cancel-button,
.swoo__input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.swoo__clear {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 46px;
	border: 0;
	background: transparent;
	color: #8a8a8a;
	cursor: pointer;
	padding: 0;
}

.swoo__clear:hover {
	color: var(--swoo-dark);
}

.swoo__clear[hidden] {
	display: none;
}

.swoo__submit {
	display: flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 72px;
	border: 0;
	background: var(--swoo-dark);
	color: #fff;
	cursor: pointer;
	padding: 0;
	transition: background .15s;
}

.swoo__submit:hover {
	background: #1f1f1f;
}

.swoo__box:focus-within {
	box-shadow: 0 0 0 3px rgba( 255, 111, 0, .25 );
}

/* ---------------------------------------------------------------- panel */

.swoo__results {
	position: absolute;
	z-index: 99999;
	top: calc( 100% + 4px );
	left: 0;
	right: 0;
	max-height: 70vh;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: #fff;
	border: 2px solid var(--swoo-accent);
	border-radius: 4px;
	box-shadow: 0 10px 28px rgba( 0, 0, 0, .18 );
}

.swoo__results[hidden] {
	display: none;
}

/* ---------------------------------------------------------------- item */

.swoo__item {
	display: flex;
	align-items: center;
	gap: 16px;
	padding: 14px 16px;
	text-decoration: none;
	color: inherit;
	border-bottom: 2px solid var(--swoo-accent);
	background: #fff;
	transition: background .12s;
}

.swoo__item:last-of-type {
	border-bottom-width: 2px;
}

.swoo__item:hover,
.swoo__item.is-active {
	background: #fff4e8;
}

.swoo__img {
	flex: 0 0 84px;
	width: 84px;
	height: 84px;
	object-fit: contain;
	background: #fff;
}

.swoo__img--empty {
	background: #f0f0f0;
	border-radius: 4px;
}

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

.swoo__name {
	font-size: 17px;
	font-weight: 400;
	line-height: 1.3;
	color: #1a1a1a;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.swoo__price {
	font-size: 18px;
	font-weight: 600;
	color: #1a1a1a;
}

.swoo__price--out {
	font-size: 14px;
	font-weight: 400;
	color: #c0392b;
}

.swoo__sku {
	font-size: 11px;
	color: #999;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* --- flecha circular --- */

.swoo__go {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: var(--swoo-accent);
	color: #fff;
	transition: transform .15s;
}

.swoo__item:hover .swoo__go,
.swoo__item.is-active .swoo__go {
	transform: translateX( 3px );
}

/* ---------------------------------------------------------------- pie */

.swoo__more {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 18px 12px;
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: .3px;
	font-size: 17px;
	font-weight: 600;
	color: var(--swoo-accent);
	background: #fff;
}

.swoo__more:hover {
	background: #fff4e8;
	color: var(--swoo-accent);
}

.swoo__empty {
	padding: 24px 16px;
	text-align: center;
	color: #777;
	font-size: 15px;
}

/* ---------------------------------------------------------------- móvil */

@media ( max-width: 640px ) {
	.swoo {
		max-width: none;
	}

	.swoo__input {
		font-size: 16px; /* menos de 16px hace que iOS haga zoom al enfocar */
		padding: 12px 14px;
	}

	.swoo__submit {
		flex-basis: 56px;
	}

	.swoo__img {
		flex-basis: 64px;
		width: 64px;
		height: 64px;
	}

	.swoo__name {
		font-size: 15px;
	}

	.swoo__price {
		font-size: 16px;
	}

	.swoo__go {
		flex-basis: 34px;
		width: 34px;
		height: 34px;
	}

	.swoo__more {
		font-size: 15px;
		padding: 15px 12px;
	}
}
