/**
 * Urra Core — Estilos del buscador modal.
 *
 * Layout estilo command-palette (Spotlight / Cmd-K): una sola caja
 * con el input arriba, separador y resultados debajo. Sin contenedor
 * anidado para el input. El badge del CPT va sobre el título como
 * chip pequeño.
 *
 * Consume el design system Urrá: colores vía `--e-global-color-*` y
 * tipografía vía `--urra-font-*`.
 */

/* ─── Variables ────────────────────────────────────────────────── */
:root {
	--uc-search-primary:     var(--e-global-color-primary, #3399CC);
	--uc-search-text:        var(--e-global-color-text, var(--e-global-color-neutral-800, #1F2937));
	--uc-search-muted:       var(--e-global-color-neutral-500, #6B7280);
	--uc-search-border:      var(--e-global-color-neutral-200, #E5E7EB);
	--uc-search-border-soft: var(--e-global-color-neutral-100, #F3F4F6);
	--uc-search-bg:          #ffffff;
	--uc-search-overlay:     rgba(15, 23, 42, 0.55);
	--uc-search-radius:      14px;
	--uc-search-card-radius: 10px;
	--uc-search-shadow:      0 25px 60px -20px rgba(15, 23, 42, 0.4);
}

/* ─── Body lock cuando el modal está abierto ──────────────────── */
body.uc-search-open {
	overflow: hidden;
}

/* ─── Modal raíz ──────────────────────────────────────────────── */
/* `z-index: 99998` queda por encima de los popups de Elementor (9999). */
.uc-search-modal {
	position: fixed;
	inset: 0;
	z-index: 99998;
	display: flex;
	align-items: flex-start;
	justify-content: center;
	padding: 8vh 16px 16px;
	box-sizing: border-box;
	font-family: var(--urra-font-body, inherit);
}

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

.uc-search-modal__overlay {
	position: absolute;
	inset: 0;
	background: var(--uc-search-overlay);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	animation: ucSearchOverlayIn 180ms ease-out;
}

/* ─── Panel: una sola caja, sin contenedores anidados ────────── */
.uc-search-modal__panel {
	position: relative;
	width: min(820px, 100%);
	max-height: 80vh;
	background: var(--uc-search-bg);
	border-radius: var(--uc-search-radius);
	box-shadow: var(--uc-search-shadow);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	color: var(--uc-search-text);
	animation: ucSearchPanelIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ─── Intro (heading + descripción editables) ─────────────────── */
.uc-search-modal__intro {
	padding: 20px 60px 6px 22px;
}

.uc-search-modal__heading {
	margin: 0 0 6px;
	font-family: var(--urra-font-heading, inherit);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.3;
	color: var(--uc-search-text);
	letter-spacing: 0;
	text-transform: none;
}

.uc-search-modal__lead {
	margin: 0;
	font-family: var(--urra-font-body, inherit);
	font-size: 13px;
	line-height: 1.55;
	color: var(--uc-search-muted);
	white-space: pre-line;
}

/* ─── Searchbar ────────────────────────────────────────────────── */
.uc-search-modal__searchbar {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 60px 18px 20px;
	border-bottom: 1px solid var(--uc-search-border-soft);
}

.uc-search-modal__intro + .uc-search-modal__searchbar {
	padding-top: 14px;
}

.uc-search-modal__icon {
	flex-shrink: 0;
	color: var(--uc-search-muted);
}

.uc-search-modal__input {
	flex: 1;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	font-family: var(--urra-font-body, inherit);
	font-size: 17px;
	font-weight: 500;
	color: var(--uc-search-text);
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.uc-search-modal__input::placeholder {
	color: var(--e-global-color-neutral-400, #9CA3AF);
	font-weight: 400;
}

.uc-search-modal__input::-webkit-search-decoration,
.uc-search-modal__input::-webkit-search-cancel-button,
.uc-search-modal__input::-webkit-search-results-button,
.uc-search-modal__input::-webkit-search-results-decoration {
	-webkit-appearance: none;
	appearance: none;
}

/* ─── Botón cerrar ─────────────────────────────────────────────── */
.uc-search-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 2;

	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0 !important;

	-webkit-appearance: none;
	appearance: none;
	background: rgba(15, 23, 42, 0.06) !important;
	border: 0 !important;
	border-radius: 50% !important;
	box-shadow: none !important;
	text-shadow: none;

	color: var(--uc-search-primary) !important;

	font: inherit;
	font-size: 0;
	line-height: 0;
	letter-spacing: 0;
	text-transform: none;
	white-space: nowrap;

	cursor: pointer;
	transition: background-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
	-webkit-tap-highlight-color: transparent;
}

.uc-search-modal__close:hover {
	background: rgba(15, 23, 42, 0.1) !important;
	transform: scale(1.06);
}

.uc-search-modal__close:active {
	background: rgba(15, 23, 42, 0.14) !important;
	transform: scale(0.96);
}

.uc-search-modal__close:focus-visible {
	outline: none;
	background: rgba(15, 23, 42, 0.1) !important;
	box-shadow:
		0 0 0 2px var(--uc-search-bg),
		0 0 0 4px var(--uc-search-primary) !important;
}

.uc-search-modal__close-icon {
	display: block;
	width: 18px;
	height: 18px;
	pointer-events: none;
	color: inherit;
	overflow: visible;
}

.uc-search-modal__close-icon path {
	stroke: currentColor !important;
	fill: none !important;
}

/* ─── Hint y resultados ───────────────────────────────────────── */
.uc-search-modal__hint {
	margin: 0;
	padding: 16px 20px;
	color: var(--uc-search-muted);
	font-family: var(--urra-font-body, inherit);
	font-size: 13px;
}

.uc-search-modal__results {
	flex: 1;
	overflow-y: auto;
	padding: 16px 20px 20px;
	scroll-behavior: smooth;
}

.uc-search-modal__results:empty {
	padding: 0;
}

.uc-search-modal__grid {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* ─── Cards ───────────────────────────────────────────────────── */
.uc-search-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 8px;
	padding: 14px 16px;
	border: 1px solid var(--uc-search-border);
	border-radius: var(--uc-search-card-radius);
	background: #ffffff;
	transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.uc-search-card--link {
	cursor: pointer;
}

.uc-search-card--link:hover {
	border-color: color-mix(in srgb, var(--uc-search-primary) 35%, var(--uc-search-border) 65%);
	transform: translateY(-1px);
	box-shadow: 0 8px 22px -14px rgba(15, 23, 42, 0.3);
}

.uc-search-card__cpt-badge {
	align-self: flex-start;
	margin-bottom: 2px;
	font-family: var(--urra-font-heading, inherit);
	font-size: 9px;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--uc-search-muted);
	background: rgba(15, 23, 42, 0.05);
	padding: 2px 7px;
	border-radius: 999px;
	line-height: 1.4;
}

.uc-search-card__title {
	margin: 0;
	font-family: var(--urra-font-heading, inherit);
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	color: var(--uc-search-primary);
}

.uc-search-card__excerpt {
	margin: 0;
	font-family: var(--urra-font-body, inherit);
	font-size: 13px;
	line-height: 1.55;
	color: var(--uc-search-text);
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.uc-search-card__cta {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-top: 4px;
	padding: 6px 12px;
	align-self: flex-start;
	font-family: var(--urra-font-heading, inherit);
	font-size: 13px;
	font-weight: 600;
	color: var(--uc-search-primary);
	background: transparent;
	border: 1px solid color-mix(in srgb, var(--uc-search-primary) 35%, transparent);
	border-radius: 999px;
	text-decoration: none;
	transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.uc-search-card__cta:hover,
.uc-search-card__cta:focus-visible {
	background: var(--uc-search-primary);
	color: #fff;
	border-color: var(--uc-search-primary);
	outline: none;
}

/* ─── Card FAQ inline ─────────────────────────────────────────── */
.uc-search-card--faq {
	cursor: default;
}

.uc-search-card__faq {
	margin: 0;
}

.uc-search-card__faq summary {
	cursor: pointer;
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
}

.uc-search-card__faq summary::-webkit-details-marker {
	display: none;
}

.uc-search-card__faq-text {
	flex: 1;
	min-width: 0;
}

/* Indicador circular +/− a la derecha, mismo lenguaje visual que el
   shortcode `[urra_faqs]`. */
.uc-search-card__faq-icon {
	position: relative;
	display: inline-flex;
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	border: 2px solid var(--uc-search-primary);
	border-radius: 50%;
	background: transparent;
	transition: transform 240ms cubic-bezier(0.4, 0, 0.2, 1);
}

.uc-search-card__faq-icon::before,
.uc-search-card__faq-icon::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 8px;
	height: 2px;
	background: var(--uc-search-primary);
	border-radius: 2px;
	transform-origin: center;
	transition:
		transform 240ms cubic-bezier(0.4, 0, 0.2, 1),
		opacity 168ms ease;
}

.uc-search-card__faq-icon::before {
	transform: translate(-50%, -50%);
}

.uc-search-card__faq-icon::after {
	transform: translate(-50%, -50%) rotate(90deg);
}

.uc-search-card__faq[open] summary .uc-search-card__faq-icon {
	transform: rotate(180deg);
}

.uc-search-card__faq[open] summary .uc-search-card__faq-icon::after {
	transform: translate(-50%, -50%) rotate(0deg);
	opacity: 0;
}

.uc-search-card__faq-answer {
	margin-top: 12px;
	color: var(--uc-search-text);
	font-family: var(--urra-font-body, inherit);
	font-size: 13px;
	line-height: 1.6;
}

.uc-search-card__faq-answer h1,
.uc-search-card__faq-answer h2,
.uc-search-card__faq-answer h3,
.uc-search-card__faq-answer h4,
.uc-search-card__faq-answer h5,
.uc-search-card__faq-answer h6 {
	margin: 14px 0 6px;
	font-family: var(--urra-font-heading, inherit);
	font-size: 13px;
	font-weight: 700;
	line-height: 1.35;
	color: var(--uc-search-text);
	letter-spacing: 0;
	text-transform: none;
}

.uc-search-card__faq-answer p {
	margin: 0 0 8px;
	font-size: 13px;
	line-height: 1.6;
}

.uc-search-card__faq-answer p:first-child { margin-top: 0; }
.uc-search-card__faq-answer p:last-child  { margin-bottom: 0; }

.uc-search-card__faq-answer ul,
.uc-search-card__faq-answer ol {
	margin: 6px 0 10px;
	padding-left: 1.4em;
	font-size: 13px;
}

.uc-search-card__faq-answer li {
	margin: 3px 0;
	line-height: 1.55;
}

.uc-search-card__faq-answer strong { font-weight: 600; }
.uc-search-card__faq-answer em     { font-style: italic; }

.uc-search-card__faq-answer a {
	color: var(--uc-search-primary);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.uc-search-card__faq-answer code {
	font-size: 12px;
	padding: 1px 5px;
	background: rgba(15, 23, 42, 0.06);
	border-radius: 4px;
}

.uc-search-card__faq-answer img {
	max-width: 100%;
	height: auto;
	border-radius: 6px;
	margin: 8px 0;
}

.uc-search-card__faq-answer blockquote {
	margin: 8px 0;
	padding: 6px 12px;
	border-left: 3px solid var(--uc-search-border);
	color: var(--uc-search-muted);
	font-size: 13px;
}

/* ─── Skeleton (loading) ──────────────────────────────────────── */
.uc-search-skeleton {
	border: 1px solid var(--uc-search-border);
	border-radius: var(--uc-search-card-radius);
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.uc-search-skeleton__line {
	height: 12px;
	border-radius: 6px;
	background: linear-gradient(90deg,
		rgba(15, 23, 42, 0.06) 0%,
		rgba(15, 23, 42, 0.12) 50%,
		rgba(15, 23, 42, 0.06) 100%);
	background-size: 200% 100%;
	animation: ucSearchShimmer 1.4s linear infinite;
}

.uc-search-skeleton__line--title {
	width: 65%;
	height: 16px;
}

.uc-search-skeleton__line--short {
	width: 40%;
}

/* ─── Empty / error ───────────────────────────────────────────── */
.uc-search-empty {
	padding: 28px 16px;
	text-align: center;
	color: var(--uc-search-muted);
	font-family: var(--urra-font-body, inherit);
	font-size: 14px;
	border: 1px dashed var(--uc-search-border);
	border-radius: var(--uc-search-card-radius);
}

.uc-search-empty p {
	margin: 0;
}

.uc-search-empty--error {
	color: #b91c1c;
	border-color: #fecaca;
	background: #fef2f2;
}

/* ─── Card tabla inline (reutiliza tabla.css del shortcode) ───── */
.uc-search-card--tabla {
	cursor: default;
}

.uc-search-card--tabla .uc-search-card__title {
	margin: 0 0 10px;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
}

#uc-search-modal .uc-search-tabla-host.urra-tabla {
	width: 100%;
	margin: 0;
	--tabla-card-bg: var(--uc-search-bg, #ffffff);
	--tabla-card-pad-x: 0;
	--tabla-card-pad-y: 0;
	--tabla-cell-pad-x: 0.625rem;
	--tabla-cell-pad-y: 0.5rem;
}

#uc-search-modal .uc-search-tabla-host .urra-tabla__scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

#uc-search-modal .uc-search-tabla-host table.urra-tabla__table {
	width: 100%;
}

#uc-search-modal .uc-search-tabla-host .urra-tabla__th,
#uc-search-modal .uc-search-tabla-host .urra-tabla__td {
	border: 0;
	margin: 0;
	padding: var(--tabla-cell-pad-y) var(--tabla-cell-pad-x);
}

#uc-search-modal .uc-search-tabla-host .urra-tabla__th {
	font-size: var(--tabla-header-size, 0.8125rem);
	font-weight: var(--tabla-header-weight, 500);
	color: var(--tabla-header-color, #64748b);
	border-bottom: 1px solid var(--tabla-row-divider, #e2e8f0);
}

#uc-search-modal .uc-search-tabla-host .urra-tabla__td {
	font-size: 0.875rem;
	border-bottom: 1px solid var(--tabla-row-divider, #e2e8f0);
}

#uc-search-modal .uc-search-tabla-host .urra-tabla__tbody .urra-tabla__tr:last-child .urra-tabla__td {
	border-bottom: none;
}

#uc-search-modal .uc-search-tabla__more-row .uc-search-tabla__more {
	color: var(--uc-search-muted);
	font-size: 12px;
	font-style: italic;
	text-align: center;
	border-bottom: none !important;
}

@media (max-width: 767px) {
	#uc-search-modal .urra-tabla--responsive-stack .uc-search-tabla__more::before {
		content: none;
		display: none;
	}

	#uc-search-modal .urra-tabla--responsive-stack .uc-search-tabla__more {
		display: block;
		text-align: center;
		padding: 0.5rem 0 0;
	}
}

/* ─── Animaciones ─────────────────────────────────────────────── */
@keyframes ucSearchOverlayIn {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes ucSearchOverlayOut {
	from { opacity: 1; }
	to   { opacity: 0; }
}

@keyframes ucSearchPanelIn {
	from { opacity: 0; transform: translateY(-12px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ucSearchSheetIn {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes ucSearchSheetOut {
	from { transform: translateY(0); }
	to   { transform: translateY(100%); }
}

@keyframes ucSearchShimmer {
	0%   { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}

/* ─── Reduced motion ──────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
	.uc-search-modal__overlay,
	.uc-search-modal__panel,
	.uc-search-skeleton__line,
	.uc-search-card--link,
	.uc-search-card__faq-icon,
	.uc-search-card__faq-icon::before,
	.uc-search-card__faq-icon::after {
		animation: none;
		transition: none;
	}
}

/* ─── Mobile fine-tuning (bottom sheet) ───────────────────────── */
@media (max-width: 600px) {
	.uc-search-modal {
		padding: 0;
		align-items: flex-end;
	}

	.uc-search-modal__panel {
		width: 100%;
		height: auto;
		min-height: 80vh;
		max-height: 88vh;
		border-radius: 18px 18px 0 0;
		animation: ucSearchSheetIn 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
	}

	.uc-search-modal--closing .uc-search-modal__panel {
		animation: ucSearchSheetOut 360ms cubic-bezier(0.4, 0, 1, 1) forwards;
	}

	.uc-search-modal--closing .uc-search-modal__overlay {
		animation: ucSearchOverlayOut 360ms ease forwards;
	}

	.uc-search-modal--closing {
		pointer-events: none;
	}

	.uc-search-modal__intro {
		padding: 16px 56px 4px 16px;
	}

	.uc-search-modal__heading {
		font-size: 24px;
	}

	.uc-search-modal__lead {
		font-size: 16px;
	}

	.uc-search-modal__searchbar {
		padding: 14px 56px 14px 16px;
	}

	.uc-search-modal__hint {
		padding: 14px 16px;
	}

	.uc-search-modal__results {
		padding: 12px 16px 16px;
	}

	.uc-search-modal__close {
		top: 10px;
		right: 10px;
		width: 40px;
		height: 40px;
	}
}
