/*
 * MOBILE (≤ 849px) — nạp sau cùng, là quy chuẩn duy nhất cho khoảng cách trên điện thoại (thang 4/8, mỗi vai trò một biến):
 *   - Giữa 2 section: 40px (--hs-space-section).        - Chữ cách mép màn hình: 16px (--hs-gutter).
 *   - Tiêu đề section → nội dung: 16px (--hs-space-head). - Lề trong thẻ / khung / form: 16px (--hs-mobile-pad).
 *   - Giữa các thẻ, phần tử (gap, margin): 12px (--hs-mobile-gap, --hs-mobile-space).
 *   - Giữ nguyên: padding bên trong nút / ô nhập (vùng bấm ≥ 44px), margin auto (đẩy nút xuống đáy thẻ),
 *     khoảng chừa cho header ở hero / banner (header 64px + 16px).
 * Dùng !important có chủ đích: đây là lớp chuẩn hoá ghi đè hàng trăm giá trị riêng lẻ của component / Flatsome.
 */

@media (max-width: 849px) {

	:root {
		--hs-space-section: 40px;
		--hs-space-head: 16px;
		--hs-space-stack: 12px;
		--hs-gap: 12px;
		--hs-inset: 12px;
		--hs-gutter: 16px;
		--hs-mobile-space: 12px; /* Khoảng giữa phần tử (margin). */
		--hs-mobile-gap: 12px;   /* Khoảng giữa thẻ trong lưới / flex. */
		--hs-mobile-pad: 16px;   /* Lề trong thẻ, khung, form. */
		--hs-header-clear: 80px; /* Header mobile 64px + 16px. */

		/* Cỡ chữ mobile gọn (~15% nhỏ hơn). Ô nhập giữ 16px — iOS tự phóng to khi chữ ô nhập < 16px. */
		--hs-fs-display: 28px;
		--hs-fs-hero: 28px;
		--hs-fs-h1: 22px;
		--hs-fs-num: 26px;
		--hs-fs-h3: 18px;
		--hs-fs-h4: 16px;
		--hs-fs-h5: 16px;
		--hs-fs-title: 15px;
		--hs-fs-body: 14px;
		/* Icon nhỏ hơn một bậc trên điện thoại. */
		--hs-icon-xl: 44px;
		--hs-icon-lg: 40px;
		--hs-icon-md: 36px;
		--hs-icon-sm: 32px;
		--hs-icon-chip: 36px;
		--hs-icon-stat: 32px;
		--hs-icon-btn: 32px;
		--hs-icon-pill: 28px;
		--hs-btn-h: 44px;
		--hs-btn-pad: 20px;
		--hs-avatar: 40px;
		--hs-avatar-lg: 40px;
		--hs-fs-label: 12px;
	}

	html body,
	html body p,
	html body li {
		font-size: var(--hs-fs-body);
	}

	html body :is(input, select, textarea) {
		font-size: 16px !important;
	}

	/* ---- 1. Gap: mọi flex / grid trong nội dung, hero, banner, footer. ---- */
	:is(#main, .footer-wrapper, .hs-hero-x, .hs-banner, .hs-pdp__related) * {
		row-gap: var(--hs-mobile-gap) !important;
		column-gap: var(--hs-mobile-gap) !important;
	}

	/* ---- 2. Padding: thẻ, khung, form → 16px mọi cạnh; ô nhỏ (chip, bảng) → 12px. ---- */
	:is(
		.hs-chi-nhanh__item, .hs-collage__stat, .hs-contact-card, .hs-crosssell, .hs-feature, .hs-filter__form, .hs-form,
		.hs-hero-x__card, .hs-info, .hs-job, .hs-lookup__form, .hs-lookup__result, .hs-lookup__empty, .hs-media, .hs-pcard__body,
		.hs-pdp__alert, .hs-pdp__note, .hs-pdp__trust, .hs-quote, .hs-rating, .hs-side-card, .hs-stat, .hs-step-x, .hs-timeline__card,
		.hs-done__card, .hs-grid--panel, .hs-grid--white, .hs-scard, .hs-scard__body, .hs-post__body, .hs-review, .hs-price__note,
		.hs-booking, .hs-shop__empty, .hs-product, .hs-flow__item, .hs-help, .hs-dat-lich .wpcf7,
		.accordion-title, .accordion-inner, .hs-pdp__tabs .woocommerce-Tabs-panel
	) {
		padding: var(--hs-mobile-pad) !important;
	}

	.hs-sec .row.hs-row-panel:not(.row-collapse),
	.hs-sec .row.hs-board:not(.row-collapse) {
		padding: var(--hs-mobile-pad) !important;
	}

	:is(.hs-chip, .hs-sr, .hs-tags__list > li, .hs-clients__list > li) {
		padding: var(--hs-mobile-gap) !important;
	}

	:is(#main, .footer-wrapper) :is(td, th) {
		padding: 10px var(--hs-mobile-gap) !important;
	}

	:is(.hs-info__list, .hs-side-card__links) > li {
		padding-bottom: var(--hs-mobile-space) !important;
	}

	:is(.hs-article__content, .hs-shop__seo) {
		padding-top: 0 !important;
		padding-bottom: 0 !important;
	}

	.hs-search__count,
	html body .hs-pdp__tabs ul.tabs {
		margin-bottom: var(--hs-mobile-space) !important;
	}

	.hs-pdp__tabs .tab-panels {
		padding-top: 0 !important;
	}

	/* Vạch chia trong thẻ (padding 1 cạnh). */
	:is(.hs-job__meta, .hs-pcard__meta, .hs-review__name, .hs-done__row, .hs-filter__group, .hs-issue, .hs-post, .hs-hero-x__card-info) {
		padding-bottom: var(--hs-mobile-space) !important;
	}

	:is(.hs-info__hours, .hs-more, .hs-scard__more) {
		padding-top: var(--hs-mobile-space) !important;
	}

	/* ---- 3. Margin giữa phần tử → 8px (margin auto giữ nguyên vì không nằm trong danh sách). ---- */
	#main :is(
		.accordion, .hs-btn-wrap, .hs-checklist, .hs-chi-nhanh, .hs-contact-card, .hs-crosssell, .hs-done__rows, .hs-form, .hs-help,
		.hs-info, .hs-issue, .hs-pagination, .hs-price, .hs-quote, .hs-tags, .hs-timeline, .hs-heading__text, .hs-shop__seo,
		.hs-pdp__tabs, .hs-grid, .row + .row, .hs-heading + .hs-grid, .hs-heading + .row
	) {
		margin-top: var(--hs-mobile-space) !important;
	}

	:is(#main, .footer-wrapper) :is(
		.hs-eyebrow-line, .hs-tags__title, .hs-pdp__label, .hs-shop__cats, .hs-pdp__related-text, .hs-contact-card__title,
		.hs-newsletter__desc, .widget, .widget-title, .wpcf7-form, legend
	) {
		margin-bottom: var(--hs-mobile-space) !important;
	}

	.footer-wrapper .hs-brand__desc {
		margin: var(--hs-mobile-space) 0 !important;
	}

	/* Chữ trong bài / nội dung soạn thảo (thẻ không class): cách nhau 8px. */
	:is(#main, .footer-wrapper) :is(p, h2, h3, h4, h5, h6, ul, ol, dl, img, figure, blockquote, table):not([class]) {
		margin-top: 0 !important;
		margin-bottom: var(--hs-mobile-space) !important;
	}

	:is(#main, .footer-wrapper) :is(p, h2, h3, h4, h5, h6, ul, ol, dl, img, figure, blockquote, table):not([class]):last-child {
		margin-bottom: 0 !important;
	}

	:is(#main, .footer-wrapper) li:not([class]) {
		margin-bottom: 0 !important;
	}

	html body .hs-flow__item {
		margin: 0 !important;
	}

	/* ---- 4. Hero / banner: chừa header, đáy 16px; tiêu đề ↔ breadcrumb 8px. ---- */
	.hs-hero-x__panel,
	.hs-banner__panel {
		padding-top: var(--hs-header-clear) !important;
		padding-bottom: var(--hs-space-section) !important;
	}

	.hs-banner__panel > *:not(.hs-banner__bg),
	.hs-booking .hs-booking__row,
	.hs-hero-x__inner.hs-container {
		padding-right: var(--hs-gutter) !important;
		padding-left: var(--hs-gutter) !important;
	}

	.hs-booking {
		padding-right: 0 !important;
		padding-left: 0 !important;
	}

	/* ---- 5. Trang Flatsome (bài, tìm kiếm, cửa hàng, chi tiết) + footer. ---- */
	.hs-has-banner #content.blog-wrapper {
		padding-top: var(--hs-space-half) !important;
		padding-bottom: var(--hs-space-section) !important;
	}

	.hs-pdp__related {
		padding: var(--hs-space-section) 0 !important;
	}

	.hs-cpt__hero img {
		margin-bottom: var(--hs-mobile-space) !important;
	}

	.footer-wrapper .footer-1 {
		padding-top: var(--hs-space-section) !important;
		padding-bottom: var(--hs-mobile-space) !important;
	}

	.footer-wrapper .absolute-footer {
		padding-bottom: var(--hs-mobile-space) !important;
	}

	.footer-wrapper .absolute-footer > .container {
		padding: var(--hs-mobile-space) !important;
	}

	/* ---- 6. Hero gọn: ẩn thẻ minh hoạ để ô đặt lịch lộ ra ngay màn hình đầu. ---- */
	.hs-hero-x__card {
		display: none !important;
	}

	/* ---- 7. Vùng bấm ≥ 44px (chữ giữ nguyên, nới vùng chạm). ---- */
	:is(#header .nav-icon a, #header .header-search a, #logo a),
	:is(#main, .footer-wrapper) :is(
		.hs-more, .hs-scard__more, .hs-pill-link, .hs-chip-link, .hs-side-card__links a, .hs-info__list a,
		.hs-contact-card a, .hs-chi-nhanh a, .hs-post__title a, .hs-link-card a, .hs-active-chip, .hs-product__name a,
		.hs-post__more, .hs-brand__logo,
		.footer-1 .widget li a, .absolute-footer a, .hs-social a, .accordion-title
	) {
		display: inline-flex;
		align-items: center;
		min-width: 44px;
		min-height: 44px;
	}

	/* Nút +/- của accordion: giữ ô 36px như thiết kế, nới vùng bấm vô hình ra 44px. */
	.accordion-title .toggle {
		position: relative !important;
		overflow: visible;
	}

	.accordion-title .toggle::after {
		content: "";
		position: absolute;
		inset: -5px; /* 36px có viền 1px → vùng bấm 44px. */
	}

	.hs-banner__crumb a {
		display: inline-flex;
		align-items: center;
		min-height: 44px;
	}

	/* Header mobile: nút menu + nút tìm kiếm cùng một kiểu (tròn 44px) → hai bên cân, logo ở giữa. */
	#header .nav-icon a {
		justify-content: center;
		width: 44px;
		height: 44px;
		padding: 0;
		border-radius: 50%;
	}

	#header .nav-icon a {
		background: rgba(255, 255, 255, 0.1);
		color: var(--hs-white);
	}
}

/* Chân trang mobile: 2 cột menu cạnh nhau; ô nhận tin + nút cùng một hàng. */
@media (max-width: 849px) {

	.footer-1 .row > .widget_nav_menu {
		flex-basis: calc(50% - var(--hs-mobile-space) / 2) !important; /* hàng có gap 8px */
		max-width: calc(50% - var(--hs-mobile-space) / 2) !important;
	}

	.hs-newsletter__desc {
		max-width: none;
	}

	.hs-newsletter {
		flex-direction: row !important;
		align-items: flex-start !important;
		gap: var(--hs-mobile-space) !important;
	}

	.hs-newsletter .wpcf7-form-control-wrap {
		flex: 1;
		min-width: 0;
	}

	.hs-newsletter input[type="submit"] {
		padding: 0 20px;
	}
}

/* Thanh 3 nút cố định đáy (< 768px, floating-contact.css): chừa chỗ để không che chân trang. */
@media (max-width: 767px) {

	html body {
		padding-bottom: calc(56px + env(safe-area-inset-bottom)) !important;
	}
}

/* ---- Bố cục gọn trên điện thoại: bớt cuộn dọc mà không bớt nội dung. ---- */
@media (max-width: 767px) {

	/* Thống kê: 3 ô một hàng, bỏ icon trang trí. */
	.hs-grid:has(> .hs-stat) {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}

	.hs-grid > .hs-stat {
		gap: 4px !important;
		text-align: center;
		align-items: center;
	}

	.hs-grid > .hs-stat .hs-stat__icon {
		display: none;
	}

	.hs-grid > .hs-stat .hs-stat__label {
		font-size: var(--hs-fs-label);
		line-height: 1.3;
	}

	/* Chip dịch vụ: 3 cột. */
	.hs-grid:has(> .hs-chip) {
		grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
	}

	/* Đúng 4 chip: 2 × 2, không để một ô lẻ hàng dưới. */
	.hs-grid:has(> .hs-chip:nth-child(4):last-child) {
		grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
	}

	.hs-grid > .hs-chip .hs-chip__title {
		font-size: var(--hs-fs-label);
		line-height: 1.3;
	}

	/* Trang chủ: công trình, đánh giá, tin tức → dải vuốt ngang (thẻ sau ló ra để gợi ý vuốt). */
	.home :is(.hs-grid:has(> .hs-pcard), .hs-grid:has(> .hs-review), .hs-grid.hs-posts) {
		display: flex !important;
		overflow-x: auto;
		overscroll-behavior-x: contain;
		scroll-snap-type: x mandatory;
		scrollbar-width: none;
	}

	.home :is(.hs-grid:has(> .hs-pcard), .hs-grid:has(> .hs-review), .hs-grid.hs-posts)::-webkit-scrollbar {
		display: none;
	}

	.home :is(.hs-grid:has(> .hs-pcard), .hs-grid:has(> .hs-review), .hs-grid.hs-posts) > * {
		flex: 0 0 84%;
		scroll-snap-align: start;
	}
}


@media (max-width: 849px) {

	/* Logo ngang trên mobile: vừa khoảng giữa nút menu và nút tìm kiếm. */
	#header #logo img {
		height: 36px;
	}

	.hs-brand__img {
		height: 96px;
	}
}

/* Menu mobile (Flatsome off-canvas): nền trắng 95% làm nội dung phía sau lộ ra → nền đặc cho dễ đọc. */
html body .off-canvas .mfp-content:has(.mobile-sidebar) {
	background: var(--hs-white);
}

/* Menu mobile: mục đang xem nổi rõ (màu nhấn + vạch trái). */
html body .mobile-sidebar .nav > li.active > a {
	box-shadow: inset 3px 0 0 var(--hs-primary);
	color: var(--hs-primary);
	font-weight: 700;
}

@media (max-width: 849px) {

	/* Khung ảnh: ảnh phủ kín khung bo góc (lề 8px chung làm ảnh vuông góc nằm trong khung tròn). */
	html body .hs-media:not(.is-framed) {
		padding: 0 !important;
	}

	/* Khung có viền trắng: ảnh bo nhỏ hơn khung một bậc cho góc đồng tâm. */
	.hs-media.is-framed img {
		border-radius: 12px;
	}
}

@media (max-width: 849px) {

	/* Khung ảnh trên màn hình nhỏ: tỉ lệ ngang 3:2 thay chiều cao cố định 420px của desktop (ảnh bị cao hơn cả chiều ngang). */
	html body .hs-media:not(.is-framed) {
		height: auto;
		aspect-ratio: 3 / 2;
	}

	html body .hs-media.is-framed {
		height: auto;
	}

	html body .hs-media.is-framed img {
		height: auto;
		aspect-ratio: 3 / 2;
	}
}

/* ---- CTA trên điện thoại: vừa nội dung (không kéo hết chiều ngang), căn giữa, cao 44px. ---- */
@media (max-width: 849px) {

	/* Thanh đặt lịch nhanh: nút gửi. */
	html body .hs-booking .hs-booking__row :is(input[type="submit"], button[type="submit"]) {
		justify-self: center;
		width: auto;
		min-height: var(--hs-btn-h);
	}

	/* Nút gửi form, nút trong thẻ bên / thẻ dịch vụ. */
	html body :is(.hs-btn--submit, .hs-side-card .hs-btn, .hs-scard__more) {
		align-self: center;
		width: auto;
		margin: 0; /* Flatsome cho mọi nút lề phải + dưới 1em → nút lệch trái. */
	}

	/* Nhóm nút: hero, khối nút đơn, băng CTA. */
	.hs-btn-wrap {
		text-align: center;
	}

	/* Băng CTA căn giữa; nút trong hero căn trái cùng mép với tiêu đề + lời dẫn (xem mục taste bên dưới). */
	:is(.hs-cta, .hs-cta__body) {
		justify-content: center;
	}

	.hs-cta__body {
		align-items: center;
	}
}

@media (max-width: 849px) {

	/* Nút trong thẻ sản phẩm / chi tiết sản phẩm: một dòng, cao 44px (trước xuống 2 dòng khi có số điện thoại). */
	html body :is(.hs-product__btn, .hs-pdp__btn) {
		min-height: var(--hs-btn-h);
		padding: 0 12px;
		font-size: 13px;
		line-height: 1.2;
		white-space: nowrap;
	}
}

@media (max-width: 849px) {

	/* Thẻ dịch vụ xếp 1 cột: bỏ chiều cao tối thiểu của tiêu đề (chỉ cần để các thẻ cạnh nhau trên desktop thẳng hàng). */
	.hs-scard__title {
		min-height: 0;
	}
}

/* ---- Vùng nhìn mobile (rà theo taste): một trục đọc, không "hét" bằng chữ in hoa. ---- */
@media (max-width: 849px) {

	/* Tiêu đề hero: chữ thường có hoa đầu câu (in hoa toàn bộ + dấu tiếng Việt khó đọc trên màn nhỏ). */
	.hs-hero-x__title {
		letter-spacing: -0.02em;
		line-height: 1.2;
		text-transform: none;
	}

	/* Hero: nút chính + hotline thẳng mép trái với tiêu đề / lời dẫn (trước căn giữa → lệch trục). */
	.hs-hero-x__actions {
		justify-content: flex-start;
		align-items: flex-start;
	}

	/* Tiêu đề section: luôn căn trái trên điện thoại → mắt đọc theo một trục, không nhảy trái / giữa xen kẽ. */
	.hs-heading--center {
		text-align: left;
	}

	.hs-heading--center .hs-eyebrow-line {
		justify-content: flex-start;
	}

	.hs-heading--center .hs-heading__text {
		margin-right: 0;
		margin-left: 0;
	}
}

/* ---- Màn hình đầu trang chủ (taste): một hành động chính, một trục căn trái 16px. ---- */
@media (max-width: 849px) {

	/* Hero chỉ còn nhãn + tiêu đề + lời dẫn: form đặt lịch ngay bên dưới là hành động chính,
	 * "Gọi ngay" / "Đặt lịch sửa" đã có ở thanh cố định đáy màn hình → bỏ cụm nút trùng lặp. */
	.hs-hero-x__actions {
		display: none !important;
	}

	/* Form đặt lịch nhanh: ô nhập thẳng mép 16px với chữ ở hero (trước lề khung + lề hàng = 32px). */
	html body .hs-booking .hs-booking__row {
		padding-right: 0 !important;
		padding-left: 0 !important;
	}

	/* Nút gửi rộng bằng các ô (chuẩn form trên điện thoại), chữ + mũi tên căn giữa. */
	html body .hs-booking .hs-booking__row :is(input[type="submit"], button[type="submit"]) {
		justify-self: stretch;
		justify-content: center;
		width: 100%;
	}
}
