/**
 * Command Palette — pill in header (iteración 1: nav-only, no popover).
 *
 * Mobile-first. Collapsed pill = round icon button.
 * Expanded pill (after scrolling past hero on home, or from y=0 elsewhere)
 *   = full-width input-like bar with placeholder text.
 * Desktop ≥900px: always expanded as compact pill with text.
 *
 * Lucide icons inline. No build tools. No :has().
 */

/* ─── Container ─────────────────────────────────────────────────────── */

.rl-palette {
	position: relative;
	display: flex;
	align-items: center;
	min-width: 0;
	flex: 1 1 auto;
}

/* ─── Pill button (mobile collapsed = round 40×40) ──────────────────── */

.rl-palette__pill {
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	height: 40px;
	width: 40px;
	padding: 0;
	border: 1px solid #fff;
	background: #fff;
	border-radius: var(--rl-radius-pill, 999px);
	color: var(--rl-text-body, #3d3d3d);
	font: inherit;
	font-size: 0.9375rem;
	line-height: 1;
	cursor: pointer;
	transition:
		width var(--rl-transition-base, 200ms ease),
		padding var(--rl-transition-base, 200ms ease),
		border-color var(--rl-transition-fast, 150ms ease),
		background var(--rl-transition-fast, 150ms ease),
		box-shadow var(--rl-transition-fast, 150ms ease);
	overflow: hidden;
	white-space: nowrap;
}

.rl-palette__pill:hover {
	border-color: var(--rl-border-focus, #00b67a);
	background: var(--rl-bg-page, #f9f7f2);
}

.rl-palette__pill:focus-visible {
	outline: 2px solid var(--rl-border-focus, #00b67a);
	outline-offset: 2px;
}

/* Icon */
.rl-palette__icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--rl-text-muted, #6b7280);
	transition: color var(--rl-transition-fast, 150ms ease);
}

.rl-palette__pill:hover .rl-palette__icon {
	color: var(--rl-border-focus, #00b67a);
}

/* Text (hidden by default in mobile collapsed) */
.rl-palette__pill-text {
	display: none;
	color: var(--rl-text-muted, #6b7280);
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	min-width: 0;
}

/* ─── Mobile: pill colapsado (40×40) → al scroll se expande, pero deja
       sitio a la hamburguesa (actions crece, el toggle no se aplasta) ──── */

.rl-header.is-scrolled .rl-header__actions {
	flex: 1 1 auto;
	min-width: 0;
}

.rl-header.is-scrolled .rl-palette {
	flex: 1 1 auto;
	min-width: 0;
}

.rl-header.is-scrolled .rl-palette__pill {
	width: 100%;
	max-width: 100%;
	padding: 0 1rem 0 0.875rem;
	justify-content: flex-start;
}

.rl-header.is-scrolled .rl-palette__pill-text {
	display: inline;
}

/* ─── Desktop ≥900px: pill compacto y ESTÁTICO (sin transformarse al scroll) ──── */

@media (min-width: 900px) {

	.rl-palette {
		flex: 0 0 auto;
	}

	.rl-palette__pill {
		width: auto;
		min-width: 0;
		max-width: 320px;
		padding: 0 0.75rem;
		gap: 0.4375rem;
		height: 28px;
		justify-content: flex-start;
		font-size: 0.8125rem;
	}

	/* Icono más chico en el pill delgado de desktop */
	.rl-palette__pill .rl-palette__icon svg {
		width: 16px;
		height: 16px;
	}

	.rl-palette__pill-text {
		display: inline;
		font-size: 0.8125rem;
	}

	/* Al scroll en desktop el header no se transforma: pill y actions estables. */
	.rl-header.is-scrolled .rl-header__actions,
	.rl-header.is-scrolled .rl-palette {
		flex: 0 0 auto;
	}

	.rl-header.is-scrolled .rl-palette__pill {
		width: auto;
		max-width: 320px;
		padding: 0 0.875rem;
	}
}

/* ─── Desktop compacto 900-1199px: solo ícono para dar espacio al nav de 7 items ── */

@media (min-width: 900px) and (max-width: 1199px) {

	.rl-palette__pill {
		width: 36px;
		min-width: 36px;
		max-width: 36px;
		height: 36px;
		padding: 0;
		justify-content: center;
	}

	.rl-palette__pill-text {
		display: none;
	}

	.rl-palette__pill .rl-palette__icon svg {
		width: 18px;
		height: 18px;
	}

	.rl-header.is-scrolled .rl-palette__pill {
		width: 36px;
		min-width: 36px;
		max-width: 36px;
		padding: 0;
	}
}

/* ─── Popover ────────────────────────────────────────────────────────── */

.rl-palette__popover {
	position: fixed;
	top: calc(var(--rl-header-height, 68px) + 8px);
	left: 0.5rem;
	right: 0.5rem;
	max-width: none;
	max-height: calc(100vh - var(--rl-header-height, 68px) - 24px);
	overflow-y: auto;
	background: var(--rl-bg-white, #fff);
	border: 1px solid var(--rl-border-warm, #e8e5df);
	border-radius: 16px;
	box-shadow: var(--rl-shadow-lg, 0 20px 60px rgba(0, 0, 0, 0.18));
	z-index: var(--rl-z-dropdown, 800);
	animation: rl-palette-fade-in 180ms ease-out;
	padding: 0.5rem;
}

@keyframes rl-palette-fade-in {

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

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Searchbar (input + close) */
.rl-palette__searchbar {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	padding: 0.625rem 0.75rem 0.5rem;
	border-bottom: 1px solid var(--rl-border-warm, #e8e5df);
}

.rl-palette__searchbar-icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--rl-text-muted, #6b7280);
}

.rl-palette__input {
	flex: 1;
	min-width: 0;
	appearance: none;
	background: transparent;
	border: 0;
	outline: 0;
	padding: 0.375rem 0;
	font: inherit;
	font-size: 0.9375rem;
	color: var(--rl-text-headline, #191919);
	line-height: 1.4;
}

.rl-palette__input::placeholder {
	color: var(--rl-text-muted, #6b7280);
	opacity: 1;
}

.rl-palette__input:focus-visible {
	outline: none;
}

.rl-palette__close {
	appearance: none;
	background: transparent;
	border: 0;
	border-radius: var(--rl-radius-sm, 6px);
	padding: 0.375rem;
	color: var(--rl-text-muted, #6b7280);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background var(--rl-transition-fast, 150ms ease), color var(--rl-transition-fast, 150ms ease);
	flex-shrink: 0;
}

.rl-palette__close:hover {
	background: var(--rl-bg-page, #f9f7f2);
	color: var(--rl-text-headline, #191919);
}

.rl-palette__close:focus-visible {
	outline: 2px solid var(--rl-border-focus, #00b67a);
	outline-offset: 2px;
}

/* Group heading (Atajos / Productos / Guías / etc.) */
.rl-palette__group-heading {
	font-size: 0.6875rem;
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--rl-text-muted, #6b7280);
	padding: 0.75rem 0.875rem 0.375rem;
	user-select: none;
}

/* Status row (loading / error / no results / too short) */
.rl-palette__status {
	padding: 0.875rem 0.875rem;
	font-size: 0.875rem;
	color: var(--rl-text-muted, #6b7280);
	text-align: center;
}

.rl-palette__status.is-loading::before {
	content: "";
	display: inline-block;
	width: 12px;
	height: 12px;
	margin-right: 0.5rem;
	vertical-align: -2px;
	border: 2px solid currentcolor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: rl-palette-spin 700ms linear infinite;
}

@keyframes rl-palette-spin {

	to {
		transform: rotate(360deg);
	}
}

.rl-palette__status.is-error {
	color: #b1402c;
}

/* Match highlight */
.rl-palette__mark {
	background: rgba(245, 215, 66, 0.45);
	color: inherit;
	font-weight: 600;
	padding: 0 0.125em;
	border-radius: 3px;
}

/* Items list */
.rl-palette__list {
	list-style: none;
	margin: 0;
	padding: 0.25rem;
	display: flex;
	flex-direction: column;
	gap: 2px;
	max-height: calc(70vh - 80px);
	overflow-y: auto;
	overscroll-behavior: contain;
}

.rl-palette__item {
	display: flex;
	align-items: center;
	gap: 0.875rem;
	padding: 0.625rem 0.75rem;
	background: transparent;
	border: 1px solid transparent;
	border-radius: 10px;
	color: var(--rl-text-body, #3d3d3d);
	font: inherit;
	font-size: 0.9375rem;
	line-height: 1.3;
	text-decoration: none;
	cursor: pointer;
	transition: background var(--rl-transition-fast, 150ms ease), border-color var(--rl-transition-fast, 150ms ease);
	text-align: left;
	width: 100%;
}

.rl-palette__item:hover {
	background: var(--rl-bg-page, #f9f7f2);
}

.rl-palette__item.is-active,
.rl-palette__item:focus-visible {
	outline: none;
	background: var(--rl-bg-page, #f9f7f2);
	border-color: var(--rl-border-focus, #00b67a);
}

.rl-palette__item-icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: var(--rl-radius-sm, 6px);
	background: var(--rl-bg-page, #f9f7f2);
	color: var(--rl-text-muted, #6b7280);
}

.rl-palette__item-body {
	display: flex;
	flex-direction: column;
	gap: 1px;
	min-width: 0;
	flex: 1;
}

.rl-palette__item-label {
	font-weight: 500;
	color: var(--rl-text-headline, #191919);
	font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
	font-size: 0.875rem;
	letter-spacing: -0.01em;
}

.rl-palette__item-hint {
	font-size: 0.8125rem;
	color: var(--rl-text-muted, #6b7280);
}

/* Highlighted item (Mia) */
.rl-palette__item.is-highlight {
	background: rgba(0, 182, 122, 0.06);
	border-color: rgba(0, 182, 122, 0.16);
}

.rl-palette__item.is-highlight .rl-palette__item-icon {
	background: rgba(0, 182, 122, 0.14);
	color: var(--rl-border-focus, #00b67a);
}

.rl-palette__item.is-highlight:hover,
.rl-palette__item.is-highlight:focus-visible,
.rl-palette__item.is-highlight.is-active {
	background: rgba(0, 182, 122, 0.1);
	border-color: var(--rl-border-focus, #00b67a);
}

.rl-palette__item-label {
	display: block;
}

.rl-palette__item-hint {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Desktop popover anchored to pill */
@media (min-width: 900px) {

	.rl-palette__popover {
		position: absolute;
		top: calc(100% + 8px);
		right: 0;
		left: auto;
		width: 380px;
		max-width: 380px;
		max-height: 70vh;
	}
}

/* ─── Hero variant ─────────────────────────────────────────────────── */

.rl-palette--hero {
	flex: 0 0 auto;
	width: 100%;
	max-width: 100%;
	margin: 2rem auto 0;
	position: relative;
}

.rl-palette__hero-bar {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 1rem 1.125rem 1rem 1.25rem;
	background: var(--rl-bg-white, #fff);
	border: 1px solid var(--rl-border-warm, #e8e5df);
	border-radius: 24px;
	box-shadow: 0 2px 8px rgba(22, 38, 59, 0.06), 0 0 0 1px rgba(22, 38, 59, 0.04);
	transition: border-color var(--rl-transition-fast, 150ms ease), box-shadow var(--rl-transition-fast, 150ms ease);
}

.rl-palette--hero[data-state="open"] .rl-palette__hero-bar,
.rl-palette__hero-bar:focus-within {
	border-color: var(--rl-border-focus, #00b67a);
	box-shadow: 0 0 0 4px rgba(0, 182, 122, 0.12), var(--rl-shadow-card-hover, 0 8px 24px rgba(0, 0, 0, 0.12));
}

.rl-palette__hero-icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: var(--rl-text-muted, #6b7280);
}

.rl-palette__hero-bar:focus-within .rl-palette__hero-icon {
	color: var(--rl-border-focus, #00b67a);
}

.rl-palette__input--hero {
	flex: 1;
	min-width: 0;
	appearance: none;
	background: transparent;
	border: 0;
	outline: 0;
	padding: 0;
	font: inherit;
	font-size: 1.0625rem;
	color: var(--rl-text-headline, #191919);
	line-height: 1.4;
}

.rl-palette__input--hero::placeholder {
	color: var(--rl-text-muted, #6b7280);
	opacity: 1;
}

/* Dropdown panel anchored under hero input */
.rl-palette__hero-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	background: var(--rl-bg-white, #fff);
	border: 1px solid var(--rl-border-warm, #e8e5df);
	border-radius: 16px;
	box-shadow: var(--rl-shadow-lg, 0 20px 60px rgba(0, 0, 0, 0.18));
	z-index: var(--rl-z-dropdown, 800);
	padding: 0.5rem;
	max-height: 60vh;
	overflow-y: auto;
	animation: rl-palette-fade-in 180ms ease-out;
}

@media (max-width: 639px) {

	.rl-palette--hero {
		margin-top: 1.25rem;
	}

	.rl-palette__hero-bar {
		padding: 0.75rem 0.875rem 0.75rem 1rem;
		border-radius: 16px;
	}

	.rl-palette__input--hero {
		font-size: 1rem;
	}
}

/* ─── Mobile inline nav-bar (shown inside nav when search opens on mobile) ── */

.rl-palette__nav-bar {
	display: none;
	align-items: center;
	gap: 0.5rem;
	flex: 1 1 auto;
	min-width: 0;
}

.rl-palette__nav-icon {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	color: rgba(255, 255, 255, 0.5);
}

.rl-palette__input--nav {
	flex: 1;
	min-width: 0;
	appearance: none;
	background: transparent;
	border: 0;
	outline: 0;
	padding: 0.25rem 0;
	font: inherit;
	font-size: 0.9375rem;
	color: #fff;
	line-height: 1.4;
}

.rl-palette__input--nav::placeholder {
	color: rgba(255, 255, 255, 0.4);
	opacity: 1;
}

.rl-palette__input--nav:focus-visible {
	outline: none;
}

.rl-palette__nav-close {
	appearance: none;
	background: transparent;
	border: 0;
	padding: 0.375rem;
	color: rgba(255, 255, 255, 0.55);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	transition: background var(--rl-transition-fast, 150ms ease), color var(--rl-transition-fast, 150ms ease);
	flex-shrink: 0;
}

.rl-palette__nav-close:hover {
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
}

.rl-palette__nav-close:focus-visible {
	outline: 2px solid rgba(255, 255, 255, 0.5);
	outline-offset: 2px;
}

/* Mobile: swap pill ↔ nav-bar when open */
@media (max-width: 899px) {

	.rl-palette[data-state="open"] .rl-palette__pill {
		display: none;
	}

	.rl-palette[data-state="open"] .rl-palette__nav-bar {
		display: flex;
	}

	/* Mobile popover: listbox only, no searchbar header, flush under nav */
	.rl-palette__popover--mobile {
		position: fixed;
		top: var(--rl-header-height, 68px);
		left: 0;
		right: 0;
		border-radius: 0 0 16px 16px;
		border-top: 1px solid rgba(255, 255, 255, 0.06);
		max-height: calc(100vh - var(--rl-header-height, 68px) - 16px);
	}
}

/* ─── Reduced motion ────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {

	.rl-palette__pill,
	.rl-palette__icon,
	.rl-palette__popover,
	.rl-palette__item,
	.rl-palette__close {
		transition: none;
		animation: none;
	}
}
