/**
 * Header section.
 *
 * @package Pharmacy
 */

.ph-section--main-header {
	padding: 0 !important;
	z-index: 50;
}

.ph-header {
	display: grid;
	grid-template-columns: auto 1fr auto;
	grid-template-areas: "logo search actions";
	align-items: center;
	gap: 20px;
	min-height: var(--hdr-h, 76px);
	background: var(--pharmacy-header-bg);
	color: var(--pharmacy-header-text);
}

.ph-header--compact { grid-template-areas: "logo nav actions"; }
.ph-header--logo-center { grid-template-areas: "search logo actions" "nav nav nav"; }

.ph-header__logo { grid-area: logo; }
.ph-header__nav { grid-area: nav; }

.ph-header__search {
	grid-area: search;
	width: 100%;
	max-width: 560px;
	justify-self: center;
}

.ph-header__actions {
	grid-area: actions;
	display: flex;
	align-items: center;
	gap: 6px;
}

.ph-header--logo-left .ph-header__nav { display: none; }
.ph-header--compact .ph-header__search { display: none; }

.ph-header.is-sticky {
	position: sticky;
	top: 0;
	transition: transform 240ms ease, box-shadow 240ms ease;
}

.ph-header.is-stuck { box-shadow: 0 2px 16px rgba(11, 31, 51, 0.09); }
.ph-header.is-hidden { transform: translateY(-100%); }

.ph-header.is-transparent {
	position: absolute;
	inset-inline: 0;
	background: transparent;
	color: #fff;
}

/* --- Logo ---------------------------------------------------------------- */

.ph-logo { display: block; text-decoration: none; }
.ph-logo__img { width: var(--pharmacy-logo-w, 160px); height: auto; }

.ph-logo--text {
	font-family: var(--pharmacy-font-heading);
	font-size: 1.3rem;
	font-weight: 700;
	color: currentColor;
}

/* --- Navigation ---------------------------------------------------------- */

.ph-menu {
	display: flex;
	list-style: none;
	margin: 0;
	padding: 0;
	gap: 22px;
}

.ph-menu li { position: relative; }

.ph-menu a {
	color: currentColor;
	text-decoration: none;
	font-weight: 500;
	font-size: 0.94rem;
	white-space: nowrap;
}

.ph-menu a:hover { color: var(--pharmacy-primary); }

.ph-menu .sub-menu {
	position: absolute;
	list-style: none;
	margin: 8px 0 0;
	padding: 10px;
	min-width: 220px;
	background: var(--pharmacy-surface);
	border: 1px solid var(--pharmacy-border);
	border-radius: var(--pharmacy-radius);
	box-shadow: 0 12px 32px -12px rgba(11, 31, 51, 0.24);
	opacity: 0;
	visibility: hidden;
	transform: translateY(-6px);
	transition: opacity 150ms ease, transform 150ms ease, visibility 150ms;
	z-index: 20;
}

/* focus-within, not just hover: a keyboard user must be able to reach a submenu. */
.ph-menu li:hover > .sub-menu,
.ph-menu li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: none;
}

.ph-menu .sub-menu a {
	display: block;
	padding: 8px 10px;
	border-radius: 6px;
}

.ph-menu .sub-menu a:hover { background: var(--pharmacy-muted); }

/* --- Actions ------------------------------------------------------------- */

.ph-header__action {
	position: relative;
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 8px;
	background: none;
	color: currentColor;
	cursor: pointer;
	text-decoration: none;
}

.ph-header__action:hover {
	background: var(--pharmacy-muted);
	color: var(--pharmacy-primary);
}

.ph-header__count {
	position: absolute;
	top: 3px;
	inset-inline-end: 3px;
	min-width: 17px;
	height: 17px;
	padding: 0 4px;
	border-radius: 999px;
	background: var(--pharmacy-accent);
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 17px;
	text-align: center;
}

.ph-header__rx { white-space: nowrap; }

.ph-header__burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 4px;
	width: 40px;
	height: 40px;
	border: 0;
	background: none;
	cursor: pointer;
	grid-area: burger;
}

.ph-header__burger span {
	display: block;
	width: 20px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
}

/* --- Predictive search --------------------------------------------------- */

.ph-search {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
	background: var(--pharmacy-field-bg);
	border: 1px solid var(--pharmacy-field-border);
	border-radius: var(--pharmacy-field-radius);
}

.ph-search__icon {
	position: absolute;
	inset-inline-start: 12px;
	opacity: 0.5;
	pointer-events: none;
}

.ph-search__input {
	flex: 1;
	height: var(--pharmacy-field-h);
	padding-inline: 40px 12px;
	border: 0;
	background: none;
	font: inherit;
	color: var(--pharmacy-field-text);
}

.ph-search__input:focus { outline: none; }

.ph-search__submit {
	height: calc(var(--pharmacy-field-h) - 8px);
	margin-inline-end: 4px;
	padding: 0 16px;
	border: 0;
	border-radius: calc(var(--pharmacy-field-radius) - 2px);
	background: var(--pharmacy-primary);
	color: #fff;
	font-weight: 600;
	font-size: 0.85rem;
	cursor: pointer;
}

.ph-search__results {
	position: absolute;
	top: calc(100% + 8px);
	inset-inline: 0;
	max-height: 70vh;
	overflow-y: auto;
	background: var(--pharmacy-surface);
	border: 1px solid var(--pharmacy-border);
	border-radius: var(--pharmacy-radius);
	box-shadow: 0 16px 44px -12px rgba(11, 31, 51, 0.28);
	z-index: 60;
}

.ph-search__products,
.ph-search__cats {
	list-style: none;
	margin: 0;
	padding: 6px;
}

.ph-search__cats {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	border-bottom: 1px solid var(--pharmacy-border);
}

.ph-search__cats a {
	display: inline-flex;
	gap: 5px;
	padding: 5px 10px;
	border-radius: 999px;
	background: var(--pharmacy-muted);
	font-size: 0.8rem;
	text-decoration: none;
	color: var(--pharmacy-heading);
}

.ph-search__cats span { opacity: 0.5; }

.ph-search__products a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px;
	border-radius: 8px;
	text-decoration: none;
	color: inherit;
}

.ph-search__products a:hover { background: var(--pharmacy-muted); }

.ph-search__products img,
.ph-search__noimg {
	flex: 0 0 44px;
	width: 44px;
	height: 44px;
	object-fit: contain;
	border-radius: 6px;
	background: var(--pharmacy-muted);
}

.ph-search__info {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.ph-search__info strong {
	font-size: 0.9rem;
	font-weight: 600;
	color: var(--pharmacy-heading);
}

.ph-search__info em { font-size: 0.78rem; opacity: 0.65; }
.ph-search__info small { font-size: 0.72rem; opacity: 0.55; }

.ph-search__right {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 3px;
}

.ph-search__price {
	font-size: 0.88rem;
	font-weight: 700;
	color: var(--pharmacy-heading);
}

.ph-search__empty {
	margin: 0;
	padding: 20px;
	text-align: center;
	opacity: 0.6;
}

/* --- Mobile -------------------------------------------------------------- */

@media (max-width: 1024px) {
	.ph-header {
		grid-template-columns: auto 1fr auto;
		grid-template-areas:
			"burger logo actions"
			"search search search";
		gap: 12px;
		padding-block: 12px;
	}

	.ph-header__burger { display: flex; }
	.ph-header__logo { justify-self: center; }
	.ph-header__nav { display: none; }

	/* The prescription CTA collapses to its icon rather than disappearing — it is the
	   single most important action in a pharmacy header. */
	.ph-header__rx span { display: none; }
	.ph-header__rx { padding-inline: 12px; }
}
