/**
 * Mango · buscador.
 *
 * Campo de búsqueda con resultados en vivo.
 */

/* Buscador -------------------------------------------------------------- */

.mango-search { --mango-search-focus: var(--mango-color-primary, #2563eb); position: relative; width: 100%; }

.mango-search-box {
	display: flex;
	align-items: center;
	height: 48px;
	overflow: hidden;
	border: 1px solid #e2e8f0;
	border-radius: 999px;
	background: #fff;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.mango-search-box:focus-within {
	border-color: var(--mango-search-focus);
	box-shadow: 0 0 0 4px color-mix(in srgb, var(--mango-search-focus) 18%, transparent);
}

.mango-search-icon { display: inline-flex; padding-left: 16px; color: #64748b; }
.mango-search-icon svg { width: 18px; height: 18px; }

.mango-search-input {
	flex: 1;
	min-width: 0;
	height: 100%;
	padding: 0 16px;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: #0f172a;
	font: inherit;
	outline: none;
}

.mango-search-input::-webkit-search-cancel-button { cursor: pointer; }

.mango-search-submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: stretch;
	margin: 4px;
	padding: 0 20px;
	border: 0;
	border-radius: 999px;
	background: var(--mango-color-primary, #2563eb);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	transition: filter .2s ease;
}

.mango-search-submit:hover { filter: brightness(1.08); }
.mango-search-submit.is-icon { aspect-ratio: 1; padding: 0; }
.mango-search-submit svg { width: 18px; height: 18px; }

/* Indicador de carga sobre el icono/botón. */
.mango-search.is-loading .mango-search-box::after {
	content: "";
	width: 16px;
	height: 16px;
	margin-right: 14px;
	border: 2px solid #cbd5e1;
	border-top-color: var(--mango-search-focus);
	border-radius: 50%;
	animation: mangoSpin .7s linear infinite;
	order: 2;
}

.mango-search.is-loading .mango-search-submit { order: 3; }

@keyframes mangoSpin { to { transform: rotate(360deg); } }

.mango-search-results {
	position: absolute;
	z-index: 1001;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	max-height: min(70vh, 460px);
	padding: 6px;
	overflow-y: auto;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 20px 48px rgba(15, 23, 42, 0.18);
	animation: mangoDrop .18s ease;
}

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

@keyframes mangoDrop { from { opacity: 0; transform: translateY(-6px); } }

.mango-search-result {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 8px 10px;
	border-radius: 10px;
	color: #0f172a;
	text-decoration: none;
}

.mango-search-result:hover,
.mango-search-result.is-active { background: #f1f5f9; }

.mango-search-result-image {
	flex: 0 0 48px;
	width: 48px;
	height: 48px;
	overflow: hidden;
	border-radius: 8px;
	background: #f1f5f9;
}

.mango-search-result-image img { width: 100%; height: 100%; object-fit: cover; }
.mango-search-result-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mango-search-result-title { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.mango-search-result-title mark { padding: 0; background: none; color: var(--mango-color-primary, #2563eb); }
.mango-search-result-price { font-size: 13px; font-weight: 700; color: #475569; }
.mango-search-result-price del { margin-right: 6px; color: #94a3b8; font-weight: 400; }
.mango-search-result-price ins { text-decoration: none; }

.mango-search-empty { margin: 0; padding: 14px; color: #64748b; font-size: 14px; text-align: center; }

.mango-search-all {
	display: block;
	width: 100%;
	margin-top: 4px;
	padding: 10px;
	border: 0;
	border-top: 1px solid #eef2f7;
	background: none;
	color: var(--mango-color-primary, #2563eb);
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
}
