/* Header — _nav_top.php, js/header.js */

#header.site-header {
	--hdr-top-h: 40px;
	--hdr-main-h: 84px;
	--hdr-primary: #174EBD;
	--hdr-ink: #1e293b;
	position: sticky;
	top: calc(var(--hdr-top-h) * -1); /* แถบบนเลื่อนหายไป แถบหลักติดอยู่ด้านบน */
	z-index: 1050; /* สูงกว่าปุ่มติดต่อลอย (1035) เพื่อให้เมนูมือถือทับได้ */
	font-family: 'Sarabun', sans-serif;
}

/* ---- แถบบน ---- */
.site-header__top {
	height: var(--hdr-top-h);
	background: linear-gradient(90deg, #0b1630, #13306b);
	color: #cbd5e1;
	font-size: 14px;
}

.site-header__top .container {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	height: 100%;
}

.site-header__info {
	display: flex;
	align-items: center;
	gap: 24px;
	min-width: 0;
}

.site-header__info a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: #e2e8f0 !important;
	text-decoration: none !important;
	white-space: nowrap;
	transition: color 0.2s ease;
}

.site-header__info a:hover {
	color: #FFF !important;
}

.site-header__info i {
	color: #60a5fa;
}

.site-header__info i.fa-line {
	color: #4ade80;
	font-size: 16px;
}

.site-header__social {
	display: flex;
	align-items: center;
	gap: 6px;
}

.site-header__social > a {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 8px;
	background: rgba(255, 255, 255, 0.08);
	color: #e2e8f0 !important;
	font-size: 14px;
	text-decoration: none !important;
	transition: background 0.2s ease;
}

.site-header__social > a:hover {
	background: var(--hdr-primary);
	color: #FFF !important;
}

/* ปุ่มถูกใจ Facebook (แสดงหลังผู้ใช้ยินยอมคุกกี้เพื่อการตลาด) */
.site-header__like {
	display: flex;
	align-items: center;
	height: var(--hdr-top-h);
	margin-right: 8px;
	overflow: hidden;
}

/* ---- แถบหลัก ---- */
.site-header__main {
	background: rgba(255, 255, 255, 0.94);
	-webkit-backdrop-filter: saturate(180%) blur(12px);
	backdrop-filter: saturate(180%) blur(12px);
	border-bottom: 1px solid rgba(15, 23, 42, 0.06);
	transition: box-shadow 0.25s ease, background 0.25s ease;
}

#header.is-scrolled .site-header__main {
	background: rgba(255, 255, 255, 0.98);
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.site-header__main .container {
	display: flex;
	align-items: center;
	gap: 24px;
	height: var(--hdr-main-h);
}

.site-header__logo {
	display: block;
	flex-shrink: 0;
}

.site-header__logo img {
	display: block;
	width: auto;
	height: 56px;
	transform-origin: left center;
	transition: transform 0.25s ease;
}

/* ย่อโลโก้ตอนเลื่อน (ใช้ transform ไม่เปลี่ยนความสูง header หน้าจึงไม่กระตุก) */
#header.is-scrolled .site-header__logo img {
	transform: scale(0.86);
}

/* ---- เมนู ---- */
.site-header__nav {
	margin-left: auto;
}

.site-header__nav > ul {
	display: flex;
	align-items: center;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-header__nav a,
.site-header__admin {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 10px 16px;
	border: 0;
	border-radius: 999px;
	background: none;
	color: var(--hdr-ink) !important;
	font-family: inherit;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none !important;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
}

.site-header__nav a:hover,
.site-header__admin:hover,
.site-header__dropdown.is-open .site-header__admin {
	background: #f1f5f9;
	color: var(--hdr-primary) !important;
}

.site-header__nav a.is-active,
.site-header__admin.is-active {
	background: #eef3fd;
	color: var(--hdr-primary) !important;
}

.site-header__nav a:focus-visible,
.site-header__admin:focus-visible,
.site-header__cta:focus-visible,
.site-header__toggle:focus-visible {
	outline: 3px solid rgba(37, 99, 235, 0.35);
	outline-offset: 2px;
}

/* dropdown แอดมิน */
.site-header__dropdown {
	position: relative;
}

.site-header__caret {
	font-size: 11px;
	transition: transform 0.2s ease;
}

.site-header__dropdown:hover .site-header__caret,
.site-header__dropdown.is-open .site-header__caret {
	transform: rotate(180deg);
}

.site-header__submenu {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	min-width: 230px;
	margin: 0;
	padding: 8px;
	border-radius: 14px;
	background: #FFF;
	box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
	list-style: none;
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

/* พื้นที่ว่างเหนือเมนูย่อย กันเมนูปิดตอนเลื่อนเมาส์ลงมา */
.site-header__submenu::before {
	content: "";
	position: absolute;
	top: -10px;
	left: 0;
	right: 0;
	height: 10px;
}

.site-header__dropdown:hover .site-header__submenu,
.site-header__dropdown:focus-within .site-header__submenu,
.site-header__dropdown.is-open .site-header__submenu {
	opacity: 1;
	visibility: visible;
	transform: none;
}

.site-header__nav .site-header__submenu a {
	display: flex;
	width: 100%;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 10px;
	color: #374151 !important;
	font-size: 15px;
}

.site-header__nav .site-header__submenu a i {
	width: 18px;
	color: #6591EA;
	text-align: center;
}

/* ---- ปุ่มด้านขวา ---- */
.site-header__actions {
	display: flex;
	align-items: center;
	gap: 10px;
}

.site-header__cta {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 11px 20px;
	border-radius: 999px;
	background: linear-gradient(135deg, #2563eb, #174EBD);
	box-shadow: 0 8px 20px rgba(23, 78, 189, 0.28);
	color: #FFF !important;
	font-size: 15px;
	font-weight: 700;
	text-decoration: none !important;
	white-space: nowrap;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.site-header__cta:hover {
	transform: translateY(-1px);
	box-shadow: 0 12px 26px rgba(23, 78, 189, 0.35);
}

/* ปุ่มเมนูมือถือ (แฮมเบอร์เกอร์) */
.site-header__toggle {
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 5px;
	width: 46px;
	height: 46px;
	padding: 0;
	border: 0;
	border-radius: 12px;
	background: #eef3fd;
	cursor: pointer;
}

.site-header__toggle span {
	display: block;
	width: 20px;
	height: 2px;
	border-radius: 2px;
	background: var(--hdr-primary);
}

/* ---- เมนูมือถือ (drawer) ---- */
html.site-drawer-open {
	overflow: hidden;
}

/* ตอนเปิดให้ visible ทันที (โฟกัสปุ่มปิดได้) ตอนปิดค่อยซ่อนหลังเลื่อนออกเสร็จ */
.site-drawer {
	position: fixed;
	inset: 0;
	visibility: hidden;
	pointer-events: none;
	transition: visibility 0s linear 0.3s;
}

.site-drawer.is-open {
	visibility: visible;
	pointer-events: auto;
	transition: visibility 0s;
}

.site-drawer__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, 0.5);
	opacity: 0;
	transition: opacity 0.3s ease;
}

.site-drawer.is-open .site-drawer__backdrop {
	opacity: 1;
}

.site-drawer__panel {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	width: min(86vw, 360px);
	overflow-y: auto;
	background: #FFF;
	box-shadow: -20px 0 50px rgba(15, 23, 42, 0.2);
	transform: translateX(100%);
	transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.site-drawer.is-open .site-drawer__panel {
	transform: none;
}

.site-drawer__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px 14px 20px;
	border-bottom: 1px solid #eef0f3;
}

.site-drawer__head img {
	display: block;
	width: auto;
	height: 40px;
}

.site-drawer__close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: #f1f5f9;
	color: #475569;
	font-size: 18px;
	cursor: pointer;
}

.site-drawer__nav {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 10px 12px;
}

.site-drawer__nav a {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 11px 12px;
	border-radius: 12px;
	color: var(--hdr-ink) !important;
	font-size: 17px;
	font-weight: 600;
	text-decoration: none !important;
}

.site-drawer__nav a i {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 38px;
	height: 38px;
	border-radius: 10px;
	background: #f1f5f9;
	color: var(--hdr-primary);
	font-size: 16px;
}

.site-drawer__nav a:hover {
	background: #f8fafc;
}

.site-drawer__nav a.is-active {
	background: #eef3fd;
	color: var(--hdr-primary) !important;
}

.site-drawer__nav a.is-active i {
	background: var(--hdr-primary);
	color: #FFF;
}

.site-drawer__label {
	padding: 10px 24px 0;
	color: #94a3b8;
	font-size: 13px;
	font-weight: 700;
}

.site-drawer__contact {
	display: grid;
	gap: 10px;
	margin-top: auto;
	padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
	border-top: 1px solid #eef0f3;
}

.site-drawer__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 12px 16px;
	border: 1px solid #e2e8f0;
	border-radius: 999px;
	color: var(--hdr-ink) !important;
	font-size: 16px;
	font-weight: 700;
	text-decoration: none !important;
}

.site-drawer__btn--phone {
	border-color: transparent;
	background: linear-gradient(135deg, #2563eb, #174EBD);
	color: #FFF !important;
}

.site-drawer__btn--line {
	border-color: transparent;
	background: #06C755;
	color: #FFF !important;
}

/* ---- Responsive ---- */
@media (max-width: 1199px) {
	.site-header__main .container {
		gap: 16px;
	}

	.site-header__nav a,
	.site-header__admin {
		padding: 9px 12px;
		font-size: 15.5px;
	}

	.site-header__email {
		display: none !important;
	}
}

@media (max-width: 991px) {
	#header.site-header {
		--hdr-main-h: 72px;
	}

	.site-header__nav,
	.site-header__cta {
		display: none;
	}

	.site-header__actions {
		margin-left: auto;
	}

	.site-header__toggle {
		display: flex;
	}

	.site-header__logo img {
		height: 48px;
	}
}

@media (max-width: 767px) {
	#header.site-header {
		--hdr-top-h: 0px;
		--hdr-main-h: 64px;
	}

	/* มือถือมีแถบติดต่อด้านล่างจออยู่แล้ว (widget-fab.php) จึงซ่อนแถบบน */
	.site-header__top {
		display: none;
	}

	.site-header__logo img {
		height: 42px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.site-header__logo img,
	.site-header__submenu,
	.site-drawer__panel,
	.site-drawer__backdrop {
		transition: none;
	}
}
