:root {
	--sidebar-w: 340px;
	--gap: 0.75rem;
	--padding: 5px; /* Outer padding reduced */
	--top-bar-h: 60px;
	--highlight-color: #ffd580; /* Hover color */
	--active-color: #ffaa00; /* Active channel color */
	--stunning-glow: #00ffff; /* Secondary glow color (now mostly unused) */
}

html,
body {
	margin: 0;
	padding: 0;
	background-color: #121212;
	font-family: Ubuntu, Arial, sans-serif;
	color: white;
	height: 100%;
	width: 100%;
	overflow: hidden;
}

a {
	color: #888;
	font-size: 12px;
	text-decoration: none;
}
a:hover {
	color: white;
}

/* ========================================================================= */
/* LAYOUT: CSS Grid for Desktop (Video + Sidebar) */
/* ========================================================================= */

.main-area {
	display: grid;
	grid-template-columns: 1fr var(--sidebar-w);
	grid-template-rows: var(--top-bar-h) 1fr;
	gap: var(--gap);
	padding: var(--padding);
	box-sizing: border-box;
	height: 100%;
	width: 100%;
}

/* TOP BAR - Grid Row 1, Column 1 */
.top-bar {
	grid-column: 1 / 2;
	grid-row: 1;

	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: #2a2a2a;
	padding: 8px 12px;
	border-radius: 0.75rem;
	box-sizing: border-box;
	height: var(--top-bar-h);
	z-index: 1;
	margin: 0;
}
.logo-container img {
	height: 46px;
	object-fit: contain;
}

.top-bar-controls {
	display: flex;
	gap: 8px;
}

.top-bar-btn {
	background-color: #383838;
	color: white;
	border: none;
	padding: 8px 15px;
	border-radius: 6px;
	font-size: 0.9rem;
	font-weight: 500;
	cursor: pointer;
	transition:
		background-color 0.2s ease,
		transform 0.1s ease;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.top-bar-btn:hover {
	background-color: #4a4a4a;
}

.top-bar-btn.active {
	background-color: var(--highlight-color);
	color: #121212;
	font-weight: 700;
}

/* VIDEO CONTAINER - Grid Row 2, Column 1 */
.video-container {
	grid-column: 1 / 2;
	grid-row: 2;

	position: relative;
	border-radius: 0.75rem;
	overflow: hidden;
	background-color: #2a2a2a;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* SIDEBAR - Grid Column 2, spans both rows */
.sidebar {
	grid-column: 2 / 3;
	grid-row: 1 / 3;

	width: 100%;
	height: 100%;
	background-color: #222;
	color: pink;
	border-radius: 0.75rem;
	display: flex;
	flex-direction: column;
	box-sizing: border-box;
	padding: 12px;
	position: relative; /* Important for hover preview */
	z-index: 1;
	box-shadow: -6px 8px 30px rgba(0, 0, 0, 0.6);
	overflow-x: hidden;
}

/* JW Player Styling */
#player {
	width: 100% !important;
	height: 100% !important;
	position: absolute !important;
	top: 0;
	left: 0;
	background-color: #000;
}

#playerPlaceholder {
	width: 100%;
	height: 100%;
	object-fit: contain;
	position: absolute;
	z-index: 1;
}

#player .jw-svg-icon-buffer {
	background-image: url("https://s4.gifyu.com/images/bL7xg.gif");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 80px 80px;
	width: 80px;
	height: 80px;
	opacity: 0.8;
}
#player .jw-controlbar {
	background: linear-gradient(
		to top,
		rgba(255, 213, 128, 0.5),
		rgba(18, 18, 18, 0.2)
	) !important;
	backdrop-filter: blur(6px);
}
#player .jw-slider-volume .jw-knob,
#player .jw-slider-volume .jw-progress {
	background-color: var(--highlight-color) !important;
}
#player .jw-slider-time .jw-progress {
	background-color: var(--highlight-color) !important;
}
#player .jw-slider-time .jw-buffer {
	background-color: #ffebb5 !important;
}
#player .jw-button-color,
#player .jw-icon {
	color: rgba(124, 252, 0, 0.6) !important;
	fill: rgba(124, 252, 0, 0.6) !important;
	transition: color 0.3s ease;
}
#player .jw-svg-icon-buffer path,
#player .jw-rightclick,
#player .jw-error,
#player .jw-overlay-error,
#player .jw-error-msg,
#player .jw-text,
#player .jw-error-text,
#player .jw-reset-text {
	display: none !important;
}
/* ... (End of JW Player CSS) ... */

/* --- MODIFIED: Sidebar Header for Layout Control --- */
.sidebar-header {
	display: flex;
	flex-wrap: wrap; /* DESKTOP: Allows wrapping to create two lines */
	gap: 12px;
	align-items: center;
	flex-shrink: 0;
}

.sidebar-header .search-box {
	flex-grow: 1; /* Search input takes available space */
}

.sidebar-header .category-toggle {
	width: 100%; /* DESKTOP: Forces category toggle to the next line */
}

.search-box {
	padding: 0.65rem 0.85rem;
	border-radius: 0.375rem;
	border: none;
	background-color: #2a2a2a;
	color: white;
	font-size: 0.86rem;
	outline: none;
}
.icon-btn {
	background-color: #2a2a2a;
	border: none;
	color: pink;
	font-size: 1rem;
	padding: 0.6rem 0.8rem;
	border-radius: 0.5rem;
	cursor: pointer;
	transition: 0.15s;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.icon-btn:hover {
	background-color: #333;
}

/* Category Toggle and Modal */
.category-toggle {
	display: flex;
	align-items: center;
	justify-content: space-between;
	background: #2a2a2a;
	color: pink;
	padding: 10px 14px;
	border-radius: 10px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s ease;
	user-select: none;
}
.category-toggle span {
	display: flex;
	align-items: center;
	gap: 8px;
}
.category-toggle:hover {
	background: #333;
}
.category-modal {
	background: #2a2a2a;
	border-radius: 0.5rem;
	margin-top: 8px;
	padding: 0;
	max-height: 0;
	overflow-y: hidden;
	opacity: 0;
	flex-shrink: 0;
	transition:
		max-height 300ms ease,
		opacity 200ms ease,
		padding 200ms ease;
}
.category-modal.open {
	max-height: 420px;
	opacity: 1;
	padding: 10px;
	overflow-y: auto;
	overflow-x: hidden;
}
.category-row {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 10px;
}
.category-item {
	display: flex;
	align-items: center;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	gap: 8px;
	background: #252525;
	border-radius: 0.5rem;
	padding: 8px 10px;
	cursor: pointer;
	transition:
		transform 140ms ease,
		background 140ms ease;
	user-select: none;
}
.category-item:hover {
	transform: translateY(-2px);
	background: #303030;
}
.category-item.active {
	background: #444;
}
.category-item i {
	color: pink;
	width: 22px;
	text-align: center;
	flex-shrink: 0;
}

/* CHANNEL LIST CONTAINER (Scrollable Area) */
.channels {
	flex-grow: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding-top: 14px;
	padding-bottom: 10px;
	position: relative;
	width: 100%;
	/* Grid View (Default: Channels/Stations) */
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
	gap: 10px;
}

/* List View (Series) */
.channels.list-view {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding-top: 10px;
}

/* --- ADDED FOR MOVIE GRID --- */
/* Special Grid View (Movies) */
.channels.movie-grid-view {
	/* Override default grid to be 2 columns */
	grid-template-columns: repeat(2, 1fr);
	gap: 12px; /* Slightly larger gap */
}

.channels.movie-grid-view .channel-btn {
	/* Override square aspect ratio for portrait posters */
	padding-top: 150%; /* 1:1.5 aspect ratio */
}
/* --- END MOVIE GRID --- */

/* Custom Scrollbar for .channels */
.channels::-webkit-scrollbar {
	width: 6px;
}
.channels::-webkit-scrollbar-track {
	background: transparent;
}
.channels::-webkit-scrollbar-thumb {
	background-color: #444;
	border-radius: 10px;
}
.channels::-webkit-scrollbar-thumb:hover {
	background-color: #555;
}

/* --- GRID CHANNEL BUTTON STYLES (Channels/Stations) --- */
.channel-btn {
	background: rgba(255, 255, 255, 0.05);
	border-radius: 10px;
	cursor: pointer;
	transition:
		box-shadow 0.18s,
		border-color 0.18s;
	padding: 6px;
	position: relative;
	height: 0;
	padding-top: 100%; /* Creates a square aspect ratio */
	border: 2px solid transparent;
	box-shadow: none;
}
.channel-btn:hover {
	box-shadow: 0 0 8px 0 var(--highlight-color);
	border-color: var(--highlight-color);
}
.channel-btn img {
	position: absolute;
	top: 6px;
	left: 6px;
	width: calc(100% - 12px);
	height: calc(100% - 12px);
	object-fit: contain;
	border-radius: 8px;
}

/* Active List Item Effect (Internal Pulsating Glow - Shared by List and Grid) */
@keyframes list-glow-inset {
	0% {
		/* Inner shadow - subtle glow */
		box-shadow: inset 0 0 10px 0 rgba(255, 170, 0, 0.6);
	}
	50% {
		/* Stronger inner shadow at midpoint */
		box-shadow: inset 0 0 20px 0 rgba(255, 170, 0, 0.9);
	}
	100% {
		/* Return to subtle glow */
		box-shadow: inset 0 0 10px 0 rgba(255, 170, 0, 0.6);
	}
}

/* MODIFIED: Active Grid Channel Effect now uses the internal glow */
.channel-btn.active-channel {
	background: rgba(255, 170, 0, 0.15);
	border: 2px solid var(--active-color);
	animation: list-glow-inset 3s ease-in-out infinite alternate;
	box-shadow: none; /* Reset external shadow */
}
/* MODIFIED: Ensure hover works correctly with the active state */
.channel-btn.active-channel:hover {
	animation: list-glow-inset 3s ease-in-out infinite alternate;
	box-shadow: 0 0 8px 0 var(--highlight-color); /* Retain hover feedback */
	border-color: var(--highlight-color);
}
/* --- END GRID CHANNEL BUTTON STYLES --- */

/* ---------------------------------------------------- */
/* LIST VIEW STYLES (Movies/Series) - **FIXED** */
/* ---------------------------------------------------- */
.list-item {
	display: flex;
	align-items: center;
	padding: 10px;
	background-color: #2a2a2a;
	border-radius: 6px;
	/* KEY: Only transition background and transform to avoid box-shadow delay */
	transition:
		background-color 0.2s ease,
		transform 0.1s ease;
	position: relative;
	overflow: hidden;
	white-space: nowrap;
	border-left: 5px solid transparent;
	padding-left: 14px;

	/* Set a base box-shadow for the animation engine to hook onto */
	box-shadow: none;
	border: 1px solid transparent; /* Added for hover effect consistency */
}

.list-item:hover {
	background-color: #383838;
	/* FIX: Removed transform: translateX(4px); to keep it still */
	transform: none;

	/* --- ADDED FOR BORDER GLOW ON HOVER --- */
	border-color: var(--highlight-color);
	box-shadow: 0 0 8px 0 rgba(255, 213, 128, 0.4);
	border-radius: 8px;
	border: 1px solid var(--highlight-color);
	padding-left: 13px; /* Adjust padding to account for the new 1px border */
}

.list-item.active-channel {
	background-color: rgba(255, 170, 0, 0.15);
	border-left: 5px solid var(--active-color);
	padding-left: 9px;

	/* Force the glow shadow to appear instantly */
	box-shadow: inset 0 0 10px 0 rgba(255, 170, 0, 0.6);

	/* IMPORTANT FIX: Override the default transition to allow box-shadow to be instant */
	transition:
		background-color 0.2s ease,
		transform 0.1s ease,
		box-shadow 0s;

	/* Uses the internal glow animation */
	animation: list-glow-inset 3s ease-in-out infinite alternate;
	/* Reset transform from potential hover state */
	transform: none;
}

.list-item.active-channel:hover {
	/* Retain the glow animation on hover */
	animation: list-glow-inset 3s ease-in-out infinite alternate;
	/* Slight color change on hover feedback */
	background-color: rgba(255, 170, 0, 0.25);
	transform: none;
	/* Ensure the transition property is carried over */
	transition:
		background-color 0.2s ease,
		transform 0.1s ease,
		box-shadow 0s;

	/* Retain hover border glow on top of active state */
	border: 1px solid var(--highlight-color);
	box-shadow:
		inset 0 0 10px 0 rgba(255, 170, 0, 0.6),
		0 0 8px 0 rgba(255, 213, 128, 0.4);
}

.list-item-title {
	flex-grow: 1;
	font-size: 1rem;
	font-weight: 500;
	color: white;
	overflow: hidden;
	text-overflow: ellipsis;
}
/* ---------------------------------------------------- */

/* Hover Image Preview */
#hoverImagePreview {
	position: absolute;
	top: 0;
	/* 180px (preview width) + 10px (gap) */
	left: -190px;
	width: 180px;
	height: 180px;
	z-index: 10;
	pointer-events: none;
	border-radius: 8px;
	box-shadow:
		0 5px 15px rgba(0, 0, 0, 0.6),
		0 0 10px rgba(255, 255, 255, 0.15);
	opacity: 0;
	transition: opacity 0.2s ease-in-out;
	background-color: #1a1a1a;
	display: flex;
	align-items: center;
	justify-content: center;
}
#hoverImagePreview.visible {
	opacity: 1;
}
#hoverImagePreview img {
	width: 90%;
	height: 90%;
	object-fit: contain;
	border-radius: 4px;
}
/* ---------------------------------------------------- */

/* Donate Popup Modal */
.donate-popup {
	display: none;
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.95);
	justify-content: center;
	align-items: center;
	/* --- MODIFICATION: Updated z-index --- */
	z-index: 999;
}
.donate-card {
	width: 90%;
	max-width: 320px;
	background: linear-gradient(180deg, #1e1e1e, #151515);
	border-radius: 12px;
	padding: 18px;
	text-align: center;
	position: relative;
	/* --- MODIFICATION: Updated z-index --- */
	z-index: 1000;
}
.donate-card img {
	width: 100%;
	border-radius: 8px;
	margin-bottom: 12px;
}
.donate-close {
	position: absolute;
	top: 10px;
	right: 12px;
	background: transparent;
	border: none;
	color: pink;
	font-size: 1.2rem;
	cursor: pointer;
	/* --- MODIFICATION: Updated z-index --- */
	z-index: 1001;
}

/* ========================================================================= */
/* Mobile Styles: Applied for all screens 600px wide or less */
/* ========================================================================= */

/* --- FIX #1: Added (orientation: portrait) --- */
@media (max-width: 600px) and (orientation: portrait) {
	:root {
		--sidebar-w: 100%;
		--top-bar-h: 40px; /* Smaller top bar height */
	}

	html,
	body {
		overflow: hidden;
		height: 100%;
	}

	.main-area {
		/* Switch from desktop grid to mobile flex-column layout */
		display: flex;
		flex-direction: column;
		height: 100%;
		/* --- MODIFICATION: Removed padding --- */
		padding: 0;
		gap: 5px; /* Adjust main gap for mobile layout */
	}

	/* Top bar: Fixed at the very top */
	.top-bar {
		/* Overrides desktop grid placement */
		grid-column: unset;
		grid-row: unset;

		/* --- MODIFICATION: Full-width fixed layout --- */
		padding: 8px 10px;
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		transform: none;
		border-radius: 0;
		/* --- END MODIFICATION --- */

		/* --- MODIFICATION: Updated z-index --- */
		z-index: 100;
		justify-content: space-between;
	}

	/* MODIFIED: Smaller top bar elements */
	.logo-container img {
		height: 34px;
	}
	.top-bar-controls {
		/* Spacing adjustments for smaller buttons */
		flex-grow: 1;
		justify-content: flex-end;
		gap: 6px;
		align-items: center;
	}
	.top-bar-btn {
		/* Sizing adjustments for smaller buttons */
		padding: 4px 8px;
		font-size: 0.7rem;
		font-weight: 700;
	}

	/* Video Container: Fixed below the top bar */
	.video-container {
		/* Overrides desktop grid placement */
		grid-column: unset;
		grid-row: unset;

		/* --- MODIFICATION: Full-width fixed layout --- */
		width: 100%;
		height: 0;
		padding-top: 56.25%; /* 16:9 Aspect ratio */
		position: fixed;
		top: var(--top-bar-h); /* Positioned below top bar */
		left: 0;
		transform: none;
		border-radius: 0;
		/* --- END MODIFICATION --- */

		/* --- MODIFICATION: Updated z-index --- */
		z-index: 90;
		margin-bottom: 0;
	}
	.video-container #player {
		/* --- MODIFICATION: Remove radius --- */
		border-radius: 0;
		position: absolute;
		bottom: 0;
		width: 100%;
		height: 100%;
	}
	.video-container #playerPlaceholder {
		/* --- MODIFICATION: Remove radius --- */
		border-radius: 0;
		position: absolute;
		bottom: 0;
		width: 100%;
	}

	/* Sidebar: Takes up the remaining vertical space */
	.sidebar {
		/* Overrides desktop grid placement */
		grid-column: unset;
		grid-row: unset;

		/* --- MODIFICATION: Removed position:relative --- */
		width: 100%;
		height: 100%;
		max-height: none;
		display: flex;
		flex-direction: column;
		/* --- MODIFICATION: Adjusted padding-top --- */
		padding-top: calc(
			var(--top-bar-h) + 56.25vw + var(--gap)
		);
		border-radius: 0;
		/* --- END MODIFICATION --- */
		overflow: hidden;
	}

	/* --- MODIFIED: Mobile Header Layout (Sidebar) --- */
	.sidebar-header {
		flex-wrap: nowrap;
		gap: 6px;
		align-items: stretch;
		/* --- MODIFICATION: Add padding back to header --- */
		padding-left: 10px;
		padding-right: 10px;
	}
	.sidebar-header .category-toggle {
		order: -1;
		width: auto;
		padding: 0.6rem 0.8rem;
	}
	.sidebar-header .search-box {
		flex-grow: 1;
		flex-shrink: 1;
		min-width: 0;
	}
	.icon-btn {
		flex-shrink: 0;
		height: auto;
	}
	.cat-prefix {
		display: none;
	}

	/* MODIFIED: Make channel list scrollable */
	.channels {
		flex-grow: 1;
		overflow-y: auto;
		/* --- MODIFICATION: Add padding back to list --- */
		padding-left: 10px;
		padding-right: 10px;
	}

	/* Hide hover preview on mobile */
	#hoverImagePreview {
		display: none !important;
	}
}