/* =============================================================================
 * WooFilterX — frontend.css (component bộ lọc frontend)
 * Mọi class tiền tố vnwfx-. Base utility ở vnwfx.css.
 * ========================================================================== */

.vnwfx-filter-root { position: relative; }

/* Self mode: panel | kết quả (2 cột desktop). */
.vnwfx-filter-root.is-self {
	display: grid;
	grid-template-columns: 280px 1fr;
	gap: 24px;
	align-items: start;
}
@media (max-width: 860px) {
	.vnwfx-filter-root.is-self { grid-template-columns: 1fr; }
}

/* ===== Layout thanh ngang ===== */
.vnwfx-filter-root.is-horizontal { display: block; }

.vnwfx-filter-bar {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 10px;
	background: var(--vnwfx-card);
	border-radius: var(--vnwfx-radius);
	box-shadow: var(--vnwfx-shadow-sm);
	margin-bottom: 12px;
}
.vnwfx-bar-item { position: relative; }
.vnwfx-bar-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var(--vnwfx-line);
	border-radius: 999px;
	background: #fff;
	color: var(--vnwfx-ink);
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.15s var(--vnwfx-ease);
	white-space: nowrap;
}
.vnwfx-bar-btn:hover { border-color: var(--vnwfx-primary); color: var(--vnwfx-primary-dark); }
.vnwfx-bar-btn.is-open,
.vnwfx-bar-btn.is-active {
	background: var(--vnwfx-primary-soft);
	border-color: var(--vnwfx-primary);
	color: var(--vnwfx-primary-dark);
}
.vnwfx-bar-master { font-weight: 600; }
.vnwfx-bar-master.is-open { background: var(--vnwfx-primary); border-color: var(--vnwfx-primary); color: #fff; }
.vnwfx-bar-caret { display: inline-flex; transition: transform 0.2s var(--vnwfx-ease); }
.vnwfx-bar-btn.is-open .vnwfx-bar-caret { transform: rotate(180deg); }

.vnwfx-bar-backdrop { position: fixed; inset: 0; z-index: 40; }

.vnwfx-bar-panel {
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	z-index: 50;
	min-width: 350px;
	max-width: 480px;
	padding: 16px;
}
.vnwfx-mega {
	position: absolute;
	left: 0;
	right: 0;
	z-index: 50;
	padding: 20px;
	margin-top: -4px;
}
.vnwfx-mega-grid {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 18px 24px;
}
@media (max-width: 720px) {
	.vnwfx-mega-grid { grid-template-columns: 1fr; }
}
.vnwfx-mega-title { display: block; margin-bottom: 8px; }
.vnwfx-mega-foot,
.vnwfx-bar-panel-foot { border-top: 1px solid var(--vnwfx-line); padding-top: 12px; }

/* Chip lựa chọn (pill) — dùng trong panel/mega */
.vnwfx-opt-chip {
	padding: 7px 14px;
	border: 1px solid var(--vnwfx-line);
	border-radius: 999px;
	background: #fff;
	color: var(--vnwfx-ink);
	font-size: 13px;
	cursor: pointer;
	transition: all 0.15s var(--vnwfx-ease);
}
.vnwfx-opt-chip:hover { border-color: var(--vnwfx-primary); }
.vnwfx-opt-chip.is-active {
	background: var(--vnwfx-primary);
	border-color: var(--vnwfx-primary);
	color: #fff;
}
.vnwfx-opt-chip small { opacity: 0.7; }

/* ===== View toggle list / grid ===== */
.vnwfx-view-toggle {
	display: inline-flex;
	border: 1px solid var(--vnwfx-line);
	border-radius: var(--vnwfx-radius-sm);
	overflow: hidden;
}
.vnwfx-view-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border: 0;
	background: #fff;
	color: var(--vnwfx-ink-soft);
	cursor: pointer;
	transition: all 0.15s var(--vnwfx-ease);
	margin: 0px;
}
.vnwfx-view-btn + .vnwfx-view-btn { border-left: 1px solid var(--vnwfx-line); }
.vnwfx-view-btn.is-active { background: var(--vnwfx-primary); color: #fff; }

/* =============================================================================
 * Lưới sản phẩm (chỉ self mode — không đụng theme ở replace mode)
 * ========================================================================== */
/* Số cột lấy từ builder qua biến --wfx-cols (đặt bằng JS). */
.wfx-self-grid ul.products {
	display: grid !important;
	grid-template-columns: repeat(var(--wfx-cols, 4), minmax(0, 1fr));
	gap: 18px;
	margin: 0;
	padding: 0;
	list-style: none;
	
}
.tax-product_cat{
	.wfx-self-grid ul.products{
		&::before,&::after{
			display:none;
		}
		.onsale{
			width: 120px;
			height: 30px;
			font-size: 14px;
			background:none;
			color: #000;
		}
	}
}

@media (max-width: 768px) { .wfx-self-grid ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; } }
@media (max-width: 480px) { .wfx-self-grid ul.products { grid-template-columns: 1fr !important; } }

/* Card sản phẩm */
.wfx-self-grid ul.products li.product {
	float: none !important;
	width: auto !important;
	max-width: 100% !important;
	margin: 0 !important;
	padding: 12px;
	list-style: none;
	background: #fff;
	border: 1px solid var(--vnwfx-line);
	border-radius: var(--vnwfx-radius);
	display: flex;
	flex-direction: column;
	position: relative;
	transition: transform 0.18s var(--vnwfx-ease), box-shadow 0.18s var(--vnwfx-ease);
}
.wfx-self-grid ul.products li.product:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}
.wfx-self-grid ul.products li.product a.woocommerce-LoopProduct-link {
	display: flex;
	flex-direction: column;
	text-decoration: none;
	color: inherit;
	.onsale{
		position: absolute;
		inset: 12px;
	}
}
.wfx-self-grid ul.products li.product img {
	width: 100%;
	height: auto;
	margin: 0 0 10px;
	border-radius: 10px;
	aspect-ratio: 1 / 1;
	object-fit: cover;
}
.wfx-self-grid ul.products li.product .woocommerce-loop-product__title {
	font-size: 14px;
	font-weight: 600;
	line-height: 1.4;
	margin: 0 0 8px;
	color: var(--vnwfx-ink);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	min-height: 2.8em;
}
.wfx-self-grid ul.products li.product .price {
	color:#E02B20;
	font-weight: 700;
	font-size: 15px;
	margin: 0 0 10px;
}
.wfx-self-grid ul.products li.product .price del {
	color: var(--vnwfx-ink-soft);
	font-weight: 400;
	font-size: 13px;
	margin-right: 6px;
}
.wfx-self-grid ul.products li.product .price ins { text-decoration: none; }
.wfx-self-grid ul.products li.product .star-rating {
	color: #f5a623;
	font-size: 13px;
	margin: 0 0 8px;
}
.wfx-self-grid ul.products li.product a.button,
.wfx-self-grid ul.products li.product a.added_to_cart {
	margin-top: auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 9px 12px;
	border: 0;
	border-radius: var(--vnwfx-radius-sm);
	background: var(--vnwfx-primary);
	color: #fff;
	font-size: 13px;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	transition: background 0.15s var(--vnwfx-ease);
}
.wfx-self-grid ul.products li.product a.button:hover,
.wfx-self-grid ul.products li.product a.added_to_cart:hover { background: var(--vnwfx-primary-dark); }
.wfx-self-grid ul.products li.product a.added_to_cart {
	background: transparent;
	color: var(--vnwfx-primary-dark);
	margin-top: 6px;
	padding: 4px;
	font-size: 12px;
}

/* List view: xếp dọc, card hàng ngang */
.wfx-grid-slot.is-view-list ul.products {
	display: block !important;
	grid-template-columns: none !important;
}
.wfx-grid-slot.is-view-list ul.products li.product {
	width: 100% !important;
	max-width: 100% !important;
	float: none !important;
	clear: both;
	margin: 0 0 14px !important;
}
.wfx-self-grid.is-view-list ul.products li.product a.woocommerce-LoopProduct-link {
	display: grid;
	grid-template-columns: 110px 1fr;
	gap: 16px;
	align-items: center;
}
.wfx-self-grid.is-view-list ul.products li.product img {
	width: 110px !important;
	margin: 0 !important;
}
.wfx-self-grid.is-view-list ul.products li.product .woocommerce-loop-product__title {
	min-height: 0;
	-webkit-line-clamp: 3;
}
.wfx-self-grid.is-view-list ul.products li.product a.button { align-self: start; margin-top: 10px; }

/* Panel bộ lọc */
.vnwfx-filter-panel { overflow: hidden; }
.vnwfx-panel-body { padding-bottom: 12px; }
.vnwfx-filter-group:first-child { border-top: 0; }
.vnwfx-filter-group { padding: 4px 0; }
.vnwfx-acc-body { padding-bottom: 8px; }

/* Toolbar kết quả */
.vnwfx-toolbar { flex-wrap: wrap; gap: 12px; }
.vnwfx-toolbar select {
	font-size: 14px;
	background: #fff;
}

/* Search box trong filter */
.vnwfx-search-box { background: #fff; }
.vnwfx-search-box:focus-within {
	border-color: var(--vnwfx-primary);
	box-shadow: 0 0 0 3px var(--vnwfx-primary-ring);
}

/* Lưới sản phẩm khi tải lại (mờ nhẹ) */
.wfx-grid-slot { transition: opacity 0.2s var(--vnwfx-ease); }

/* Nút mở drawer — ẩn trên desktop */
.vnwfx-filter-toggle { display: none; }
.vnwfx-drawer-close { display: none; }
.vnwfx-panel-foot { display: none; }
.vnwfx-drawer-overlay { display: none; }

/* ----- Mobile: off-canvas drawer ----- */
@media (max-width: 860px) {
	.wfx-grid-slot.is-view-list ul.products{
		display: flex !important;
		flex-direction: column;
	}
	.vnwfx-filter-toggle {
		display: inline-flex;
		position: sticky;
		top: 8px;
		z-index: 20;
		margin-bottom: 12px;
	}

	/* Lớp phủ tối cho cả sidebar drawer & mega thanh ngang */
	.vnwfx-drawer-overlay,
	.vnwfx-bar-backdrop {
		display: block;
		position: fixed;
		inset: 0;
		background: rgba(0, 0, 0, 0.45);
		z-index: 99998;
		animation: vnwfx-fade-in 0.2s var(--vnwfx-ease);
	}
	@keyframes vnwfx-fade-in { from { opacity: 0; } to { opacity: 1; } }

	/* ===== Bottom sheet kiểu iOS (trượt từ dưới lên) ===== */
	.vnwfx-filter-panel,
	.vnwfx-mega {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		top: auto;
		width: 100%;
		max-width: none;
		max-height: 85vh;
		margin: 0;
		z-index: 99999;
		border-radius: var(--vnwfx-radius-lg) var(--vnwfx-radius-lg) 0 0;
		box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
		display: flex;
		flex-direction: column;
		overflow: hidden;
	}
	/* Tay nắm kéo (grab handle) iOS */
	.vnwfx-filter-panel::before,
	.vnwfx-mega::before {
		content: "";
		flex-shrink: 0;
		width: 40px;
		height: 4px;
		margin: 8px auto 6px;
		border-radius: 999px;
		background: #d1d1d6;
	}

	/* Panel sidebar: ẩn dưới đáy, trượt lên khi .is-open */
	.vnwfx-filter-panel {
		transform: translateY(100%);
		transition: transform 0.32s var(--vnwfx-ease);
	}
	.vnwfx-filter-panel.is-open { transform: translateY(0); }
	.vnwfx-filter-panel .vnwfx-panel-head { flex-shrink: 0; }
	.vnwfx-filter-panel .vnwfx-panel-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

	/* Mega (thanh ngang) thành bottom sheet, tự trượt lên */
	.vnwfx-mega { animation: vnwfx-sheet-up 0.32s var(--vnwfx-ease); }
	.vnwfx-mega .vnwfx-mega-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
	@keyframes vnwfx-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

	/* Foot dính đáy sheet */
	.vnwfx-panel-foot,
	.vnwfx-mega-foot {
		flex-shrink: 0;
		position: sticky;
		bottom: 0;
		background: #fff;
		display: flex;
	}

	/* Thanh ngang trên mobile: chỉ giữ nút "Bộ lọc" tổng (+ nút toggle), ẩn dropdown lẻ */
	.vnwfx-filter-bar .vnwfx-bar-item { display: none; }

	.vnwfx-drawer-close { display: inline-flex; }
}

/* Tôn trọng prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
	.vnwfx-filter-panel,
	.vnwfx-mega,
	.wfx-grid-slot { transition: none !important; animation: none !important; }
}
