/**
 * Buscador de hubs — componente reutilizable por sección.
 * Colores: definir en el contenedor padre o con --hub-search-primary.
 */

.jursoc-hub-search {
	--hub-search-primary: var(--claustro-primary, #003366);
	--hub-search-dark: var(--claustro-dark, #001a33);
	--hub-search-accent: var(--claustro-accent, #0d9488);
	--hub-search-radius: var(--claustro-radius, 14px);
	--hub-search-surface: #fff;
	--hub-search-border: color-mix(in srgb, var(--hub-search-primary) 14%, #e2e8f0);
	--hub-search-glow: color-mix(in srgb, var(--hub-search-primary) 16%, transparent);
	margin-bottom: clamp(1.25rem, 2.5vw, 1.75rem);
}

.jursoc-hub-search--sticky {
	position: sticky;
	top: 0;
	z-index: 25;
	padding: clamp(0.65rem, 1.5vw, 0.85rem) 0 clamp(0.5rem, 1vw, 0.65rem);
	background: linear-gradient(
		180deg,
		#fff 0%,
		#fff 70%,
		color-mix(in srgb, #fff 90%, transparent) 100%
	);
	backdrop-filter: blur(10px);
}

.jursoc-hub-search__panel {
	position: relative;
	padding: clamp(1rem, 2.2vw, 1.25rem) clamp(1.1rem, 2.5vw, 1.35rem);
	border: 1px solid var(--hub-search-border);
	border-radius: var(--hub-search-radius);
	background: var(--hub-search-surface);
	box-shadow:
		0 1px 2px rgba(15, 23, 42, 0.04),
		0 10px 32px color-mix(in srgb, var(--hub-search-primary) 8%, transparent);
	overflow: hidden;
}

.jursoc-hub-search__panel::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0;
	bottom: 0;
	width: 4px;
	background: linear-gradient(
		180deg,
		var(--hub-search-accent) 0%,
		var(--hub-search-primary) 100%
	);
}

.jursoc-hub-search__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	margin-bottom: 0.65rem;
}

.jursoc-hub-search__label {
	margin: 0;
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--hub-search-primary);
}

.jursoc-hub-search__shortcut {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
}

.jursoc-hub-search__kbd {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 1.5rem;
	height: 1.5rem;
	padding: 0 0.35rem;
	border: 1px solid color-mix(in srgb, var(--hub-search-primary) 20%, #cbd5e1);
	border-radius: 6px;
	background: linear-gradient(180deg, #fff 0%, #f1f5f9 100%);
	box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
	font-family: inherit;
	font-size: 0.72rem;
	font-weight: 700;
	line-height: 1;
	color: #64748b;
}

.jursoc-hub-search__field {
	position: relative;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 0.65rem 0.5rem 0.85rem;
	border: 2px solid color-mix(in srgb, var(--hub-search-primary) 18%, #e2e8f0);
	border-radius: 12px;
	background: #f8fafc;
	transition:
		border-color 0.2s ease,
		background 0.2s ease,
		box-shadow 0.2s ease;
}

.jursoc-hub-search__field:focus-within {
	border-color: var(--hub-search-primary);
	background: #fff;
	box-shadow:
		0 0 0 4px var(--hub-search-glow),
		0 6px 20px color-mix(in srgb, var(--hub-search-primary) 10%, transparent);
}

.jursoc-hub-search.is-active .jursoc-hub-search__field {
	border-color: color-mix(in srgb, var(--hub-search-primary) 55%, #e2e8f0);
	background: #fff;
}

.jursoc-hub-search__icon {
	display: flex;
	flex-shrink: 0;
	color: var(--hub-search-primary);
	opacity: 0.9;
	transition: transform 0.2s ease;
}

.jursoc-hub-search__field:focus-within .jursoc-hub-search__icon {
	transform: scale(1.05);
}

.jursoc-hub-search__input {
	flex: 1;
	min-width: 0;
	border: none;
	background: transparent;
	font-size: clamp(1rem, 2vw, 1.06rem);
	line-height: 1.45;
	color: #0f172a;
}

.jursoc-hub-search__input::placeholder,
.jursoc-hub-search__input::-webkit-input-placeholder,
.jursoc-hub-search__input::-moz-placeholder {
	color: #64748b;
	opacity: 1;
}

.jursoc-hub-search__input:focus {
	outline: none;
}

/* Placeholder visual de respaldo (Safari / type search legacy) */
.jursoc-hub-search__ghost {
	position: absolute;
	left: 2.85rem;
	right: 2.75rem;
	pointer-events: none;
	font-size: clamp(1rem, 2vw, 1.06rem);
	line-height: 1.45;
	color: #64748b;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: opacity 0.15s ease;
}

.jursoc-hub-search__field.is-focused .jursoc-hub-search__ghost,
.jursoc-hub-search__field.has-value .jursoc-hub-search__ghost {
	opacity: 0;
	visibility: hidden;
}

.jursoc-hub-search__field.is-empty:not(.is-focused) .jursoc-hub-search__input::placeholder {
	color: transparent;
}

.jursoc-hub-search__clear {
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 2.15rem;
	height: 2.15rem;
	padding: 0;
	border: none;
	border-radius: 10px;
	background: color-mix(in srgb, var(--hub-search-primary) 10%, #e2e8f0);
	color: #475569;
	cursor: pointer;
	transition:
		background 0.2s ease,
		color 0.2s ease,
		transform 0.15s ease;
}

.jursoc-hub-search__clear:hover,
.jursoc-hub-search__clear:focus-visible {
	background: color-mix(in srgb, var(--hub-search-primary) 18%, #f1f5f9);
	color: var(--hub-search-dark);
	transform: scale(1.04);
}

.jursoc-hub-search__clear:focus-visible {
	outline: 2px solid var(--hub-search-primary);
	outline-offset: 2px;
}

.jursoc-hub-search__helpers {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	justify-content: space-between;
	gap: 0.5rem 1rem;
	margin-top: 0.55rem;
}

.jursoc-hub-search__hint {
	margin: 0;
	flex: 1 1 12rem;
	min-width: 0;
	font-size: 0.84rem;
	line-height: 1.45;
	color: #64748b;
}

.jursoc-hub-search__kbd-tips {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.35rem 0.65rem;
	margin: 0;
	padding: 0;
	list-style: none;
	flex-shrink: 0;
}

.jursoc-hub-search__kbd-tip {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	font-size: 0.72rem;
	color: #94a3b8;
}

.jursoc-hub-search__kbd--inline {
	min-width: 1.35rem;
	height: 1.35rem;
	padding: 0 0.3rem;
	font-size: 0.65rem;
}

.jursoc-hub-search__suggestions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.45rem 0.55rem;
	margin-top: 0.75rem;
	padding-top: 0.75rem;
	border-top: 1px dashed color-mix(in srgb, var(--hub-search-primary) 16%, #e2e8f0);
}

.jursoc-hub-search__suggestions-label {
	font-size: 0.72rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.08em;
	color: #94a3b8;
	flex-shrink: 0;
}

.jursoc-hub-search__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem;
}

.jursoc-hub-search__chip {
	display: inline-flex;
	align-items: center;
	padding: 0.3rem 0.75rem;
	border: 1px solid color-mix(in srgb, var(--hub-search-primary) 22%, #e2e8f0);
	border-radius: 999px;
	background: #fff;
	color: var(--hub-search-dark);
	font-family: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition:
		background 0.2s ease,
		border-color 0.2s ease,
		color 0.2s ease,
		transform 0.15s ease,
		box-shadow 0.2s ease;
}

.jursoc-hub-search__chip:hover:not(:disabled),
.jursoc-hub-search__chip:focus-visible:not(:disabled) {
	border-color: var(--hub-search-primary);
	background: color-mix(in srgb, var(--hub-search-primary) 8%, #fff);
	color: var(--hub-search-primary);
	transform: translateY(-1px);
	box-shadow: 0 3px 10px color-mix(in srgb, var(--hub-search-primary) 12%, transparent);
}

.jursoc-hub-search__chip:focus-visible {
	outline: 2px solid var(--hub-search-accent);
	outline-offset: 2px;
}

.jursoc-hub-search__chip.is-suggested-active {
	border-color: var(--hub-search-accent);
	background: color-mix(in srgb, var(--hub-search-accent) 12%, #fff);
	color: var(--hub-search-dark);
}

.jursoc-hub-search__chip:disabled {
	opacity: 0.55;
	cursor: default;
}

.jursoc-hub-search__status {
	display: flex;
	align-items: center;
	gap: 0.45rem;
	min-height: 1.35rem;
	margin-top: 0.55rem;
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--hub-search-dark);
}

.jursoc-hub-search__idle {
	color: #64748b;
	font-weight: 500;
}

.jursoc-hub-search__idle:empty {
	display: none;
}

.jursoc-hub-search__meta[hidden],
.jursoc-hub-search__meta:empty {
	display: none;
}

.jursoc-hub-search.is-active .jursoc-hub-search__idle {
	display: none;
}

.jursoc-hub-search__status-dot {
	width: 0.45rem;
	height: 0.45rem;
	border-radius: 50%;
	background: #cbd5e1;
	flex-shrink: 0;
	transition: background 0.2s ease, box-shadow 0.2s ease;
}

.jursoc-hub-search.is-active .jursoc-hub-search__status-dot {
	background: var(--hub-search-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--hub-search-accent) 35%, transparent);
}

.jursoc-hub-search.is-searching .jursoc-hub-search__status-dot {
	animation: jursoc-hub-search-pulse 0.9s ease-in-out infinite;
}

@keyframes jursoc-hub-search-pulse {
	0%, 100% { opacity: 1; transform: scale(1); }
	50% { opacity: 0.55; transform: scale(0.85); }
}

.jursoc-hub-search.is-busy .jursoc-hub-search__meta {
	color: #64748b;
	font-weight: 500;
}

.jursoc-hub-search__empty {
	margin-top: 0.85rem;
}

.jursoc-hub-search__empty-inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.85rem;
	padding: clamp(1.35rem, 3.5vw, 2rem);
	border: 2px dashed color-mix(in srgb, var(--hub-search-primary) 28%, #cbd5e1);
	border-radius: var(--hub-search-radius);
	background: linear-gradient(
		155deg,
		color-mix(in srgb, var(--hub-search-primary) 4%, #fff) 0%,
		#f8fafc 100%
	);
	text-align: center;
}

.jursoc-hub-search__empty-icon {
	color: var(--hub-search-primary);
	opacity: 0.5;
}

.jursoc-hub-search__empty-text {
	margin: 0;
	max-width: 30rem;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.45;
	color: #334155;
}

.jursoc-hub-search__empty-tips {
	width: 100%;
	max-width: 26rem;
	text-align: left;
}

.jursoc-hub-search__empty-tips-title {
	margin: 0 0 0.4rem;
	font-size: 0.72rem;
	font-weight: 800;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--hub-search-primary);
}

.jursoc-hub-search__empty-tips-list {
	margin: 0;
	padding-left: 1.15rem;
	font-size: 0.88rem;
	line-height: 1.5;
	color: #64748b;
}

.jursoc-hub-search__empty-tips-list li + li {
	margin-top: 0.25rem;
}

.jursoc-hub-search__empty-chips {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.4rem;
}

.jursoc-hub-search.is-active .jursoc-hub-search__suggestions {
	opacity: 0.65;
	pointer-events: none;
}

.jursoc-hub-search__reset {
	padding: 0.55rem 1.2rem;
	border: none;
	border-radius: 999px;
	background: var(--hub-search-primary);
	color: #fff;
	font-size: 0.88rem;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.jursoc-hub-search__reset:hover,
.jursoc-hub-search__reset:focus-visible {
	background: var(--hub-search-dark);
	transform: translateY(-1px);
	box-shadow: 0 6px 18px color-mix(in srgb, var(--hub-search-primary) 35%, transparent);
}

.jursoc-hub-search__reset:focus-visible {
	outline: 2px solid var(--hub-search-accent);
	outline-offset: 3px;
}

/* Resaltado en resultados (consumido por JS de cada hub) */
mark.jursoc-hub-search__mark {
	padding: 0 0.12em;
	border-radius: 0.15em;
	background: color-mix(in srgb, var(--hub-search-accent) 32%, #fef9c3);
	color: inherit;
	font-weight: inherit;
}

@media (max-width: 640px) {
	.jursoc-hub-search__shortcut {
		display: none;
	}

	.jursoc-hub-search__panel {
		padding-left: 1rem;
		padding-right: 1rem;
	}

	.jursoc-hub-search__helpers {
		flex-direction: column;
		align-items: stretch;
	}

	.jursoc-hub-search__kbd-tips {
		justify-content: flex-start;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jursoc-hub-search__status-dot,
	.jursoc-hub-search__icon,
	.jursoc-hub-search__clear,
	.jursoc-hub-search__reset {
		animation: none;
		transition: none;
	}
}
