/**
 * Primary nav + Mega menu – mobile-first
 */

.sanomart-primary-nav {
	background: var( --sanomart-primary );
	position: relative;
	margin-top: 12px;
}

.sanomart-primary-nav__list > .menu-item {
	border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sanomart-nav__link {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.85rem 1rem;
	color: #fff;
	text-decoration: none;
	font-size: 0.9375rem;
	font-weight: 500;
}

.sanomart-nav__link:hover,
.sanomart-nav__link:focus-visible {
	color: #fff;
	outline: none;
}

/* .menu-item-has-mega.is-mega-open > .sanomart-nav__link,
.menu-item-has-mega.is-mega-mobile-open > .sanomart-nav__link {
	background: rgba(255, 255, 255, 0.12);
} */

.sanomart-nav__chevron {
	width: 0.5rem;
	height: 0.5rem;
	border-right: 2px solid #fff;
	border-bottom: 2px solid #fff;
	transform: rotate(45deg);
	transition: transform 0.2s ease;
	flex-shrink: 0;
}

.menu-item-has-mega.is-mega-open > .sanomart-nav__link .sanomart-nav__chevron,
.menu-item-has-mega.is-mega-mobile-open > .sanomart-nav__link .sanomart-nav__chevron {
	transform: rotate(-135deg);
}

/* Mega dropdown */
.sanomart-mega {
	background: #fff;
	border-top: 1px solid #e8eef3;
}

.sanomart-mega__panel {
	display: flex;
	flex-direction: column;
	max-width: var(--sanomart-container, 1280px);
	margin: 0 auto;
	padding: 0.75rem;
}

.sanomart-mega__sidebar {
	flex: 0 0 auto;
}

.sanomart-mega__subs {
	margin: 0;
	padding: 0;
	list-style: none;
}

.sanomart-mega__sub-item {
	margin: 0;
}

.sanomart-mega__sub-item > .sub-menu {
	display: none !important;
}

.sanomart-mega__sub-link {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	padding: 0.65rem 0.75rem;
	border-radius: 0.5rem;
	color: var( --sanomart-primary );
	text-decoration: none;
	font-size: 0.875rem;
	transition: background 0.15s ease;
}

.sanomart-mega__sub-link:hover,
.sanomart-mega__sub-item.is-active .sanomart-mega__sub-link {
	background: #f0f3f6;
	font-weight: 600;
}

.sanomart-mega__sub-icon {
	width: 28px;
	height: 28px;
	object-fit: contain;
	flex-shrink: 0;
}

.sanomart-mega__products {
	flex: 1;
	min-width: 0;
	margin-top: 0.75rem;
	background: #f5f7f9;
	border-radius: 0.75rem;
	padding: 1rem;
	position: relative;
}

.sanomart-mega-children {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem;
	margin-bottom: 1rem;
}

.sanomart-mega-children__item {
	display: flex;
	align-items: center;
	gap: 0.7rem;
	min-width: 0;
	padding: 0.5rem 0.75rem;
	border-radius: 0.75rem;
	background: #fff;
	color: #24435f;
	text-decoration: none;
	box-shadow: inset 0 0 0 1px rgba(21, 74, 122, 0.08);
	transition: background 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.sanomart-mega-children__item:hover,
.sanomart-mega-children__item:focus-visible {
	background: #f8fbff;
	box-shadow: inset 0 0 0 1px rgba(33, 94, 152, 0.18);
	transform: translateY(-1px);
	outline: none;
}

.sanomart-mega-children__icon {
	width: 36px;
	height: 36px;
	border-radius: 999px;
	object-fit: contain;
	flex-shrink: 0;
	background: #f4f7fb;
}

.sanomart-mega-children__icon--placeholder {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.sanomart-mega-children__icon--placeholder::before {
	content: "";
	width: 14px;
	height: 14px;
	border-radius: 999px;
	background: linear-gradient(135deg, #2f7eea 0%, #7db5ff 100%);
}

.sanomart-mega-children__text {
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
	color: inherit;
}

.sanomart-mega__products-loading {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.68);
	backdrop-filter: blur(1px);
	border-radius: 0.75rem;
	z-index: 2;
	pointer-events: none;
}

.sanomart-mega__products-loading[hidden] {
	display: none !important;
}

.sanomart-mega__products-loading span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 110px;
	padding: 0.45rem 0.8rem;
	font-size: 0.875rem;
	font-weight: 600;
	color: var( --sanomart-primary );
	background: rgba(255, 255, 255, 0.95);
	border: 1px solid rgba(12, 74, 122, 0.2);
	border-radius: 999px;
}

.sanomart-mega-products__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	margin-bottom: 1rem;
	flex-wrap: wrap;
}

.sanomart-mega-products__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	color: #1a1a1a;
}

.sanomart-mega-products__view-all {
	font-size: 0.875rem;
	font-weight: 600;
	color: var( --sanomart-primary );
	text-decoration: none;
	white-space: nowrap;
}

.sanomart-mega-products__view-all:hover {
	text-decoration: underline;
}

.sanomart-mega-products__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.75rem;
}

.sanomart-mega-products__empty {
	margin: 0;
	font-size: 0.875rem;
	color: #5a7a94;
}

/* Product card */
.sanomart-mega-product__link {
	display: block;
	text-decoration: none;
	color: inherit;
	height: 100%;
}

.sanomart-mega-product__image-wrap {
	background: #fff;
	border-radius: 0.5rem;
	padding: 12px;
	margin-bottom: 16px;
	aspect-ratio: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

.sanomart-mega-product__image {
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	width: 100%;
	height: 100%;
}

.sanomart-mega-product__title {
	margin: 0 0 0.35rem;
	font-size: 0.8125rem;
	font-weight: 500;
	line-height: 1.35;
	color: #1a1a1a;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.sanomart-mega-product__price-row {
	display: flex;
	flex-direction: column;
	gap: 0.15rem;
}

.sanomart-mega-product__price {
	font-size: 0.8125rem;
	font-weight: 700;
	color: #d32f2f;
}

.sanomart-mega-product__price .woocommerce-Price-amount {
	color: inherit;
}

.sanomart-mega-product__price-old {
	font-size: 0.75rem;
	color: #9aa8b4;
	text-decoration: line-through;
}

.sanomart-mega-product__price-old .woocommerce-Price-amount {
	color: inherit;
}

/* Tablet */
@media (min-width: 768px) {
	.sanomart-mega-products__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

/* Mobile – nav chuyển vào drawer */
@media (max-width: 1023px) {
	.sanomart-primary-nav {
		display: none;
	}
}

/* Desktop */
@media (min-width: 1024px) {
	.sanomart-primary-nav__list {
		display: flex;
		flex-direction: row;
		flex-wrap: wrap;
		max-width: var(--sanomart-container, 1280px);
		margin: 0 auto;
		padding-left: var(--sanomart-container-padding);
    	padding-right: var(--sanomart-container-padding);
	}

	.sanomart-primary-nav__list > .menu-item {
		border-top: 0;
		position: static;
	}

	.sanomart-primary-nav__list > .menu-item.menu-item-has-children:not(.menu-item-has-mega) {
		position: relative;
	}

	.sanomart-nav__link {
		position: relative;
		min-height: 47px;
		padding: 0.9rem 0;
		white-space: nowrap;
	}

	.sanomart-primary-nav__list > .menu-item + .menu-item {
		margin-left: 2.2rem;
	}

	.sanomart-nav__link::after {
		content: "";
		position: absolute;
		left: 0;
		right: 0;
		bottom: 10px;
		height: 2px;
		background: #fff;
		opacity: 0;
		transform: scaleX(0);
		transform-origin: left center;
		transition: opacity 0.16s ease, transform 0.16s ease;
	}

	.sanomart-nav__link:hover::after,
	.sanomart-nav__link:focus-visible::after,
	.menu-item-has-mega.is-mega-open > .sanomart-nav__link::after,
	.menu-item-has-children:not(.menu-item-has-mega):hover > .sanomart-nav__link::after,
	.menu-item-has-children:not(.menu-item-has-mega):focus-within > .sanomart-nav__link::after,
	.current-menu-item > .sanomart-nav__link::after,
	.current-menu-ancestor > .sanomart-nav__link::after {
		opacity: 1;
		transform: scaleX(1);
	}

	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega) > .sub-menu {
		position: absolute;
		top: 100%;
		left: 0;
		z-index: 101;
		min-width: 14rem;
		margin: 0;
		margin-top: -1px;
		padding: 0.5rem 0;
		list-style: none;
		background: #fff;
		border: 1px solid #d9e4ed;
		border-radius: 0.75rem;
		box-shadow: 0 16px 40px rgba(18, 45, 74, 0.14);
		opacity: 0;
		visibility: hidden;
		pointer-events: none;
		transform: translateY(0.35rem);
		transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
	}

	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega):hover > .sub-menu,
	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega):focus-within > .sub-menu {
		opacity: 1;
		visibility: visible;
		pointer-events: auto;
		transform: translateY(0);
	}

	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega) > .sub-menu .menu-item {
		position: relative;
	}

	.sanomart-primary-nav__list > .menu-item.menu-item-has-children:not(.menu-item-has-mega) > .sub-menu {
		left: 0;
	}

	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega) > .sub-menu .menu-item-has-children > .sub-menu {
		top: -1px;
		left: calc(100% - 0.1rem);
	}

	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega) > .sub-menu a {
		display: block;
		padding: 0.7rem 1rem;
		color: #16324f;
		font-size: 0.9375rem;
		font-weight: 500;
		line-height: 1.35;
		text-decoration: none;
		transition: background 0.16s ease, color 0.16s ease;
	}

	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega) > .sub-menu a:hover,
	.sanomart-primary-nav__list .menu-item-has-children:not(.menu-item-has-mega) > .sub-menu a:focus-visible {
		background: #f3f7fb;
		color: var(--sanomart-primary);
		outline: none;
	}

	.sanomart-mega {
		position: absolute;
		left: 0;
		right: 0;
		top: 100%;
		z-index: 100;
		box-shadow: 0 12px 40px rgba(12, 74, 122, 0.15);
		border-top: 0;
	}

	.sanomart-mega__panel {
		flex-direction: row;
		align-items: stretch;
		gap: 0;
		padding: 1.25rem 1.5rem;
		min-height: 320px;
	}

	.sanomart-mega__sidebar {
		flex: 0 0 32%;
		max-width: 280px;
		padding-right: 1rem;
		border-right: 1px solid #e8eef3;
	}

	.sanomart-mega__products {
		margin-top: 0;
		margin-left: 1.25rem;
		flex: 1;
	}

	.sanomart-mega-products__grid {
		grid-template-columns: repeat(4, minmax(0, 1fr));
		gap: 1rem;
	}

	.sanomart-mega-children {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}

	.menu-item-has-mega.is-mega-mobile-open .sanomart-mega[hidden] {
		display: block;
	}
}

/* Mobile mega accordion */
@media (max-width: 1023px) {
	.menu-item-has-mega .sanomart-mega[hidden] {
		display: none !important;
	}

	.menu-item-has-mega.is-mega-mobile-open .sanomart-mega {
		display: block !important;
	}
}
