/* --------------------------------------------------------------------------
 * DWAI TV - Premium Video Frontend CSS
 * Assumes the existence of generic variables injected via shortcode or theme.
 * Fallbacks are provided if variables are missing.
 * -------------------------------------------------------------------------- */

:root {
	/* Fallbacks in case settings injection is disabled and theme doesn't provide them */
	--dwai-theme-blue-fb: var(--dwai-theme-blue, #193a70);
	--dwai-primary-blue-fb: var(--dwai-primary-blue, #005ea5);
	--dwai-orange-accent-fb: var(--dwai-orange-accent, #f58426);
	--dwai-text-dark-fb: var(--dwai-text-dark, #333333);
	--dwai-text-light-fb: var(--dwai-text-light, #757575);
	--dwai-border-color-fb: var(--dwai-border-color, #e2e8f0);
	--dwai-background-soft-fb: var(--dwai-background-soft, #f8f9fa);
}

/* ------------------------
 * Gallery Filtering
 * ------------------------ */
.dwai-tv-gallery-container {
	margin: 2rem 0;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.dwai-tv-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	margin-bottom: 2rem;
	justify-content: center;
}

.dwai-filter-btn {
	background-color: var(--dwai-background-soft-fb);
	color: var(--dwai-text-dark-fb);
	border: 1px solid var(--dwai-border-color-fb);
	padding: 0.5rem 1.25rem;
	border-radius: 30px;
	cursor: pointer;
	font-weight: 500;
	font-size: 0.95rem;
	transition: all 0.3s ease;
}

.dwai-filter-btn:hover,
.dwai-filter-btn.active {
	background-color: var(--dwai-theme-blue-fb);
	color: #ffffff;
	border-color: var(--dwai-theme-blue-fb);
	transform: translateY(-2px);
	box-shadow: 0 4px 10px rgba(25, 58, 112, 0.2);
}

/* ------------------------
 * Grid Layout
 * ------------------------ */
.dwai-video-grid {
	display: grid;
	gap: 2rem;
	grid-template-columns: repeat(3, 1fr);
}

.dwai-video-grid.dwai-cols-1 { grid-template-columns: 1fr; }
.dwai-video-grid.dwai-cols-2 { grid-template-columns: repeat(2, 1fr); }
.dwai-video-grid.dwai-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
	.dwai-video-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 640px) {
	.dwai-video-grid { grid-template-columns: 1fr !important; }
}

/* ------------------------
 * Grid Item / Cards
 * ------------------------ */
.dwai-grid-item {
	display: block;
	transition: opacity 0.4s ease, transform 0.4s ease;
}
.dwai-grid-item.hide {
	display: none;
}

.dwai-video-card-link {
	display: block;
	text-decoration: none !important;
	background: #fff;
	border-radius: 14px;
	overflow: hidden;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
	transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
	border: 1px solid rgba(0,0,0,0.03);
}

.dwai-video-card-link:hover {
	transform: translateY(-8px);
	box-shadow: 0 16px 32px rgba(25, 58, 112, 0.12);
}

.dwai-video-card-thumbnail {
	position: relative;
	width: 100%;
	padding-top: 56.25%; /* 16:9 Aspect Ratio */
	background-size: cover;
	background-position: center;
	background-color: var(--dwai-background-soft-fb);
	transition: filter 0.3s ease;
}

.dwai-video-card-link:hover .dwai-video-card-thumbnail {
	filter: brightness(0.9);
}

.dwai-fallback-thumb {
	background: linear-gradient(135deg, var(--dwai-theme-blue-fb), var(--dwai-primary-blue-fb));
	display: flex;
	align-items: center;
	justify-content: center;
}

.dwai-fallback-logo {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: rgba(255, 255, 255, 0.2);
	font-weight: 900;
	font-size: 2rem;
	letter-spacing: 2px;
}

.dwai-hover-video-preview {
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	transition: opacity 0.4s ease;
	z-index: 1;
}

/* Custom play button styling */
.dwai-custom-play-img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	border-radius: 50%;
}

/* Persistent Grid Play Button */
.dwai-grid-play-btn {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 60px;
	height: 60px;
	z-index: 2;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(25, 58, 112, 0.85); /* Theme blue with opacity */
	border-radius: 50%;
	transition: all 0.3s ease;
}

.dwai-video-card-link:hover .dwai-grid-play-btn {
	transform: translate(-50%, -50%) scale(1.1);
	background: rgba(25, 58, 112, 1);
}

.dwai-grid-play-btn svg {
	width: 30px;
	height: 30px;
	margin-left: 4px;
}

/* Play indicator on hover */
.dwai-play-hover-indicator {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(0.8);
	width: 60px;
	height: 60px;
	background: rgba(25, 58, 112, 0.85); /* Theme blue with opacity */
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	opacity: 0;
	transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dwai-video-card-link:hover .dwai-play-hover-indicator {
	opacity: 1;
	transform: translate(-50%, -50%) scale(1);
}

.dwai-play-hover-indicator svg {
	width: 30px;
	height: 30px;
	margin-left: 4px;
}

.dwai-card-duration {
	position: absolute;
	bottom: 10px;
	right: 10px;
	background: rgba(0, 0, 0, 0.7);
	color: #fff;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 0.8rem;
	font-weight: 500;
}

.dwai-video-card-content {
	padding: 1.25rem;
}

.dwai-card-title {
	margin: 0 0 0.5rem 0 !important;
	font-size: 1.1rem !important;
	color: var(--dwai-text-dark-fb) !important;
	font-weight: 600 !important;
	line-height: 1.4 !important;
	transition: color 0.3s ease;
}

.dwai-video-card-link:hover .dwai-card-title {
	color: var(--dwai-primary-blue-fb) !important;
}

.dwai-card-cat {
	font-size: 0.85rem;
	color: var(--dwai-orange-accent-fb);
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* ------------------------
 * Single Video Page / Player
 * ------------------------ */
.dwai-single-container {
	max-width: 1000px;
	margin: 0 auto;
	padding: 2rem 1rem;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.dwai-single-video-header {
	margin-bottom: 2rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 1rem;
}

.dwai-single-title {
	margin: 0 !important;
	font-size: 2.8rem !important;
	color: var(--dwai-theme-blue-fb) !important;
	font-weight: 800 !important;
	letter-spacing: -0.5px;
}

.dwai-back-btn {
	display: inline-block;
	color: var(--dwai-primary-blue-fb);
	text-decoration: none;
	font-weight: 600;
	font-size: 1rem;
	transition: color 0.3s ease;
}

.dwai-back-btn:hover {
	color: var(--dwai-orange-accent-fb);
}

/* ------------------------
 * The Player Container (Lazy loaded)
 * ------------------------ */
.dwai-single-video-wrapper {
	position: relative;
	width: 100%;
	padding-top: 56.25%; /* 16:9 Aspect Ratio */
	border-radius: 20px;
	overflow: hidden;
	box-shadow: 0 24px 48px rgba(0, 0, 0, 0.15);
	background: #000;
	cursor: pointer;
	will-change: transform;
	transition: transform 0.4s ease;
}

.dwai-single-video-wrapper:hover {
	transform: scale(1.01);
}

.dwai-video-poster {
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	background-size: cover;
	background-position: center;
	z-index: 2;
	transition: opacity 0.5s ease;
}

/* Dark overlay gradient */
.dwai-video-poster::after {
	content: '';
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	background: linear-gradient(to bottom, rgba(0,0,0,0) 50%, rgba(0,0,0,0.6) 100%);
	z-index: 1;
}

.dwai-play-btn-overlay {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 80px;
	height: 80px;
	background: rgba(25, 58, 112, 0.85); /* Theme blue with opacity */
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
	z-index: 3;
	box-shadow: 0 4px 20px rgba(25, 58, 112, 0.5);
	transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dwai-single-video-wrapper:hover .dwai-play-btn-overlay {
	transform: translate(-50%, -50%) scale(1.1);
	background: rgba(25, 58, 112, 1);
	box-shadow: 0 6px 25px rgba(25, 58, 112, 0.7);
}

.dwai-play-btn-overlay svg {
	width: 40px;
	height: 40px;
	margin-left: 6px;
}

.dwai-video-duration {
	position: absolute;
	bottom: 20px;
	right: 20px;
	background: rgba(0,0,0,0.8);
	color: #fff;
	padding: 6px 12px;
	border-radius: 6px;
	font-weight: 600;
	z-index: 3;
}

.dwai-iframe-dock {
	position: absolute;
	top: 0; left: 0; right: 0; bottom: 0;
	z-index: 1; /* Below poster until played */
}

.dwai-iframe-dock iframe,
.dwai-iframe-dock video {
	width: 100%;
	height: 100%;
	border: 0;
	outline: none;
}

/* When playing, hide poster, bring iframe to top */
.dwai-single-video-wrapper.is-playing .dwai-video-poster {
	opacity: 0;
	pointer-events: none;
}
.dwai-single-video-wrapper.is-playing .dwai-iframe-dock {
	z-index: 5;
}

.dwai-video-watermark {
	position: absolute;
	bottom: 20px;
	right: 20px;
	height: auto;
	z-index: 10;
	pointer-events: none;
	opacity: 0.8;
	transition: opacity 0.3s ease;
}

.dwai-single-video-wrapper:hover .dwai-video-watermark {
	opacity: 1;
}

@media (max-width: 768px) {
	.dwai-video-watermark {
		bottom: 10px;
		right: 10px;
	}
}

.dwai-single-content {
	margin-top: 2.5rem;
	font-size: 1.1rem;
	line-height: 1.8;
	color: var(--dwai-text-dark-fb);
}

/* ------------------------
 * Interactions & Share Bar
 * ------------------------ */
.dwai-video-interactions-bar {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	margin-top: 1.5rem;
	padding: 1.5rem 0;
	border-top: 1px solid var(--dwai-border-color-fb);
	border-bottom: 1px solid var(--dwai-border-color-fb);
	gap: 1rem;
}

.dwai-video-stats {
	display: flex;
	gap: 1.5rem;
	align-items: center;
}

.dwai-stat {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 1.05rem;
	font-weight: 600;
	color: var(--dwai-text-light-fb);
	background: none;
	border: none;
	padding: 0;
	cursor: default;
}

.dwai-stat svg {
	width: 24px;
	height: 24px;
}

.dwai-like-btn {
	cursor: pointer;
	transition: color 0.3s ease;
}

.dwai-like-btn:hover {
	color: var(--dwai-theme-blue-fb);
}

.dwai-like-btn.liked {
	color: var(--dwai-orange-accent-fb);
}
.dwai-like-btn.liked svg {
	fill: var(--dwai-orange-accent-fb);
}

.dwai-video-share {
	display: flex;
	align-items: center;
	gap: 1rem;
}

.dwai-share-label {
	font-weight: 600;
	color: var(--dwai-text-dark-fb);
}

.dwai-share-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background-color: var(--dwai-background-soft-fb);
	color: var(--dwai-theme-blue-fb);
	text-decoration: none;
	transition: all 0.3s ease;
	border: none;
	cursor: pointer;
}

.dwai-share-icon svg {
	width: 20px;
	height: 20px;
}

.dwai-share-icon:hover {
	background-color: var(--dwai-theme-blue-fb);
	color: #fff;
	transform: translateY(-3px);
	box-shadow: 0 5px 15px rgba(25, 58, 112, 0.2);
}

.dwai-share-wa:hover {
	background-color: #25D366;
	color: #fff;
}

/* Embed Code Wrapper */
.dwai-embed-code-wrapper {
	margin-top: 1rem;
	background: var(--dwai-background-soft-fb);
	padding: 1rem;
	border-radius: 8px;
	transition: all 0.3s ease;
}
.dwai-embed-code-wrapper.hide {
	display: none;
}
.dwai-embed-code-wrapper textarea {
	width: 100%;
	border: 1px solid var(--dwai-border-color-fb);
	border-radius: 4px;
	padding: 0.5rem;
	font-family: monospace;
	resize: none;
}

/* Toast */
#dwai-toast-message {
	position: fixed;
	bottom: 30px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--dwai-theme-blue-fb);
	color: #fff;
	padding: 10px 20px;
	border-radius: 30px;
	font-weight: 600;
	box-shadow: 0 10px 30px rgba(0,0,0,0.2);
	z-index: 9999;
	transition: opacity 0.3s ease, transform 0.3s ease;
}
.dwai-toast-hide {
	opacity: 0;
	pointer-events: none;
	transform: translate(-50%, 20px) !important;
}
