/**
 * Lumik Search Modal — fork del módulo Zenth Toolkit Search
 *
 * Modal centrado estilo Spotlight de macOS.
 * Overlay oscuro + modal elevado + animación de entrada (fade + scale).
 *
 * Las clases CSS conservan el prefijo `zenth-search-*` para facilitar
 * la migración futura a Zenth Toolkit. Sobrescribe los tokens desde
 * el child theme para alinear con la marca del sitio.
 */

/* ============================================================
   VARIABLES
   ============================================================ */
.zenth-search-root {
	--zenth-search-bg: #ffffff;
	--zenth-search-text: #1a1a1a;
	--zenth-search-text-muted: rgba(26, 26, 26, 0.55);
	/* Color de acento — sobrescribir desde el child theme con la marca del sitio */
	--zenth-search-accent: #2271b1;
	--zenth-search-overlay: rgba(0, 0, 0, 0.55);
	--zenth-search-border: rgba(0, 0, 0, 0.08);
	--zenth-search-hover: rgba(0, 0, 0, 0.04);
	--zenth-search-selected-bg: rgba(34, 113, 177, 0.08);
	--zenth-search-selected-border: var(--zenth-search-accent);
	--zenth-search-shadow: 0 24px 80px rgba(0, 0, 0, 0.35),
						   0 8px 24px rgba(0, 0, 0, 0.12);
    --zenth-search-speed-open: 280ms;
    --zenth-search-speed-close: 220ms;
    --zenth-search-ease-open: cubic-bezier(0.32, 0.72, 0, 1);
    --zenth-search-ease-close: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Alias. */
    --zenth-search-speed: var(--zenth-search-speed-open);
    --zenth-search-ease: var(--zenth-search-ease-open);
	--zenth-search-z: 999997;
}


/* ============================================================
   ROOT (contenedor fixed, full-viewport)
   ============================================================ */
.zenth-search-root {
	position: fixed;
	inset: 0;
	z-index: var(--zenth-search-z);
	pointer-events: none;
	display: grid;
	place-items: start center;
	padding: 12vh 24px 24px;
	font-family: inherit;
	visibility: hidden;
	transition: visibility 0s linear var(--zenth-search-speed-close);
}

.zenth-search-root.is-open {
	pointer-events: auto;
	visibility: visible;
	transition: visibility 0s linear 0s;
}

/* Bloquear scroll del body cuando el modal está abierto */
body.zenth-search-body-lock {
	overflow: hidden;
}


/* ============================================================
   OVERLAY
   ============================================================ */
.zenth-search-root .zenth-search-overlay {
	position: absolute;
	inset: 0;
	background: var(--zenth-search-overlay);
	opacity: 0;
	transition: opacity var(--zenth-search-speed-close) var(--zenth-search-ease-close);
	cursor: pointer;
}

.zenth-search-root.is-open .zenth-search-overlay {
	opacity: 1;
	transition: opacity var(--zenth-search-speed-open) var(--zenth-search-ease-open);
}


/* ============================================================
   MODAL (la tarjeta centrada)
   ============================================================ */
.zenth-search-root .zenth-search-modal {
	position: relative;
	width: 100%;
	max-width: 640px;
	background: var(--zenth-search-bg);
	color: var(--zenth-search-text);
	border-radius: 12px;
	box-shadow: var(--zenth-search-shadow);
	overflow: hidden;
	max-height: calc(100vh - 20vh);
	display: flex;
	flex-direction: column;

	/* Animación de entrada: escalar desde 0.96 y subir 12px. */
	opacity: 0;
	transform: scale(0.96) translateY(12px);
    transition: opacity var(--zenth-search-speed-close) var(--zenth-search-ease-close),
				transform var(--zenth-search-speed-close) var(--zenth-search-ease-close);
}

.zenth-search-root.is-open .zenth-search-modal {
	opacity: 1;
	transform: scale(1) translateY(0);
	transition: opacity var(--zenth-search-speed-open) var(--zenth-search-ease-open),
				transform var(--zenth-search-speed-open) var(--zenth-search-ease-open);
}


/* ============================================================
   INPUT WRAP (lupa + input + ESC)
   ============================================================ */
.zenth-search-root .zenth-search-input-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 16px 20px;
	border-bottom: 1px solid var(--zenth-search-border);
	flex-shrink: 0;
}

.zenth-search-root .zenth-search-input-icon {
	flex-shrink: 0;
	color: var(--zenth-search-text-muted);
	display: flex;
	align-items: center;
	justify-content: center;
}

.zenth-search-root .zenth-search-input-icon svg {
	width: 22px;
	height: 22px;
	display: block;
}

.zenth-search-root .zenth-search-input {
	flex: 1;
	min-width: 0;
	border: none !important;
	outline: none !important;
	background: transparent !important;
	box-shadow: none !important;
	padding: 4px 0 !important;
	margin: 0 !important;
	font-family: inherit !important;
	font-size: 17px !important;
	font-weight: 500 !important;
	line-height: 1.4 !important;
	color: var(--zenth-search-text) !important;
	-webkit-appearance: none;
	appearance: none;
}

.zenth-search-root .zenth-search-input::placeholder {
	color: var(--zenth-search-text-muted);
	font-weight: 400;
}

/* Quitar el botón X nativo del input[type=search] en WebKit */
.zenth-search-root .zenth-search-input::-webkit-search-cancel-button,
.zenth-search-root .zenth-search-input::-webkit-search-decoration {
	-webkit-appearance: none;
	appearance: none;
}

.zenth-search-root .zenth-search-close {
	flex-shrink: 0;
	background: transparent;
	border: none;
	padding: 4px 8px;
	cursor: pointer;
	color: var(--zenth-search-text-muted);
	transition: color 150ms ease;
	display: flex;
	align-items: center;
}

.zenth-search-root .zenth-search-close:hover {
	color: var(--zenth-search-text);
}

.zenth-search-root .zenth-search-esc {
	display: inline-block;
	padding: 3px 8px;
	background: rgba(0, 0, 0, 0.06);
	border-radius: 4px;
	font-family: inherit;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.5px;
	color: inherit;
}


/* ============================================================
   BODY (scrolleable)
   ============================================================ */
.zenth-search-root .zenth-search-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	min-height: 180px;
}


/* ============================================================
   ESTADO INICIAL (sin query)
   ============================================================ */
.zenth-search-root .zenth-search-empty {
	padding: 28px 24px 32px;
	text-align: center;
}

.zenth-search-root .zenth-search-empty__hint {
	margin: 0 0 20px;
	font-size: 14px;
	color: var(--zenth-search-text-muted);
	line-height: 1.5;
}

.zenth-search-root .zenth-search-suggestions__label {
	display: block;
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1.2px;
	color: var(--zenth-search-text-muted);
	margin-bottom: 12px;
}

.zenth-search-root .zenth-search-suggestions__list {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	justify-content: center;
}

.zenth-search-root .zenth-search-suggestion {
	padding: 8px 16px;
	background: rgba(0, 0, 0, 0.04);
	border: 1px solid transparent;
	border-radius: 100px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 500;
	color: var(--zenth-search-text);
	cursor: pointer;
	transition: background 150ms ease, border-color 150ms ease;
}

.zenth-search-root .zenth-search-suggestion:hover {
	background: rgba(0, 0, 0, 0.07);
	border-color: var(--zenth-search-border);
}


/* ============================================================
   RESULTADOS
   ============================================================ */
.zenth-search-root .zenth-search-results {
	padding: 8px 0;
}

.zenth-search-root .zenth-search-group {
	padding: 0;
}

.zenth-search-root .zenth-search-group__label {
	margin: 0 !important;
	padding: 12px 20px 6px;
	font-size: 11px !important;
	font-weight: 700 !important;
	text-transform: uppercase;
	letter-spacing: 1.2px;
	color: var(--zenth-search-text-muted);
	line-height: 1;
}

.zenth-search-root .zenth-search-group__list {
	list-style: none !important;
	margin: 0 !important;
	padding: 0 !important;
}

.zenth-search-root .zenth-search-item {
	margin: 0;
	padding: 0;
	list-style: none !important;
	border-left: 3px solid transparent;
	transition: background 120ms ease, border-color 120ms ease;
}

.zenth-search-root .zenth-search-item:hover,
.zenth-search-root .zenth-search-item.is-selected {
	background: var(--zenth-search-selected-bg);
	border-left-color: var(--zenth-search-selected-border);
}

.zenth-search-root .zenth-search-item__link {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 10px 20px 10px 17px; /* 17 = 20 - 3 del border-left */
	text-decoration: none !important;
	color: inherit !important;
}

.zenth-search-root .zenth-search-item__thumb {
	flex: 0 0 auto;
	width: 48px;
	height: 48px;
	border-radius: 6px;
	background: rgba(0, 0, 0, 0.05);
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

.zenth-search-root .zenth-search-item__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.zenth-search-root .zenth-search-item__thumb--placeholder {
	background: rgba(0, 0, 0, 0.05);
}

.zenth-search-root .zenth-search-item__body {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.zenth-search-root .zenth-search-item__title {
	font-size: 15px;
	font-weight: 500;
	color: var(--zenth-search-text);
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.zenth-search-root .zenth-search-item__price {
	font-size: 13px;
	font-weight: 600;
	color: var(--zenth-search-accent);
	line-height: 1.3;
}

.zenth-search-root .zenth-search-item__excerpt {
	font-size: 13px;
	font-weight: 400;
	color: var(--zenth-search-text-muted);
	line-height: 1.4;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}


/* ============================================================
   VER TODOS LOS RESULTADOS
   ============================================================ */
.zenth-search-root .zenth-search-see-all {
	display: block;
	padding: 14px 20px;
	margin-top: 8px;
	border-top: 1px solid var(--zenth-search-border);
	font-size: 13px;
	font-weight: 600;
	color: var(--zenth-search-accent) !important;
	text-decoration: none !important;
	text-align: center;
	transition: background 120ms ease;
}

.zenth-search-root .zenth-search-see-all:hover {
	background: var(--zenth-search-hover);
}

/* ============================================================
   FIX: forzar que [hidden] gane sobre display:flex/grid/block
   ============================================================
   El atributo HTML `hidden` aplica display:none por defecto, pero
   cualquier regla CSS que defina `display:` explícitamente lo
   sobreescribe por especificidad. Este selector garantiza que
   los estados con `hidden` se oculten correctamente.
*/

.zenth-search-root [hidden] {
	display: none !important;
}

/* ============================================================
   LOADING
   ============================================================ */
.zenth-search-root .zenth-search-loading {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 40px 20px;
	color: var(--zenth-search-text-muted);
}

.zenth-search-root .zenth-search-spinner {
	width: 22px;
	height: 22px;
	border: 2px solid rgba(0, 0, 0, 0.12);
	border-top-color: var(--zenth-search-accent);
	border-radius: 50%;
	animation: zenth-search-spin 700ms linear infinite;
}

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

.zenth-search-root .zenth-search-loading__text {
	font-size: 13px;
	font-weight: 500;
}


/* ============================================================
   SIN RESULTADOS
   ============================================================ */
.zenth-search-root .zenth-search-no-results {
	padding: 36px 24px;
	text-align: center;
}

.zenth-search-root .zenth-search-no-results__text {
	margin: 0 0 8px !important;
	font-size: 15px;
	color: var(--zenth-search-text);
}

.zenth-search-root .zenth-search-no-results__text strong {
	color: var(--zenth-search-accent);
	font-weight: 600;
}

.zenth-search-root .zenth-search-no-results__hint {
	margin: 0 !important;
	font-size: 13px;
	color: var(--zenth-search-text-muted);
}


/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 640px) {
	.zenth-search-root {
		padding: 8vh 12px 12px;
	}

	.zenth-search-root .zenth-search-modal {
		max-height: calc(100vh - 12vh);
	}

	.zenth-search-root .zenth-search-input-wrap {
		padding: 14px 16px;
	}

	.zenth-search-root .zenth-search-input {
		font-size: 16px !important; /* Evita zoom en iOS */
	}

	.zenth-search-root .zenth-search-item__link {
		padding: 10px 16px 10px 13px;
		gap: 12px;
	}

	.zenth-search-root .zenth-search-item__thumb {
		width: 40px;
		height: 40px;
	}

	.zenth-search-root .zenth-search-group__label {
		padding: 12px 16px 6px;
	}
}


/* ============================================================
   ACCESIBILIDAD
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
	.zenth-search-root .zenth-search-overlay,
	.zenth-search-root .zenth-search-modal {
		transition: none !important;
	}
	.zenth-search-root .zenth-search-spinner {
		animation-duration: 0ms !important;
	}
}
