/* =============================================================================
   Mạnh An Service — Header Frontend CSS
   ============================================================================= */

/* ---- Header wrapper ---- */
.manhan-site-header {
	position: relative;
	z-index: 1000;
	background: #fff;
}

.manhan-site-header--sticky {
	position: sticky;
	top: 0;
	z-index: 9999;
}

.manhan-site-header--border {
	border-bottom: 1px solid #e5e5e5;
}

/* ---- Container ---- */
.manhan-container {
	max-width: 1280px;
	margin-left: auto;
	margin-right: auto;
	padding-left: 20px;
	padding-right: 20px;
}

/* ---- Rows ---- */
.manhan-hb-row { width: 100%; }

.manhan-hb-row-inner {
	display: flex;
	align-items: stretch;  /* col chiều cao bằng nhau */
	min-height: 60px;
	width: 100%;
}

/* ---- Columns — justify-content set trực tiếp bằng inline style PHP ---- */
.manhan-hb-col {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 1;
	min-width: 0;
}

/* Fallback theo class khi inline style không apply */
.manhan-hb-col--0 { justify-content: flex-start; }
.manhan-hb-col--1 { justify-content: center; }
.manhan-hb-col--2 { justify-content: flex-end; }

.manhan-hb-spacer { flex: 1; }

.manhan-hb-divider {
	padding: 0 8px;
	color: #ccc;
}

/* ---- Logo ---- */
.manhan-hb-logo img {
	max-height: 60px;
	width: auto;
	display: block;
}
.manhan-hb-logo--text {
	font-size: 1.5rem;
	font-weight: 700;
	text-decoration: none;
	color: inherit;
}

.manhan-hb-site-title {
	font-size: 1.25rem;
	font-weight: 700;
	text-decoration: none;
	color: inherit;
}

/* ============================================================
   DESKTOP MENU
   ============================================================ */

.manhan-hb-nav { display: flex; }

.manhan-hb-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
}

.manhan-menu-item { position: relative; }

/* Link — dùng font mặc định của theme, không override */
.manhan-menu-link {
	display: flex;
	align-items: center;
	gap: 5px;
	padding: 18px 16px;
	text-decoration: none !important;   /* chặn global link underline của theme */
	color: inherit;
	font-family: inherit;
	font-size: inherit;
	font-weight: inherit;
	white-space: nowrap;
	position: relative;
	transition: color 0.2s;
}

/* Gạch chân animation (pseudo-element) */
.manhan-menu-link::after {
	content: '';
	position: absolute;
	bottom: 10px;
	left: 16px;
	right: 16px;
	height: 2px;
	background: var(--wp--preset--color--primary, #0073aa);
	transform: scaleX(0);
	transform-origin: center;
	transition: transform 0.22s ease;
	border-radius: 2px;
}

.manhan-menu-link:hover,
.manhan-menu-item.current-menu-item > .manhan-menu-link,
.manhan-menu-item.current-menu-ancestor > .manhan-menu-link,
.manhan-menu-item.current-menu-parent > .manhan-menu-link {
	color: var(--wp--preset--color--primary, #0073aa);
}

.manhan-menu-link:hover::after,
.manhan-menu-item.current-menu-item > .manhan-menu-link::after,
.manhan-menu-item.current-menu-ancestor > .manhan-menu-link::after,
.manhan-menu-item.current-menu-parent > .manhan-menu-link::after {
	transform: scaleX(1);
}

/* Active item: in đậm */
.manhan-menu-item.current-menu-item > .manhan-menu-link,
.manhan-menu-item.current-menu-ancestor > .manhan-menu-link,
.manhan-menu-item.current-menu-parent > .manhan-menu-link {
	font-weight: 700;
}

/* Caret/mũi tên chỉ có menu con — đủ lớn để thấy rõ */
.manhan-menu-caret {
	font-size: 0.85em;
	line-height: 1;
	display: inline-flex;
	align-items: center;
	transition: transform 0.22s;
	pointer-events: none;
	opacity: 0.7;
}

.manhan-menu-item:hover > .manhan-menu-link .manhan-menu-caret {
	transform: rotate(180deg);
	opacity: 1;
}

/* Sub-menu dropdown */
.manhan-sub-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	position: absolute;
	top: calc(100% + 2px);
	left: 0;
	min-width: 260px;         /* rộng hơn để chứa menu dài */
	background: #fff;
	border: 1px solid #e5e5e5;
	border-radius: 6px;
	box-shadow: 0 8px 24px rgba(0,0,0,0.13);
	z-index: 99999;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
	pointer-events: none;
}

.manhan-menu-item:hover > .manhan-sub-menu,
.manhan-menu-item:focus-within > .manhan-sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.manhan-menu-item--sub .manhan-menu-link {
	padding: 11px 20px;
	font-size: inherit;
	text-decoration: none !important;
}

.manhan-menu-item--sub .manhan-menu-link::after {
	display: none; /* không có gạch chân ở sub-item */
}

.manhan-menu-item--sub:hover > .manhan-menu-link {
	background: #f5f5f5;
}

/* 2nd level sub-menu */
.manhan-menu-item--sub .manhan-sub-menu {
	top: -6px;
	left: 100%;
}

/* ============================================================
   MOBILE — breakpoint
   ============================================================ */

/* Default: ẩn mobile rows, hiện desktop rows */
.manhan-hb-row--mobile  { display: none; }
.manhan-hb-row--desktop { display: block; }

@media (max-width: 768px) {
	.manhan-hb-row--desktop { display: none !important; }
	.manhan-hb-row--mobile  { display: flex !important; }
	.manhan-hb-row--mobile.is-row-hidden  { display: none !important; }
}

@media (min-width: 769px) {
	.manhan-hb-row--mobile  { display: none !important; }
	.manhan-hb-row--desktop { display: block !important; }
	.manhan-hb-row--desktop.is-row-hidden { display: none !important; }
}

/* Hamburger */
.manhan-hb-hamburger {
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px;
	display: flex;
	flex-direction: column;
	gap: 5px;
	width: 40px;
	color: inherit;
}
.manhan-hb-hamburger span {
	display: block;
	width: 24px;
	height: 2px;
	background: currentColor;
	border-radius: 2px;
	transition: transform 0.25s, opacity 0.25s;
}
.manhan-hb-hamburger.is-active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.manhan-hb-hamburger.is-active span:nth-child(2) { opacity: 0; }
.manhan-hb-hamburger.is-active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ============================================================
   MOBILE DRAWER — slides from right, 2/3 width
   ============================================================ */

.manhan-mobile-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.45);
	z-index: 10998;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s;
}
.manhan-mobile-overlay.is-visible {
	opacity: 1;
	pointer-events: auto;
}

.manhan-mobile-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	width: 66.667%;
	background: #fff;
	z-index: 10999;
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	box-shadow: -4px 0 24px rgba(0,0,0,0.18);
}

.manhan-mobile-drawer.is-open { transform: translateX(0); }

.manhan-mobile-drawer__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.manhan-mobile-drawer__header {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	padding: 12px 16px;
	border-bottom: 1px solid #eee;
	flex-shrink: 0;
}

.manhan-mobile-drawer__close {
	background: none;
	border: none;
	font-size: 1.4rem;
	cursor: pointer;
	padding: 4px 8px;
	color: #333;
	line-height: 1;
}

.manhan-mobile-drawer__body {
	flex: 1;
	overflow-y: auto;
	padding: 8px 0;
}

/* ============================================================
   MOBILE MENU — accordion
   ============================================================ */

.manhan-mobile-menu {
	list-style: none;
	margin: 0;
	padding: 0;
}

.manhan-mobile-menu li {
	border-bottom: 1px solid #f0f0f0;
}

.manhan-mobile-menu a {
	display: block;
	padding: 13px 20px;
	text-decoration: none !important;   /* chặn global underline */
	color: inherit;
	font-family: inherit;
	font-size: inherit;
}

.manhan-mobile-menu a:hover { background: #f5f5f5; }

.manhan-mobile-menu-row {
	display: flex;
	align-items: stretch;
}

.manhan-mobile-menu-row > a { flex: 1; }

/* Toggle button */
.manhan-mobile-submenu-toggle {
	background: none;
	border: none;
	border-left: 1px solid #eee;
	padding: 0 18px;
	cursor: pointer;
	font-size: 1rem;
	color: #555;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
	flex-shrink: 0;
}

.manhan-mobile-submenu-toggle:hover { background: #f0f0f0; }

.manhan-mobile-submenu-toggle .toggle-arrow {
	display: inline-block;
	transition: transform 0.25s;
}

.manhan-mobile-submenu-toggle.is-open .toggle-arrow { transform: rotate(180deg); }

/* Sub-menu: max-height controlled by JS */
.manhan-mobile-menu .sub-menu {
	list-style: none;
	margin: 0;
	padding: 0;
	overflow: hidden;
	max-height: 0;
	transition: max-height 0.3s ease;
}

/* Không cần .is-open max-height rule — JS đặt giá trị cụ thể */

.manhan-mobile-menu .sub-menu a {
	padding-left: 36px;
	font-size: 0.9em;
	color: #555;
}

.manhan-mobile-menu .sub-menu .sub-menu a { padding-left: 52px; }

/* ============================================================
   BUTTON
   ============================================================ */
.manhan-hb-button {
	display: inline-block;
	padding: 9px 22px;
	background: var(--wp--preset--color--primary, #0073aa);
	color: #fff;
	text-decoration: none;
	border-radius: 4px;
	font-weight: 600;
	white-space: nowrap;
	transition: opacity 0.2s;
}
.manhan-hb-button:hover { opacity: 0.85; }

/* ============================================================
   PHONE
   ============================================================ */
.manhan-hb-phone {
	display: flex;
	align-items: center;
	gap: 4px;
}
.manhan-hb-phone a { text-decoration: none; color: inherit; font-weight: 600; }

/* ============================================================
   CART — badge nổi bật
   ============================================================ */
.manhan-hb-cart {
	position: relative;
	display: inline-flex;
	align-items: center;
	text-decoration: none;
	color: inherit;
	padding: 6px;
}
.manhan-hb-cart__icon {
	font-size: 1.5rem;
	line-height: 1;
}
.manhan-hb-cart__badge {
	position: absolute;
	top: -2px;
	right: -6px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	background: #e00;
	color: #fff;
	font-size: 0.72rem;
	font-weight: 700;
	font-family: -apple-system, sans-serif;
	border-radius: 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	box-shadow: 0 1px 4px rgba(200,0,0,0.4);
	border: 1.5px solid #fff;
}

/* ============================================================
   SEARCH FORM (inline)
   ============================================================ */
.manhan-hb-search-form { display: flex; align-items: center; }
.manhan-hb-search-input {
	padding: 7px 12px;
	border: 1px solid #ccc;
	border-radius: 4px 0 0 4px;
	outline: none;
	box-shadow: none;
}
.manhan-hb-search-input:focus {
	outline: none !important;
	box-shadow: none !important;
	border-color: #999;
}
.manhan-hb-search-submit {
	padding: 7px 12px;
	border: 1px solid #ccc;
	border-left: none;
	border-radius: 0 4px 4px 0;
	background: #f5f5f5;
	cursor: pointer;
}
.manhan-hb-search-icon-btn {
	background: none;
	border: none;
	font-size: 1.25rem;
	cursor: pointer;
	padding: 4px 8px;
	color: inherit;
}

/* ============================================================
   SEARCH POPUP
   ============================================================ */
.manhan-search-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.5);
	backdrop-filter: blur(4px);
	z-index: 19998;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s;
}
.manhan-search-overlay.is-visible {
	opacity: 1;
	pointer-events: auto;
}

.manhan-search-popup {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	z-index: 19999;
	background: #fff;
	padding: 10px 16px 20px;
	transform: translateY(-100%);
	transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
	box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.manhan-search-popup.is-open { transform: translateY(0); }

/* Layout: X trên cùng bên phải, form bên dưới 1 hàng */
.manhan-search-popup__inner {
	max-width: 640px;
	margin: 0 auto;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.manhan-search-popup__top-bar {
	display: flex;
	justify-content: flex-end;
}

.manhan-search-popup__close {
	background: none;
	border: none;
	font-size: 1.3rem;
	cursor: pointer;
	padding: 4px 6px;
	color: #666;
	line-height: 1;
}
.manhan-search-popup__close:hover { color: #000; }

/* Form 1 hàng, không xuống dòng */
.manhan-search-popup__form {
	display: flex;
	align-items: center;
	gap: 0;
}

.manhan-search-popup__input {
	flex: 1;
	min-width: 0;
	padding: 12px 14px;
	font-size: 1rem;
	border: 1px solid #ccc;
	border-radius: 4px 0 0 4px;
	outline: none;
	box-shadow: none;
	-webkit-appearance: none;
}
/* Xóa viền xanh khi focus — dùng custom border thay */
.manhan-search-popup__input:focus {
	outline: none;
	box-shadow: none;
	border-color: #999;
}

.manhan-search-popup__submit {
	flex-shrink: 0;
	padding: 12px 16px;
	font-size: 1rem;
	border: 1px solid #ccc;
	border-left: none;
	border-radius: 0 4px 4px 0;
	background: var(--wp--preset--color--primary, #0073aa);
	color: #fff;
	cursor: pointer;
	white-space: nowrap;
	transition: opacity 0.2s;
}
.manhan-search-popup__submit:hover { opacity: 0.85; }
