/**
 * Barra sticky (búsqueda + enlaces), independiente del header principal.
 */

.nj-sticky-header {
	--nj-sticky-bg: #007a55;
	--nj-sticky-fg: #ffffff;
	--nj-sticky-pill-text: #1a2b4c;
	--nj-sticky-placeholder: #ffffff;

	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 99990;
	display: flex;
	align-items: center;
	box-sizing: border-box;
	min-height: 59px;
	padding: 0;
	margin: 0;
	background: var(--nj-sticky-bg);
	color: var(--nj-sticky-fg);
	font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-100%);
	transition: opacity 0.35s ease, transform 0.35s ease, visibility 0.35s ease;
	pointer-events: none;
}

.nj-sticky-header.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

/* Altura de la barra (JS la actualiza; fallback para layout antes de pintar) */
body.nj-sticky-header-below {
	--nj-sticky-bar-height: 59px;
	--nj-sticky-bar-offset-top: 0px;
}

body.admin-bar.nj-sticky-header-below {
	--nj-sticky-bar-offset-top: 32px;
}

/* Visible bajo #masthead en todo el sitio excepto portada; position:sticky al hacer scroll */
body.nj-sticky-header-below .nj-sticky-header,
body.nj-sticky-header-below .nj-sticky-header.nj-sticky-header--catalog,
body.farmacia-cat-archive-active .nj-sticky-header,
body.farmacia-cat-archive-active .nj-sticky-header.nj-sticky-header--catalog {
	position: sticky;
	top: 0;
	left: auto;
	right: auto;
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
}

body.admin-bar.nj-sticky-header-below .nj-sticky-header,
body.admin-bar.nj-sticky-header-below .nj-sticky-header.nj-sticky-header--catalog,
body.admin-bar.farmacia-cat-archive-active .nj-sticky-header,
body.admin-bar.farmacia-cat-archive-active .nj-sticky-header.nj-sticky-header--catalog {
	top: 32px;
}

/* Astra aplica #primary { margin: 4em 0 } — quitar hueco bajo nj-sticky-header */
body.nj-sticky-header-below #primary,
body.nj-sticky-header-below .site-content > .ast-container #primary {
	margin-top: 0 !important;
	margin-bottom: 0 !important;
}

.admin-bar .nj-sticky-header {
	top: 32px;
}

@media screen and (max-width: 782px) {
	.admin-bar .nj-sticky-header {
		top: 46px;
	}

	body.admin-bar.nj-sticky-header-below {
		--nj-sticky-bar-offset-top: 46px;
	}

	body.admin-bar.nj-sticky-header-below .nj-sticky-header,
	body.admin-bar.nj-sticky-header-below .nj-sticky-header.nj-sticky-header--catalog,
	body.admin-bar.farmacia-cat-archive-active .nj-sticky-header,
	body.admin-bar.farmacia-cat-archive-active .nj-sticky-header.nj-sticky-header--catalog {
		top: 46px;
	}
}

.nj-sticky-header__inner {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	width: 100%;
	max-width: 1240px;
	min-height: 59px;
	padding: 15px 17px;
	margin: 0 auto;
}

.nj-sticky-header__pill {
	display: flex;
	flex-direction: row;
	align-items: stretch;
	flex: 1 1 auto;
	min-width: 0;
	max-width: min(930px, 100%);
	padding: 0;
	background: transparent;
	border-radius: 999px;
	box-sizing: border-box;
}

.nj-sticky-header__categories {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.35rem;
	flex-shrink: 0;
	height: 44px;
	box-sizing: border-box;
	padding: 0 1.25rem;
	margin: 0;
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-right: none;
	background: #ffffff;
	color: var(--nj-sticky-pill-text);
	font: inherit;
	font-size: clamp(0.875rem, 1.6vw, 1rem);
	font-weight: 700;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	border-radius: 999px 0 0 999px;
}

.nj-sticky-header__categories:hover,
.nj-sticky-header__categories:focus-visible {
	color: var(--nj-sticky-bg);
	outline: none;
}

.nj-sticky-header__categories:focus-visible {
	box-shadow: 0 0 0 2px var(--nj-sticky-bg);
	border-radius: 6px;
}

.nj-sticky-header__categories-chevron {
	flex-shrink: 0;
	opacity: 0.85;
}

.nj-sticky-header__divider {
	display: none;
}

.nj-sticky-header .nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search {
	flex: 0 0 450px;
	width: 450px;
	min-width: 450px;
	height: 44px;
	box-sizing: border-box;
	padding: 0 0.35rem 0 0.95rem !important;
	margin: 0;
	background: #037451;
	border: 1px solid rgba(255, 255, 255, 0.7);
	border-inline-start: none;
	border-radius: 0 999px 999px 0;
	display: flex;
	align-items: center;
}

.nj-sticky-header .nj-sticky-header__search-root .farmacia-product-search__form {
	max-width: none !important;
	width: 100%;
	height: 100%;
	margin: 0;
	display: flex;
	align-items: center;
}

.nj-sticky-header .nj-sticky-header__search-bar.farmacia-product-search__bar {
	display: grid;
	grid-template-columns: 1fr auto;
	align-items: center;
	gap: 0.35rem;
	width: 100%;
	height: 100%;
	min-height: 0 !important;
	max-height: 100%;
	padding: 0 !important;
	margin: 0 !important;
	background: transparent !important;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: #ffffff;
}

.nj-sticky-header .farmacia-product-search__input-wrap {
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	height: 100%;
	margin: 0;
	padding: 0;
}

.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__input {
	width: 100%;
	min-width: 0;
	max-width: 100% !important;
	height: 100%;
	margin: 0 !important;
	padding: 0 !important;
	font-size: clamp(0.875rem, 1vw, 1rem);
	font-weight: 600;
	line-height: 1;
	color: #eef8f4 !important;
	background: transparent;
	border: none;
	box-shadow: none;
	appearance: none;
	-webkit-appearance: none;
}

.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__input::-webkit-search-decoration,
.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__input::-webkit-search-cancel-button {
	display: none;
	-webkit-appearance: none;
}

/*
 * El bloque farmacia/product-search define ::placeholder con mayor especificidad
 * (color: inherit + opacity 0.88), por eso hay que igualar/ganar especificidad.
 */
.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__input::placeholder,
.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__input::-webkit-input-placeholder,
.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__input::-moz-placeholder {
	color: #ffffff !important;
	opacity: 1 !important;
}

.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__submit {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	margin: 0;
	padding: 0;
	color: #ffffff !important;
	background: transparent;
	border: none;
	border-radius: 999px;
	align-self: center;
}

.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__submit svg {
	display: block;
}

.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__submit svg,
.nj-sticky-header
	.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
	.farmacia-product-search__submit svg path {
	color: #ffffff !important;
	stroke: #ffffff !important;
	fill: none;
}

.nj-sticky-header .farmacia-product-search__suggestions {
	z-index: 99991;
}

/*
 * #masthead por encima de nj-sticky-header (99990) y por debajo de #wpadminbar (99999).
 * Un z-index > 99999 tapa los desplegables del admin bar.
 */
#masthead.site-header,
header.site-header {
	position: relative;
	z-index: 99995;
}

/*
 * Astra añade border-bottom: 1px en .ast-primary-header-bar (color claro).
 * nj-sticky-header va justo después de #masthead → se ve como raya blanca entre ambas barras.
 */
#masthead.site-header .ast-primary-header-bar,
#masthead.site-header .main-header-bar {
	border-bottom: none !important;
}

#masthead.site-header + .nj-sticky-header {
	margin-top: 0;
	border-top: none;
}

#masthead .site-header-primary-section-right,
#masthead .ast-builder-layout-element {
	overflow: visible;
}

.nj-sticky-header__nav {
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: flex-end;
	flex-shrink: 0;
	gap: clamp(0.65rem, 1.5vw, 1.35rem);
}

.nj-sticky-header__link {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.4rem;
	color: var(--nj-sticky-fg);
	font-size: clamp(0.8125rem, 1.5vw, 0.9rem);
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
	transition: opacity 0.15s ease;
}

.nj-sticky-header__link:hover,
.nj-sticky-header__link:focus-visible {
	opacity: 0.88;
	outline: none;
}

.nj-sticky-header__link:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.nj-sticky-header__link svg {
	display: block;
	flex-shrink: 0;
}

.nj-sticky-header__link-icon {
	display: block;
	flex-shrink: 0;
	width: 20px;
	height: 20px;
	object-fit: contain;
}

/* ——— Responsive ——— */

/* Tablet ancho: buscador flexible, nav en la misma fila */
@media (max-width: 1240px) {
	.nj-sticky-header__inner {
		padding-inline: clamp(12px, 2.5vw, 17px);
	}

	.nj-sticky-header .nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search {
		flex: 1 1 auto;
		width: auto;
		min-width: 0;
		max-width: min(450px, 100%);
	}
}

/* Tablet: pill ancho completo + atajos debajo */
@media (max-width: 1024px) {
	.nj-sticky-header__inner {
		flex-wrap: wrap;
		row-gap: 8px;
		min-height: auto;
	}

	.nj-sticky-header__pill {
		flex: 1 1 100%;
		max-width: 100%;
	}

	.nj-sticky-header__nav {
		flex: 1 1 100%;
		justify-content: center;
		flex-wrap: wrap;
		gap: 0.65rem 1.25rem;
	}
}

/* Móvil grande: una sola fila (pill + iconos) para reducir altura */
@media (max-width: 768px) {
	.nj-sticky-header {
		--nj-sticky-control-h: 34px;
		--nj-sticky-pad-y: 7px;
		min-height: calc(var(--nj-sticky-control-h) + (var(--nj-sticky-pad-y) * 2));
		height: auto;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.nj-sticky-header__inner,
	.nj-sticky-header__inner.ast-container {
		flex-wrap: nowrap;
		align-items: center;
		align-content: center;
		min-height: 0 !important;
		height: var(--nj-sticky-control-h);
		padding-block: 0 !important;
		padding-inline: 10px !important;
		margin-block: 0;
		gap: 6px;
	}

	.nj-sticky-header__pill {
		flex: 1 1 auto;
		min-width: 0;
		max-width: none;
		align-items: center;
		height: var(--nj-sticky-control-h);
	}

	.nj-sticky-header__categories {
		height: var(--nj-sticky-control-h);
		padding-inline: 0.65rem;
		font-size: 0.75rem;
		align-self: center;
	}

	.nj-sticky-header .nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search {
		flex: 1 1 auto;
		width: auto;
		min-width: 0;
		max-width: none;
		height: var(--nj-sticky-control-h) !important;
		max-height: var(--nj-sticky-control-h);
		padding: 0 0.15rem 0 0.5rem !important;
		align-self: center;
	}

	.nj-sticky-header
		.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
		.farmacia-product-search__form,
	.nj-sticky-header
		.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
		.farmacia-product-search__bar {
		height: 100% !important;
		min-height: 0 !important;
		max-height: 100% !important;
	}

	.nj-sticky-header
		.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
		.farmacia-product-search__input {
		font-size: 0.8125rem;
		font-weight: 600;
		line-height: var(--nj-sticky-control-h);
		height: 100%;
	}

	.nj-sticky-header
		.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
		.farmacia-product-search__submit {
		width: 26px;
		height: 26px;
		align-self: center;
	}

	.nj-sticky-header
		.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
		.farmacia-product-search__submit svg {
		width: 18px;
		height: 18px;
	}

	.nj-sticky-header__nav {
		flex: 0 0 auto;
		align-self: center;
		width: auto;
		height: var(--nj-sticky-control-h);
		justify-content: flex-end;
		align-items: center;
		flex-wrap: nowrap;
		gap: 0.15rem;
		overflow: visible;
		padding: 0;
		margin: 0;
	}

	.nj-sticky-header__link {
		position: relative;
		flex: 0 0 auto;
		align-items: center;
		justify-content: center;
		width: var(--nj-sticky-control-h);
		height: var(--nj-sticky-control-h);
		min-width: var(--nj-sticky-control-h);
		min-height: var(--nj-sticky-control-h);
		padding: 0;
		margin: 0;
		font-size: 0;
		gap: 0;
	}

	.nj-sticky-header__link svg,
	.nj-sticky-header__link-icon {
		display: block;
		width: 18px;
		height: 18px;
		margin: 0;
	}

	.nj-sticky-header__link-text {
		position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}
}

/* Móvil pequeño: aún más compacto */
@media (max-width: 480px) {
	.nj-sticky-header {
		--nj-sticky-control-h: 32px;
		--nj-sticky-pad-y: 6px;
	}

	.nj-sticky-header__inner,
	.nj-sticky-header__inner.ast-container {
		padding-inline: 8px !important;
		gap: 4px;
	}

	.nj-sticky-header__categories {
		padding-inline: 0.45rem;
	}

	.nj-sticky-header__categories-chevron {
		width: 10px;
		height: 10px;
	}

	.nj-sticky-header
		.nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search
		.farmacia-product-search__input {
		font-size: 0.75rem;
		line-height: var(--nj-sticky-control-h);
	}

	.nj-sticky-header__nav {
		gap: 0;
	}

	.nj-sticky-header__link svg,
	.nj-sticky-header__link-icon {
		width: 17px;
		height: 17px;
	}
}

/* Pantallas muy estrechas */
@media (max-width: 360px) {
	.nj-sticky-header {
		--nj-sticky-control-h: 30px;
		--nj-sticky-pad-y: 5px;
	}

	.nj-sticky-header__inner,
	.nj-sticky-header__inner.ast-container {
		padding-inline: 6px !important;
	}

	.nj-sticky-header__categories {
		padding-inline: 0.35rem;
	}

	.nj-sticky-header .nj-sticky-header__search-root.wp-block-farmacia-product-search.farmacia-product-search {
		padding-inline-start: 0.35rem !important;
	}
}

/* Móvil: categorías solo flecha (texto accesible vía aria-label) */
@media (max-width: 480px) {
	.nj-sticky-header__categories-label {
		position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border: 0;
	}

	.nj-sticky-header__categories:not(:has(.nj-sticky-header__categories-chevron)) {
		min-width: 2rem;
		justify-content: center;
	}

	.nj-sticky-header__categories {
		justify-content: center;
	}
}

/* Mi perfil: menú lateral fijo en la parte inferior (sin offset del sticky superior). */