/* ==========================================================================
   MG Header — 2-row ecommerce header
   ========================================================================== */

/* ── Reset & base ── */
.mg-header {
	position: relative;
	z-index: 1000;
	font-family: var(--theme-font-stack-default, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	-webkit-font-smoothing: antialiased;
}

.mg-header *,
.mg-header *::before,
.mg-header *::after {
	box-sizing: border-box;
}

/* ── Container ── */
.mg-header__container {
	max-width: 1290px;
	margin: 0 auto;
	padding: 0 clamp(14px, 2.5vw, 32px);
	display: flex;
	align-items: center;
}

/* ==========================================================================
   Row 1 — Primary: Logo | Search | Actions
   ========================================================================== */
.mg-header__row--primary {
	background: var(--mg-purple, #490D78);
	padding: 10px 0;
}

.mg-header__row--primary .mg-header__container {
	gap: 16px;
}

/* ── Logo ── */
.mg-header__logo {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	text-decoration: none;
	color: #fff;
}

.mg-header__logo-img {
	display: block;
	width: auto;
	height: auto;
	max-height: 58px;
	object-fit: contain;
}

.mg-header__logo-text {
	font-size: 20px;
	font-weight: 700;
	color: #fff;
	white-space: nowrap;
}

/* ── Search form ── */
.mg-header__row--primary .mg-header-search-form {
	flex: 1 1 auto;
	max-width: 640px;
	position: relative;
	display: flex;
	align-items: center;
	background: #fff;
	border-radius: 999px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
	overflow: hidden;
}

.mg-header__row--primary .mg-header-search-form input[type="search"] {
	flex: 1 1 auto;
	width: 100%;
	height: 46px;
	min-height: 46px;
	border: 0;
	padding: 0 56px 0 22px;
	font-size: 14.5px;
	color: #333;
	background: transparent;
	border-radius: 999px;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.mg-header__row--primary .mg-header-search-form input[type="search"]::placeholder {
	color: #aaa;
}

.mg-header__row--primary .mg-header-search-form input[type="search"]:focus {
	box-shadow: inset 0 0 0 2px rgba(245, 205, 70, 0.5);
	border-radius: 999px;
}

.mg-header__row--primary .mg-header-search-form button {
	position: absolute;
	right: 0;
	top: 0;
	width: 50px;
	height: 100%;
	border: 0;
	border-radius: 0 999px 999px 0;
	background: var(--mg-gold, #F5CD46);
	color: #2f0a49;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
}

.mg-header__row--primary .mg-header-search-form button:hover {
	background: #e6be3a;
}

.mg-header__row--primary .mg-header-search-form button svg {
	width: 24px;
	height: 24px;
	stroke: #2f0a49;
	stroke-width: 2.6;
	fill: none;
	display: block;
}

/* Live search dropdown positioning */
.mg-header__row--primary .mg-header-search-form .mg-ls-dropdown {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	z-index: 10000;
	border-radius: 12px;
}

/* ── Actions (Account + Cart) ── */
.mg-header__actions {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	gap: 6px;
}

.mg-header__action {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.10);
	color: #fff;
	text-decoration: none;
	font-size: 13px;
	font-weight: 500;
	border: 0;
	cursor: pointer;
	transition: background 0.2s, transform 0.15s;
	white-space: nowrap;
	line-height: 1;
}

.mg-header__action:hover {
	background: rgba(255, 255, 255, 0.18);
	transform: translateY(-1px);
}

.mg-header__action svg {
	flex-shrink: 0;
}

.mg-header__action--cart {
	position: relative;
}

.mg-header__cart-count {
	min-width: 18px;
	height: 18px;
	border-radius: 999px;
	background: var(--mg-gold, #F5CD46);
	color: #2f0a49;
	font-size: 11px;
	font-weight: 800;
	line-height: 18px;
	text-align: center;
	display: inline-block;
	box-shadow: 0 2px 6px rgba(245, 205, 70, 0.4);
}

.mg-header__cart-count.is-empty {
	display: none;
}

/* ==========================================================================
   Row 2 — Secondary: Nav + Shipping
   ========================================================================== */
.mg-header__row--secondary {
	background: #3a0a62;
	border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.mg-header__row--secondary .mg-header__container {
	min-height: 40px;
}

/* ── Hamburger (hidden on desktop) ── */
.mg-header__hamburger {
	display: none;
}

/* ── Nav ── */
.mg-header__nav {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 0;
	flex: 1 1 auto;
}

.mg-header__nav-item {
	position: relative;
}

.mg-header__nav-link,
a.mg-header__nav-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	padding: 9px 14px;
	color: rgba(255, 255, 255, 0.88);
	font-size: 13px;
	font-weight: 500;
	text-decoration: none;
	white-space: nowrap;
	transition: color 0.15s;
	border: 0;
	background: none;
	cursor: pointer;
	font-family: inherit;
}

.mg-header__nav-link:hover,
a.mg-header__nav-link:hover {
	color: var(--mg-gold, #F5CD46);
}

.mg-header__caret {
	transition: transform 0.2s;
}

/* ── Categories dropdown ── */
.mg-header__dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	min-width: 220px;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
	opacity: 0;
	visibility: hidden;
	transform: translateY(4px);
	transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
	z-index: 500;
	padding: 6px 0;
}

.mg-header__nav-item--dropdown:hover .mg-header__dropdown,
.mg-header__nav-item--dropdown.is-open .mg-header__dropdown {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.mg-header__nav-item--dropdown:hover .mg-header__caret,
.mg-header__nav-item--dropdown.is-open .mg-header__caret {
	transform: rotate(180deg);
}

.mg-header__dropdown-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mg-header__dropdown-list li a {
	display: block;
	padding: 8px 18px;
	color: #333;
	font-size: 13px;
	font-weight: 400;
	text-decoration: none;
	transition: background 0.15s, color 0.15s;
}

.mg-header__dropdown-list li a:hover {
	background: #f5f3f8;
	color: var(--mg-purple, #490D78);
}

.mg-header__dropdown-all a {
	font-weight: 600;
	color: var(--mg-purple, #490D78) !important;
	border-top: 1px solid #eee;
	margin-top: 4px;
	padding-top: 10px;
}

/* ── Shipping note ── */
.mg-header__shipping {
	margin-left: auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: rgba(255, 255, 255, 0.7);
	font-size: 12px;
	font-weight: 500;
	white-space: nowrap;
	padding: 0 4px;
}

.mg-header__shipping svg {
	flex-shrink: 0;
	opacity: 0.7;
}

/* ==========================================================================
   Sticky header
   ========================================================================== */
.mg-header.is-sticky {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 1000;
}

.mg-header.is-sticky .mg-header__row--primary {
	padding: 6px 0;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
	background: rgba(73, 13, 120, 0.97);
	backdrop-filter: blur(8px);
}

.mg-header.is-sticky .mg-header__logo-img {
	max-height: 42px;
}

.mg-header.is-sticky .mg-header__row--secondary {
	display: none;
}

/* Spacer to prevent content jump when sticky */
.mg-header-spacer {
	display: none;
}

.mg-header.is-sticky + .mg-header-spacer {
	display: block;
}

/* ==========================================================================
   Mobile & Tablet (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {

	/* Primary row */
	.mg-header__row--primary {
		padding: 8px 0;
	}

	.mg-header__row--primary .mg-header__container {
		flex-wrap: wrap;
		gap: 8px;
	}

	.mg-header__logo-img {
		max-height: 40px;
	}

	/* Search: full width below logo + actions */
	.mg-header__row--primary .mg-header-search-form {
		order: 3;
		flex: 1 1 100%;
		max-width: none;
	}

	.mg-header__row--primary .mg-header-search-form input[type="search"] {
		height: 40px;
		min-height: 40px;
		font-size: 13px;
	}

	/* Actions: push to right */
	.mg-header__actions {
		margin-left: auto;
	}

	.mg-header__action-label {
		display: none;
	}

	.mg-header__action {
		padding: 6px 8px;
	}

	/* Secondary row */
	.mg-header__hamburger {
		display: flex;
		flex-direction: column;
		justify-content: center;
		gap: 4px;
		width: 32px;
		height: 32px;
		padding: 6px;
		background: none;
		border: 0;
		cursor: pointer;
		flex-shrink: 0;
	}

	.mg-header__hamburger span {
		display: block;
		width: 100%;
		height: 2px;
		background: #fff;
		border-radius: 2px;
		transition: transform 0.2s, opacity 0.2s;
	}

	.mg-header__hamburger[aria-expanded="true"] span:nth-child(1) {
		transform: translateY(6px) rotate(45deg);
	}
	.mg-header__hamburger[aria-expanded="true"] span:nth-child(2) {
		opacity: 0;
	}
	.mg-header__hamburger[aria-expanded="true"] span:nth-child(3) {
		transform: translateY(-6px) rotate(-45deg);
	}

	.mg-header__nav {
		display: none;
		position: absolute;
		top: 100%;
		left: 0;
		right: 0;
		flex-direction: column;
		align-items: stretch;
		background: #3a0a62;
		box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
		z-index: 900;
		padding: 8px 0;
	}

	.mg-header__nav.is-open {
		display: flex;
	}

	.mg-header__nav-link,
	a.mg-header__nav-link {
		padding: 12px 20px;
		font-size: 14px;
	}

	/* Categories dropdown on mobile: inline expand */
	.mg-header__dropdown {
		position: static;
		background: rgba(0, 0, 0, 0.15);
		box-shadow: none;
		border-radius: 0;
		opacity: 1;
		visibility: hidden;
		max-height: 0;
		overflow: hidden;
		transform: none;
		transition: max-height 0.3s, visibility 0.3s, padding 0.3s;
		padding: 0;
	}

	.mg-header__nav-item--dropdown.is-open .mg-header__dropdown {
		visibility: visible;
		max-height: 600px;
		padding: 4px 0;
	}

	.mg-header__dropdown-list li a {
		color: rgba(255, 255, 255, 0.85);
		padding: 10px 32px;
	}

	.mg-header__dropdown-list li a:hover {
		background: rgba(255, 255, 255, 0.08);
		color: #fff;
	}

	.mg-header__dropdown-all a {
		color: var(--mg-gold, #F5CD46) !important;
		border-top-color: rgba(255, 255, 255, 0.1);
	}

	.mg-header__shipping {
		display: none;
	}

	/* Sticky on mobile */
	.mg-header.is-sticky .mg-header__row--primary .mg-header-search-form {
		display: none;
	}

	.mg-header.is-sticky .mg-header__logo-img {
		max-height: 34px;
	}
}

/* ── Hide legacy blocks (now redundant with new header) ── */
.mg-hero-compact,
.mg-promo-banners {
	display: none !important;
}

/* ── Fix product grid on shop + search pages ── */
ul.products[data-products] {
	display: grid !important;
	grid-template-columns: repeat(4, 1fr);
	gap: 20px;
	list-style: none;
	padding: 0;
}

@media (max-width: 999px) {
	ul.products[data-products] {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 689px) {
	ul.products[data-products] {
		grid-template-columns: repeat(2, 1fr);
		gap: 12px;
	}
}

/* ── Product card layout (replaces stripped ct-woocommerce-styles) ── */
ul.products[data-products] li.product figure {
	position: relative;
	margin: 0;
}

ul.products[data-products] li.product .ct-media-container {
	display: block;
	width: 100%;
}

ul.products[data-products] li.product .ct-media-container img {
	width: 100%;
	height: auto;
	object-fit: contain;
	aspect-ratio: 1 / 1;
}

ul.products[data-products] li.product .onsale {
	position: absolute;
	top: 8px;
	left: 8px;
	z-index: 2;
	background: #e63946;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	padding: 4px 10px;
	border-radius: 20px;
	line-height: 1.3;
}

/* ── YITH filter visual fixes ── */
/* Hide native checkbox/radio — YITH draws its own via ::before pseudo */
.yith-wcan-filter .filter-items input[type="checkbox"],
.yith-wcan-filter .filter-items input[type="radio"] {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

/* Ensure filter labels are clickable and aligned */
.yith-wcan-filter .filter-items label {
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: pointer;
	padding: 6px 0;
}

/* Custom checkbox appearance */
.yith-wcan-filter .filter-items .term-label::before {
	content: "";
	display: inline-block;
	width: 18px;
	height: 18px;
	min-width: 18px;
	border: 2px solid #ccc;
	border-radius: 4px;
	transition: background .2s, border-color .2s;
}

.yith-wcan-filter .filter-items .active .term-label::before,
.yith-wcan-filter .filter-items input:checked + .term-label::before {
	background: var(--mg-purple, #490D78);
	border-color: var(--mg-purple, #490D78);
	background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 7l3 3 5-5' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-size: 14px;
	background-position: center;
	background-repeat: no-repeat;
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
	.mg-header__row--primary .mg-header-search-form {
		max-width: 420px;
	}

	.mg-header__nav-link,
	a.mg-header__nav-link {
		padding: 9px 10px;
		font-size: 12px;
	}
}

/* ==========================================================================
   Login Modal
   ========================================================================== */
.mg-login-modal {
	position: fixed;
	inset: 0;
	z-index: 10000;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity .25s, visibility .25s;
}
.mg-login-modal[aria-hidden="true"] {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}
.mg-login-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,.55);
}
.mg-login-modal__dialog {
	position: relative;
	width: 90%;
	max-width: 400px;
	background: #fff;
	border-radius: 12px;
	padding: 32px 28px 28px;
	box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.mg-login-modal__close {
	position: absolute;
	top: 12px;
	right: 14px;
	border: 0;
	background: none;
	font-size: 24px;
	color: #666;
	cursor: pointer;
	line-height: 1;
}
.mg-login-modal__close:hover { color: #000; }
.mg-login-modal__title {
	margin: 0 0 20px;
	font-size: 20px;
	font-weight: 700;
	color: var(--mg-purple, #490D78);
	text-align: center;
}
.mg-login-modal__form label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 4px;
	color: #333;
}
.mg-login-modal__form input[type="text"],
.mg-login-modal__form input[type="password"] {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid #ccc;
	border-radius: 6px;
	font-size: 14px;
	margin-bottom: 14px;
	transition: border-color .2s;
}
.mg-login-modal__form input:focus {
	outline: none;
	border-color: var(--mg-purple, #490D78);
	box-shadow: 0 0 0 2px rgba(73,13,120,.12);
}
.mg-login-modal__submit {
	width: 100%;
	padding: 12px;
	background: var(--mg-purple, #490D78);
	color: #fff;
	border: 0;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	transition: background .2s;
}
.mg-login-modal__submit:hover {
	background: #3a0860;
}
.mg-login-modal__links {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-top: 12px;
	font-size: 12px;
}
.mg-login-modal__links a { color: var(--mg-purple, #490D78); }
.mg-login-modal__remember {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	color: #555;
}
.mg-login-modal__divider {
	text-align: center;
	margin: 20px 0;
	position: relative;
}
.mg-login-modal__divider::before {
	content: "";
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 1px;
	background: #ddd;
}
.mg-login-modal__divider span {
	position: relative;
	background: #fff;
	padding: 0 12px;
	font-size: 13px;
	color: #888;
}
.mg-login-modal__register {
	display: block;
	text-align: center;
	padding: 10px;
	border: 2px solid var(--mg-purple, #490D78);
	border-radius: 8px;
	color: var(--mg-purple, #490D78);
	font-weight: 700;
	font-size: 14px;
	text-decoration: none;
	transition: background .2s, color .2s;
}
.mg-login-modal__register:hover {
	background: var(--mg-purple, #490D78);
	color: #fff;
}

/* Make account button look like a link in header */
button.mg-header__action--account {
	background: none;
	border: 0;
	cursor: pointer;
	padding: 0;
	font: inherit;
	color: inherit;
}
