/**
 * UF Before / After
 */
.ufl-ba {
	--ufl-ba-pos: 50%;
	--ufl-ba-radius: var(--ufl-r-lg, 16px);
	--ufl-ba-handle: #ffffff;
}

.ufl-ba__stage {
	position: relative;
	width: 100%;
	height: clamp(280px, 50vw, 520px);
	overflow: hidden;
	border-radius: var(--ufl-ba-radius);
	background: #0f172a;
	isolation: isolate;
	touch-action: pan-y;
	box-shadow: var(--ufl-shadow-sm, 0 4px 12px -4px rgba(15, 23, 42, 0.12));
}

.ufl-ba--ratio-16x9 .ufl-ba__stage { height: auto; aspect-ratio: 16 / 9; }
.ufl-ba--ratio-4x3 .ufl-ba__stage  { height: auto; aspect-ratio: 4 / 3; }
.ufl-ba--ratio-3x2 .ufl-ba__stage  { height: auto; aspect-ratio: 3 / 2; }
.ufl-ba--ratio-1x1 .ufl-ba__stage  { height: auto; aspect-ratio: 1 / 1; }
.ufl-ba--ratio-4x5 .ufl-ba__stage  { height: auto; aspect-ratio: 4 / 5; }

.ufl-ba--vertical .ufl-ba__stage {
	touch-action: pan-x;
}

.ufl-ba__stage .ufl-ba__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	user-select: none;
	-webkit-user-drag: none;
}

/* Ảnh SAU bị cắt theo vị trí tay nắm. */
.ufl-ba__img--after {
	clip-path: inset(0 0 0 var(--ufl-ba-pos));
}

.ufl-ba--vertical .ufl-ba__img--after {
	clip-path: inset(var(--ufl-ba-pos) 0 0 0);
}

/* Range input đặt trước .ufl-ba__handle để keyboard :focus-visible ~ .ufl-ba__handle hoạt động chuẩn. */
.ufl-ba__range {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: ew-resize;
	z-index: 3;
	appearance: none;
	-webkit-appearance: none;
	background: transparent;
}

/* Hướng dọc: writing-mode vertical-lr + direction ltr đồng bộ 0% (trên) -> 100% (dưới). */
.ufl-ba--vertical .ufl-ba__range {
	cursor: ns-resize;
	writing-mode: vertical-lr;
	direction: ltr;
}

.ufl-ba__handle {
	position: absolute;
	top: 0;
	bottom: 0;
	left: var(--ufl-ba-pos);
	width: 2px;
	margin-left: -1px;
	background: var(--ufl-ba-handle);
	box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
	z-index: 2;
	pointer-events: none;
}

.ufl-ba--vertical .ufl-ba__handle {
	top: var(--ufl-ba-pos);
	bottom: auto;
	left: 0;
	right: 0;
	width: auto;
	height: 2px;
	margin: -1px 0 0;
}

.ufl-ba__handle::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 2.85rem;
	height: 2.85rem;
	transform: translate(-50%, -50%);
	border-radius: var(--ufl-r-pill, 9999px);
	background: var(--ufl-ba-handle) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 6 4 12l5 6M15 6l5 6-5 6'/%3E%3C/svg%3E") center / 58% no-repeat;
	box-shadow: 0 6px 20px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(15, 23, 42, 0.08);
	transition: box-shadow 160ms ease, transform 160ms ease;
}

.ufl-ba--vertical .ufl-ba__handle::after {
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23111827' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6-5 6 5M6 15l6 5 6-5'/%3E%3C/svg%3E");
}

.ufl-ba__range:focus-visible ~ .ufl-ba__handle::after,
.ufl-ba__stage:has(.ufl-ba__range:focus-visible) .ufl-ba__handle::after {
	outline: 3px solid var(--ufl-primary, #446084);
	outline-offset: 3px;
	box-shadow: 0 0 0 6px var(--ufl-primary-soft, rgba(68, 96, 132, 0.22)), 0 8px 24px rgba(15, 23, 42, 0.38);
	transform: translate(-50%, -50%) scale(1.06);
}

.ufl-ba__label {
	position: absolute;
	top: 0.85rem;
	z-index: 2;
	padding: 0.28rem 0.7rem;
	border-radius: var(--ufl-r-pill, 9999px);
	background: rgba(15, 23, 42, 0.68);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	color: #fff;
	font-size: 0.75rem;
	font-weight: 600;
	line-height: 1.4;
	letter-spacing: 0.03em;
	pointer-events: none;
}

.ufl-ba__label--before {
	left: 0.85rem;
}

.ufl-ba__label--after {
	right: 0.85rem;
}

/* Chế độ dọc: nhãn Trước ở trên-giữa, nhãn Sau ở dưới-giữa. */
.ufl-ba--vertical .ufl-ba__label--before {
	top: 0.85rem;
	bottom: auto;
	left: 50%;
	right: auto;
	transform: translateX(-50%);
}

.ufl-ba--vertical .ufl-ba__label--after {
	top: auto;
	bottom: 0.85rem;
	left: 50%;
	right: auto;
	transform: translateX(-50%);
}

.ufl-ba--no-labels .ufl-ba__label {
	display: none;
}
