/* MasterStudy Modern Header
   Scoped entirely under #msmh-header / #msmh-drawer so it never leans on the
   theme's old header CSS. Reused theme/LMS-plugin components (search, wishlist,
   account dropdown, settings, become-instructor/enterprise, WPML, socials) are
   restyled by targeting their existing classes -- their own JS keeps working untouched. */

#msmh-header,
#msmh-drawer {
	--msmh-primary: #4E1F91;
	--msmh-primary-dark: #37166B;
	--msmh-primary-soft: #F1ECFA;
	--msmh-text: #1A1A2E;
	--msmh-text-muted: #6B7280;
	--msmh-border: #E7E5F0;
	--msmh-bg: #FFFFFF;
	--msmh-bg-soft: #F7F6FB;
	--msmh-radius: 14px;
	--msmh-shadow: 0 8px 30px rgba(24, 10, 51, 0.08);
	box-sizing: border-box;
}
#msmh-header *,
#msmh-header *::before,
#msmh-header *::after,
#msmh-drawer *,
#msmh-drawer *::before,
#msmh-drawer *::after {
	box-sizing: border-box;
}

/* ---------- layout shell ---------- */
#msmh-header {
	position: sticky;
	top: 0;
	z-index: 999;
	background: var(--msmh-bg);
	font-family: inherit;
}
#msmh-header.msmh-scrolled .msmh-main {
	box-shadow: var(--msmh-shadow);
}
.msmh-container {
	max-width: 1280px;
	margin: 0 auto;
	padding: 0 24px;
}

/* ---------- top utility bar ---------- */
.msmh-topbar {
	background: var(--msmh-primary);
	color: #fff;
}
.msmh-topbar .msmh-container {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 40px;
	gap: 16px;
}
.msmh-topbar__right {
	display: flex;
	align-items: center;
	gap: 20px;
}

/* language switcher (reused: parts/wpml_switcher.php) */
.msmh-lang .language-switcher-unit,
.msmh-lang .top_bar_info {
	all: unset;
	display: flex;
	align-items: center;
	position: relative;
}
.msmh-lang .stm_current_language {
	all: unset;
	display: flex;
	align-items: center;
	gap: 6px;
	color: rgba(255, 255, 255, 0.85);
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
}
.msmh-lang .top_bar_info li {
	color: rgba(255, 255, 255, 0.85);
	font-size: 13px;
	list-style: none;
}
.msmh-lang .lang_dropdown_menu {
	position: absolute;
	top: 100%;
	left: 0;
	margin-top: 10px;
	background: #fff;
	border-radius: 10px;
	box-shadow: var(--msmh-shadow);
	padding: 6px;
	min-width: 140px;
	list-style: none;
	display: none;
	z-index: 20;
}
.msmh-lang .stm_current_language.dropdown_toggle.open + .lang_dropdown_menu,
.msmh-lang .lang_dropdown_menu.show {
	display: block;
}
.msmh-lang .lang_dropdown_menu a {
	display: block;
	padding: 8px 10px;
	border-radius: 6px;
	color: var(--msmh-text);
	font-size: 13px;
	text-decoration: none;
}
.msmh-lang .lang_dropdown_menu a:hover {
	background: var(--msmh-bg-soft);
}

/* socials (reused: parts/socials.php) */
.msmh-socials .header_top_bar_socs ul {
	all: unset;
	display: flex;
	align-items: center;
	gap: 12px;
	list-style: none;
}
.msmh-socials .header_top_bar_socs li {
	list-style: none;
}
.msmh-socials .header_top_bar_socs a {
	display: flex;
	align-items: center;
	justify-content: center;
	color: rgba(255, 255, 255, 0.85);
	font-size: 13px;
	text-decoration: none;
	transition: color 0.15s ease;
}
.msmh-socials .header_top_bar_socs a:hover {
	color: #fff;
}

/* ---------- main row ---------- */
.msmh-main {
	border-bottom: 1px solid var(--msmh-border);
	transition: box-shadow 0.2s ease;
}
.msmh-main__inner {
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 24px;
	min-height: 88px;
}
/*
 * Grid columns are pinned explicitly (rather than left to auto-placement)
 * because .msmh-main__center is display:none on mobile — an auto-placed
 * item that's hidden is dropped from the grid entirely, which would shift
 * .msmh-main__end into the middle track and leave the last track's gap
 * reserved, pulling it in from the true right edge.
 */
.msmh-main__start {
	grid-column: 1;
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
}
.msmh-main__center {
	grid-column: 2;
	display: flex;
	justify-content: center;
	min-width: 0;
}
.msmh-main__end {
	grid-column: 3;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 10px;
}

/* centered primary menu */
.msmh-nav__list {
	all: unset;
	display: flex;
	align-items: center;
	gap: 32px;
	list-style: none;
}
.msmh-nav__list li {
	list-style: none;
}
.msmh-nav__list a {
	color: var(--msmh-text);
	font-size: 15px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.15s ease;
}
.msmh-nav__list a:hover {
	color: var(--msmh-primary);
}

/* logo (reused: parts/logo.php) */
.msmh-logo {
	flex-shrink: 0;
	display: flex;
	align-items: center;
}
.msmh-logo a {
	display: flex;
	align-items: center;
}
.msmh-logo img {
	max-height: 58px;
	width: auto !important;
	max-width: 220px;
}
.msmh-logo .logo {
	font-size: 26px;
	font-weight: 700;
	color: var(--msmh-primary);
}

/* round icon buttons (search) */
.msmh-icon-btn {
	all: unset;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	color: var(--msmh-text);
	flex-shrink: 0;
	transition: background 0.15s ease, color 0.15s ease;
}
.msmh-icon-btn:hover {
	background: var(--msmh-bg-soft);
	color: var(--msmh-primary);
}

/* search modal */
.msmh-search-modal {
	position: fixed;
	inset: 0;
	z-index: 1000;
	visibility: hidden;
	pointer-events: none;
}
.msmh-search-modal.is-open {
	visibility: visible;
	pointer-events: auto;
}
.msmh-search-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(20, 10, 40, 0.5);
	opacity: 0;
	transition: opacity 0.2s ease;
}
.msmh-search-modal.is-open .msmh-search-modal__overlay {
	opacity: 1;
}
.msmh-search-modal__panel {
	position: absolute;
	top: 12%;
	left: 50%;
	width: 90%;
	max-width: 640px;
	background: #fff;
	border-radius: var(--msmh-radius);
	box-shadow: var(--msmh-shadow);
	padding: 32px;
	opacity: 0;
	transform: translate(-50%, -12px);
	transition: opacity 0.2s ease, transform 0.2s ease;
}
.msmh-search-modal.is-open .msmh-search-modal__panel {
	opacity: 1;
	transform: translate(-50%, 0);
}
.msmh-search-modal__close {
	all: unset;
	cursor: pointer;
	position: absolute;
	top: 14px;
	right: 18px;
	font-size: 26px;
	line-height: 1;
	color: var(--msmh-text-muted);
	padding: 4px 8px;
}
.msmh-search-modal__title {
	margin: 0 0 18px;
	font-size: 20px;
	font-weight: 700;
	color: var(--msmh-text);
}
.msmh-search-modal__field {
	height: 54px;
}
/*
 * The reused #stm_lms_courses_search widget ships its own layout CSS from the
 * MasterStudy LMS plugin (position: relative + an absolutely-positioned
 * button, meant for a different header). That CSS isn't scoped to this
 * modal, so it can still apply here. The ID selector + !important below
 * guarantee our flex layout wins regardless of that plugin CSS's specificity
 * or load order.
 */
.msmh-search-modal__field #stm_lms_courses_search {
	all: unset;
	position: relative !important;
	display: flex !important;
	flex-direction: row !important;
	flex-wrap: nowrap !important;
	align-items: center !important;
	width: 100% !important;
	height: 100% !important;
	background: var(--msmh-bg-soft);
	border-radius: 999px;
	box-sizing: border-box;
}
.msmh-search-modal__field #stm_lms_courses_search form {
	order: 1;
	flex: 1 1 auto;
	min-width: 0;
	height: 100%;
	margin: 0;
}
.msmh-search-modal__field #stm_lms_courses_search .autocomplete-wrapper {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
}
.msmh-search-modal__field #stm_lms_courses_search input {
	all: unset;
	box-sizing: border-box;
	display: block;
	width: 100%;
	height: 100%;
	padding: 0 20px;
	font-size: 15px;
	color: var(--msmh-text);
}
.msmh-search-modal__field #stm_lms_courses_search input::placeholder {
	color: var(--msmh-text-muted);
}
.msmh-search-modal__field #stm_lms_courses_search .autocomplete-list {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid var(--msmh-border);
	border-radius: 12px;
	box-shadow: var(--msmh-shadow);
	max-height: 320px;
	overflow-y: auto;
	list-style: none;
	margin: 0;
	padding: 8px 0;
	z-index: 10;
}
.msmh-search-modal__field #stm_lms_courses_search .autocomplete-list li a {
	display: block;
	padding: 10px 20px;
	color: var(--msmh-text);
	text-decoration: none;
}
.msmh-search-modal__field #stm_lms_courses_search .autocomplete-list li a:hover {
	background: var(--msmh-primary-soft);
	color: var(--msmh-primary);
}
.msmh-search-modal__field #stm_lms_courses_search .stm_lms_courses_search__button {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	order: 2;
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin-right: 6px;
	border-radius: 50%;
	background: var(--msmh-primary);
	color: #fff;
}
.msmh-search-modal__field #stm_lms_courses_search .stm_lms_courses_search__button:hover {
	background: var(--msmh-primary-dark);
}
.msmh-search-modal__field #stm_lms_courses_search .stm_lms_courses_search__button i {
	font-size: 16px;
	color: #fff;
}

/* ---------- right side: account cluster ---------- */
.msmh-account-cluster {
	display: flex;
	align-items: center;
	gap: 14px;
}
.msmh-account-cluster > * {
	display: flex;
	align-items: center;
}
.msmh-account-cluster .stm_lms_log_in {
	all: unset;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 14px;
	font-weight: 600;
	color: var(--msmh-text);
	white-space: nowrap;
}
.msmh-account-cluster .btn.btn-default {
	all: unset;
	cursor: pointer;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	padding: 10px 20px;
	border-radius: 999px;
	background: var(--msmh-primary);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	white-space: nowrap;
	transition: background 0.15s ease;
}
.msmh-account-cluster .btn.btn-default:hover {
	background: var(--msmh-primary-dark);
}

/* mobile-only elements hidden on desktop; the burger opens the drawer */
.msmh-burger {
	all: unset;
	display: none;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	gap: 4px;
	width: 40px;
	height: 40px;
	flex-shrink: 0;
	cursor: pointer;
	margin-left: auto;
}
.msmh-burger span {
	display: block;
	width: 20px;
	height: 2px;
	background: var(--msmh-text);
	border-radius: 2px;
}

body.msmh-no-scroll {
	overflow: hidden;
}

/* ---------- off-canvas drawer (mobile) ---------- */
#msmh-drawer {
	position: fixed;
	inset: 0;
	z-index: 1000;
	visibility: hidden;
	pointer-events: none;
}
#msmh-drawer.is-open {
	visibility: visible;
	pointer-events: auto;
}
.msmh-drawer__overlay {
	position: absolute;
	inset: 0;
	background: rgba(20, 10, 40, 0.45);
	opacity: 0;
	transition: opacity 0.2s ease;
}
#msmh-drawer.is-open .msmh-drawer__overlay {
	opacity: 1;
}
.msmh-drawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 88%;
	max-width: 360px;
	background: #fff;
	box-shadow: var(--msmh-shadow);
	padding: 18px 20px 32px;
	overflow-y: auto;
	transform: translateX(100%);
	transition: transform 0.25s ease;
}
#msmh-drawer.is-open .msmh-drawer__panel {
	transform: translateX(0);
}
.msmh-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding-bottom: 16px;
	margin-bottom: 16px;
	border-bottom: 1px solid var(--msmh-border);
}
.msmh-drawer__close {
	all: unset;
	cursor: pointer;
	flex-shrink: 0;
	font-size: 26px;
	line-height: 1;
	color: var(--msmh-text-muted);
	padding: 4px 8px;
}
.msmh-drawer__account {
	display: flex;
	align-items: center;
	gap: 14px;
	flex-wrap: wrap;
	flex: 1 1 auto;
	min-width: 0;
}
.msmh-drawer__section {
	margin-bottom: 18px;
	padding-bottom: 18px;
	border-bottom: 1px solid var(--msmh-border);
}
.msmh-drawer__section:last-child {
	border-bottom: none;
	margin-bottom: 0;
}
.msmh-drawer__menu {
	all: unset;
	display: flex;
	flex-direction: column;
	list-style: none;
}
.msmh-drawer__menu li {
	list-style: none;
}
.msmh-drawer__menu a {
	display: block;
	padding: 10px 0;
	color: var(--msmh-text);
	font-size: 15px;
	font-weight: 500;
	text-decoration: none;
	border-bottom: 1px solid var(--msmh-border);
}
.msmh-drawer .msmh-socials .header_top_bar_socs a {
	color: var(--msmh-text-muted);
}
.msmh-drawer .msmh-socials .header_top_bar_socs a:hover {
	color: var(--msmh-primary);
}

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
	.msmh-nav__list {
		gap: 20px;
	}
}

@media (max-width: 860px) {
	.msmh-container {
		padding: 0 16px;
	}
	.msmh-topbar {
		display: none;
	}
	/* centered primary menu moves into the drawer on mobile to keep the bar clean */
	.msmh-main__center {
		display: none;
	}
	.msmh-main__inner {
		min-height: 72px;
		gap: 12px;
	}
	/* account/wishlist/settings move into the drawer on mobile to keep the bar clean */
	.msmh-main__end > .msmh-account-cluster {
		display: none;
	}
	.msmh-burger {
		display: flex;
	}
}

@media (max-width: 480px) {
	.msmh-logo img {
		max-height: 44px;
	}
}
