/* FIX CLS: CSS tối ưu cho Video Playlist với Video.js - Anti Layout Shift */
.video-playlist-wrapper {
	display: flex;
	flex-direction: column;
	align-items: center;
	background-color: #1a1a1a;
	padding: 10px;
	max-width: 1280px;
	margin: 0 auto;
	max-height: 90vh;
	overflow-y: auto;
	/* FIX CLS: Đặt chiều cao tối thiểu để tránh layout shift */
	min-height: 300px;
	/* FIX CLS: Prevent layout shift during Video.js initialization */
	contain: layout style;
}

/* FIX: Khi chỉ có 1 video, loại bỏ khoảng trống thừa */
.video-playlist-wrapper.single-video {
	min-height: auto;
	padding: 10px 10px 0 10px;
}

/* FIX CLS: Container video chính với aspect ratio cố định cho Video.js */
.main-video-container {
	width: 100%;
	position: relative;
	background-color: black;
	/* FIX CLS: Aspect ratio cố định ngay từ đầu */
	aspect-ratio: 16/9;
	max-height: none !important;
	height: auto;
	/* FIX CLS: Prevent Video.js from causing layout shift */
	contain: layout style;
	overflow: hidden;
	/* FIX CLS: Lock dimensions during Video.js initialization */
	box-sizing: border-box;
}

/* FIX CLS: Pre-setup container for Video.js to prevent shift */
.main-video-container.vjs-container-ready {
	display: block;
	box-sizing: border-box;
	/* FIX CLS: Force stable dimensions */
	min-height: 0; /* Prevent height expansion */
}

/* FIX CLS: Video.js specific styling to prevent layout shift */
.video-js {
	width: 100% !important;
	height: 100% !important;
	position: relative !important;
	display: block !important;
	box-sizing: border-box;
	/* FIX CLS: Prevent Video.js from changing container size during init */
	max-width: none !important;
	max-height: none !important;
	/* FIX CLS: Critical - prevent any size changes during initialization */
	transition: none !important;
}

/* FIX CLS: Lock Video.js dimensions during initialization */
.video-js:not(.vjs-ready) {
	transition: none !important;
	transform: none !important;
}

/* FIX CLS: Video.js player styling - force exact positioning */
.video-js .vjs-tech {
	width: 100% !important;
	height: 100% !important;
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	object-fit: contain;
	/* FIX CLS: Prevent video element from resizing */
	transition: none !important;
	transform: none !important;
}

/* FIX CLS: Prevent Video.js poster from causing layout shift */
.video-js .vjs-poster {
	width: 100% !important;
	height: 100% !important;
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	object-fit: contain;
	background-size: contain !important;
	background-position: center !important;
	background-repeat: no-repeat !important;
}

/* FIX CLS: Video.js control bar positioning */
.video-js .vjs-control-bar {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 30px;
	/* FIX CLS: Prevent control bar from affecting container height */
	box-sizing: border-box;
}

/* FIX CLS: Video.js big play button positioning */
.video-js .vjs-big-play-button {
	position: absolute !important;
	top: 50% !important;
	left: 50% !important;
	transform: translate(-50%, -50%) !important;
	/* FIX CLS: Prevent button from affecting layout */
	z-index: 3;
	/*  margin: 0 !important; */
}

/* FIX CLS: Video.js loading spinner */
.video-js .vjs-loading-spinner {
	position: absolute !important;
	top: 50% !important;
	left: 50% !important;
	transform: translate(-50%, -50%) !important;
	z-index: 2;
}

/* FIX CLS: Video.js responsive container override */
.video-js-responsive-container {
	width: 100% !important;
	position: relative !important;
	aspect-ratio: 16/9 !important;
	height: auto !important;
}

/* FIX CLS: Prevent Video.js fluid mode from changing container */
.video-js.vjs-fluid {
	padding-top: 0 !important;
	height: 100% !important;
	width: 100% !important;
}

/* FIX CLS: Override Video.js default responsive behavior */
.video-js.vjs-fluid:not(.vjs-audio-only-mode) {
	padding-top: 0 !important;
}

/* FIX CLS: Container playlist với chiều cao cố định */
.video-playlist-container {
	width: 100%;
	min-height: 76px; /* 60px video + 16px padding */
	position: relative;
	/* FIX CLS: Prevent playlist from causing layout shift */
	contain: layout style;
}

/* NEW: Playlist wrapper for scroll overlay */
.playlist-wrapper {
	position: relative;
	overflow: hidden;
	width: 100%;
}

/* NEW: Scroll indicator overlay */
.scroll-indicator {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	width: 40px;
	background: linear-gradient(to right, transparent, rgba(0,0,0,0.8));
	color: white;
	font-size: 16px;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease;
	z-index: 10;
	border-radius: 0 4px 4px 0;
}

/* Hiện khi cần */
.scroll-indicator.show {
	opacity: 1;
}

/* CSS riêng cho icon fa-angles-right */
.scroll-indicator .fa-angles-right {
	position: absolute;
	top: 40%;
	left: 50%;
	transform: translate(-50%, -50%);
	animation: slideRight 1s ease-in-out infinite;
	text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

@keyframes slideRight {
	0%, 100% {
		transform: translateX(0);
	}
	50% {
		transform: translateX(5px);
	}
}

/* FIX CLS: Playlist với chiều cao cố định và scroll horizontal */
.video-playlist {
	display: flex;
	gap: 10px;
	padding: 8px;
	margin: 0;
	list-style: none;
	/* FIX CLS: Đặt chiều cao cố định để tránh layout shift */
	min-height: 60px;
	align-items: center;
	/* NEW: Horizontal scroll */
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: thin;
	scrollbar-color: #888 #1a1a1a;
	/* FIX CLS: Prevent playlist from causing layout shift */
	contain: layout style;
}

/* NEW: Enhanced scrollbar styling for playlist */
.video-playlist::-webkit-scrollbar {
	height: 4px;
}

.video-playlist::-webkit-scrollbar-track {
	background: #1a1a1a;
	border-radius: 2px;
}

.video-playlist::-webkit-scrollbar-thumb {
	background: #888;
	border-radius: 2px;
	transition: background 0.3s ease;
}

.video-playlist::-webkit-scrollbar-thumb:hover {
	background: #555;
}

/* FIX CLS: Items playlist với kích thước cố định */
.video-playlist li {
	position: relative;
	cursor: pointer;
	/* NEW: Flex shrink để không bị co lại */
	flex-shrink: 0;
	/* FIX CLS: Kích thước cố định để tránh layout shift */
	width: 120px;
	height: 60px;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	border: 2px solid transparent;
	/* FIX CLS: Box-sizing để tính toán chính xác */
	box-sizing: border-box;
	border-radius: 4px;
	overflow: hidden;
	/* NEW: Min-width để đảm bảo không bị co */
	min-width: 120px;
	/* FIX CLS: Prevent individual items from causing shift */
	contain: layout style;
}

/* FIX CLS: Hover effect không ảnh hưởng layout */
.video-playlist li:hover {
	/* FIX CLS: Chỉ dùng transform, không thay đổi kích thước */
	transform: translateY(-2px) scale(1.02);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
	border-color: #555;
	z-index: 1;
	/* FIX CLS: Optimize rendering */
	will-change: transform;
}

/* FIX CLS: Video duration label - tương thích với script của bạn */
.video-playlist li .video-duration {
	position: absolute;
	top: 2px;
	right: 2px;
	background-color: rgba(0, 0, 0, 0.8);
	color: #ffffffb0;
	padding: 2px 6px;
	font-size: 12px;
	font-weight: bold;
	border-radius: 3px;
	/* FIX CLS: Đảm bảo duration label không ảnh hưởng layout */
	pointer-events: none;
	z-index: 2;
	/* FIX CLS: Đặt min-width để tránh text shifting */
	min-width: 32px;
	text-align: center;
	/* FIX CLS: Smooth transition khi duration load */
	opacity: 0;
	transition: opacity 0.3s ease;
	/* FIX CLS: Prevent label from affecting parent layout */
	box-sizing: border-box;
}

/* FIX CLS: Hiển thị duration sau khi load */
.video-playlist li .video-duration:not(:empty) {
	opacity: 1;
}

/* FIX #6: Dùng img thay vì video cho thumbnail — tránh lỗi type HLS */
.video-playlist li img.playlist-thumb,
.video-playlist li video {
	width: 120px;
	height: 60px;
	background-color: black;
	display: block;
	object-fit: cover;
	box-sizing: border-box;
	border-radius: 2px;
}

/* FIX CLS: Thumbnail container */
.thumbnail-container {
	width: 120px;
	height: 60px;
	position: relative;
	overflow: hidden;
	border-radius: 2px;
	/* FIX CLS: Prevent container from shifting */
	box-sizing: border-box;
}

/* FIX CLS: Placeholder khi video chưa load */
.video-playlist li .video-placeholder {
	width: 120px;
	height: 60px;
	background-color: #333;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #888;
	font-size: 12px;
	position: absolute;
	top: 0;
	left: 0;
	box-sizing: border-box;
}

/* FIX CLS: Loading state cho video */
.video-loading {
	opacity: 1;
	transition: opacity 0.3s ease;
}

.video-loaded {
	opacity: 1;
}

/* Overlay playing không ảnh hưởng layout */
.video-playlist li .overlay-playing {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.6);
	color: white;
	display: flex;
	justify-content: center;
	align-items: center;
	font-size: 14px;
	font-weight: bold;
	opacity: 0;
	transition: opacity 0.3s ease;
	/* FIX CLS: Không ảnh hưởng layout */
	pointer-events: none;
	border-radius: 2px;
	box-sizing: border-box;
}

.video-playlist li.playing .overlay-playing {
	opacity: 1;
}

/* Enhanced scrollbar styling for container */
.video-playlist-container::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

.video-playlist-container::-webkit-scrollbar-track {
	background-color: #1a1a1a;
	border-radius: 10px;
}

.video-playlist-container::-webkit-scrollbar-thumb {
	background-color: #555;
	border-radius: 10px;
	border: 2px solid #1a1a1a;
	transition: background-color 0.3s ease;
}

.video-playlist-container::-webkit-scrollbar-thumb:hover {
	background-color: #3498db;
	border-width: 1px;
}

/* Enhanced scrollbar for Firefox */
.video-playlist-container {
	scrollbar-width: thin;
	scrollbar-color: #838383 #000000;
	background: #1f1f1f;
}

/* FIX CLS: Responsive styles với kích thước cố định */
@media (max-width: 768px) {
	.video-playlist-wrapper {
		flex-direction: column;
		padding: 5px;
		/* FIX CLS: Chiều cao tối thiểu cho mobile */
		min-height: 300px;
	}

	/* FIX: Mobile single video */
	.video-playlist-wrapper.single-video {
		min-height: auto;
		padding: 5px 5px 0 5px;
	}

	/* FIX CLS: Video chính mobile với aspect ratio */
	.main-video-container {
		aspect-ratio: 16/9;
		max-height: none !important;
		height: auto;
	}

	/* FIX CLS: Video.js mobile styling */
	.video-js {
		width: 100% !important;
		height: 100% !important;
	}

	/* FIX CLS: Container playlist mobile */
	.video-playlist-container {
		/* FIX CLS: Chiều cao tối thiểu cho mobile */
		min-height: 66px; /* 56px video + 10px padding */
	}

	/* NEW: Scroll indicator mobile */
	.scroll-indicator {
		width: 30px;
		font-size: 14px;
	}

	/* FIX CLS: Items playlist mobile với kích thước cố định */
	.video-playlist li {
		width: 100px;
		height: 56px;
		min-width: 100px;
	}

	/* FIX CLS: Container thumbnail mobile */
	.thumbnail-container {
		width: 100px;
		height: 56px;
	}

	/* FIX CLS: Video/img thumbnail mobile */
	.video-playlist li video,
	.video-playlist li img.playlist-thumb {
		width: 100px;
		height: 56px;
	}

	/* FIX CLS: Placeholder mobile */
	.video-playlist li .video-placeholder {
		width: 100px;
		height: 56px;
	}

	/* FIX CLS: Duration label mobile */
	.video-playlist li .video-duration {
		font-size: 10px;
		padding: 1px 4px;
		min-width: 28px;
	}
}

/* FIX CLS: Tablet responsive */
@media (max-width: 1024px) and (min-width: 769px) {
	.video-playlist-wrapper {
		max-width: 100%;
		padding: 8px;
	}

	/* FIX: Tablet single video */
	.video-playlist-wrapper.single-video {
		min-height: auto;
		padding: 8px 8px 0 8px;
	}

	.main-video-container {
		max-height: none !important;
		height: auto;
	}

	/* FIX CLS: Video.js tablet styling */
	.video-js {
		width: 100% !important;
		height: 100% !important;
	}

	/* NEW: Scroll indicator tablet */
	.scroll-indicator {
		width: 35px;
		font-size: 15px;
	}
}

/* FIX CLS: Large screen optimization */
@media (min-width: 1281px) {
	.video-playlist-wrapper {
		max-width: 1400px;
	}

	/* FIX: Large screen single video */
	.video-playlist-wrapper.single-video {
		min-height: auto;
		padding: 10px 10px 0 10px;
	}
}

/* FIX CLS: Preload skeleton cho better UX */
.video-skeleton {
	width: 120px;
	height: 60px;
	background: linear-gradient(90deg, #333 25%, #555 50%, #333 75%);
	background-size: 200% 100%;
	animation: skeleton-loading 1.5s infinite;
	box-sizing: border-box;
}

@media (max-width: 768px) {
	.video-skeleton {
		width: 100px;
		height: 56px;
	}
}

@keyframes skeleton-loading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* FIX CLS: Focus states for accessibility */
.video-playlist li:focus {
	outline: 2px solid #3498db;
	outline-offset: 2px;
}

/* FIX CLS: Video.js focus states */
.video-js:focus,
.video-js .vjs-big-play-button:focus {
	outline: 2px solid #3498db;
	outline-offset: 2px;
}

/* NEW: Hover effect for scroll indicator */
.scroll-indicator:hover {
	background: linear-gradient(to right, transparent, rgba(0,0,0,0.9));
}

/* NEW: Smooth scroll behavior */
.video-playlist {
	scroll-behavior: smooth;
}

/* NEW: Better visual feedback for scrollable content */
.playlist-wrapper:hover .scroll-indicator.show {
	opacity: 0.8;
}

/* NEW: Pulse animation for scroll indicator when first shown */
.scroll-indicator.show.pulse {
	animation: pulse-scroll 1s ease-in-out;
}

@keyframes pulse-scroll {
	0%, 100% {
		opacity: 0.8;
		transform: scale(1);
	}
	50% {
		opacity: 1;
		transform: scale(1.05);
	}
}

/* FIX CLS: Critical - Prevent Video.js from overriding aspect ratios */
.video-js.vjs-dimensions-16-9,
.video-js.vjs-dimensions-4-3 {
	width: 100% !important;
	height: 100% !important;
	padding-top: 0 !important;
	/* FIX CLS: Disable any Video.js size transitions */
	transition: none !important;
}

/* FIX CLS: Prevent Video.js responsive behavior from breaking layout */
.video-js.vjs-responsive {
	width: 100% !important;
	height: 100% !important;
	padding-top: 0 !important;
	transition: none !important;
}

/* FIX CLS: Override any Video.js inline styles that might cause CLS */
.video-js[style] {
	width: 100% !important;
	height: 100% !important;
}

/* FIX CLS: CRITICAL - Disable all Video.js transitions during initialization */
.video-js:not(.vjs-ready) * {
	transition: none !important;
	transform: none !important;
	animation: none !important;
}

/* FIX CLS: Force Video.js wrapper to maintain container size */
.video-js-responsive-container .video-js {
	position: absolute !important;
	top: 0 !important;
	left: 0 !important;
	width: 100% !important;
	height: 100% !important;
}

/* --------   show/hide play button -------- */
/* FIX: Big play button visibility states - chỉ control hiển thị, không thay đổi style */
.video-js.vjs-paused .vjs-big-play-button {
	display: block !important;
	opacity: 1 !important;
	visibility: visible !important;
}

.video-js.vjs-playing .vjs-big-play-button {
	display: none !important;
	opacity: 0 !important;
	visibility: hidden !important;
}

.video-js.vjs-ended .vjs-big-play-button {
	display: block !important;
	opacity: 1 !important;
	visibility: visible !important;
}

/* FIX: Show button khi user inactive và video paused */
.video-js.vjs-user-inactive.vjs-paused .vjs-big-play-button {
	display: block !important;
	opacity: 1 !important;
	visibility: visible !important;
}

/* FIX: Handle loading states - chỉ hide khi đang load content mới */
.video-js.vjs-waiting:not(.vjs-paused) .vjs-big-play-button {
	display: none !important;
}

.video-js.vjs-waiting.vjs-paused .vjs-big-play-button {
	display: block !important;
	opacity: 1 !important;
	visibility: visible !important;
}

/* FIX: Override inline styles có thể hide button */
.video-js.vjs-paused .vjs-big-play-button[style*="display: none"] {
	display: block !important;
}

.video-js.vjs-ended .vjs-big-play-button[style*="display: none"] {
	display: block !important;
}

.video-js.vjs-paused .vjs-big-play-button[style*="visibility: hidden"] {
	visibility: visible !important;
}

.video-js.vjs-ended .vjs-big-play-button[style*="visibility: hidden"] {
	visibility: visible !important;
}

.video-js.vjs-paused .vjs-big-play-button[style*="opacity: 0"] {
	opacity: 1 !important;
}

.video-js.vjs-ended .vjs-big-play-button[style*="opacity: 0"] {
	opacity: 1 !important;
}

/* FORCE HIDE: Tắt tất cả remote playback controls */
video::-webkit-media-controls-wireless-playback-picker-button,
video::-webkit-media-controls-airplay-picker-button,
video::-webkit-media-controls-start-playback-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    -webkit-appearance: none !important;
    pointer-events: none !important;
}

/* FORCE HIDE: Video.js remote playback controls - tất cả các tên có thể */
.video-js .vjs-airplay-control,
.video-js .vjs-airplay-button,
.video-js .vjs-chromecast-button,
.video-js .vjs-chromecast-control,
.video-js .vjs-cast-button,
.video-js .vjs-cast-control,
.video-js .vjs-remote-playback-button,
.video-js .vjs-wireless-button,
.video-js [class*="chromecast"],
.video-js [class*="airplay"],
.video-js [class*="cast"],
.video-js [class*="wireless"],
.video-js [class*="remote"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* FORCE HIDE: Bất kỳ button nào có icon cast */
.video-js button[title*="cast" i],
.video-js button[title*="chromecast" i],
.video-js button[title*="airplay" i],
.video-js button[aria-label*="cast" i],
.video-js button[aria-label*="chromecast" i],
.video-js button[aria-label*="airplay" i] {
    display: none !important;
    visibility: hidden !important;
}

/* FORCE HIDE: CSS cho các icon SVG cast */
.video-js svg[class*="cast"],
.video-js svg[class*="chromecast"],
.video-js svg[class*="airplay"],
.video-js .vjs-icon-cast,
.video-js .vjs-icon-chromecast,
.video-js .vjs-icon-airplay {
    display: none !important;
    visibility: hidden !important;
}