/**
 * PlayFlix Companion — front-end styles.
 * Pairs with the PlayFlix theme's .pf-player-wrap / .pf-server-tabs classes.
 */

/* Player iframe fills the theme's 16:9 player box. */
.pf-player iframe[data-pf-frame] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	background: #050508;
}

/* Click-to-play cover: our own play button over the (not yet loaded) player. */
.pf-play-overlay {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	padding: 0;
	margin: 0;
	cursor: pointer;
	background-color: #050508;
	background-size: cover;
	background-position: center;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2;
}

.pf-play-overlay::before {
	content: '';
	position: absolute;
	inset: 0;
	background: rgba(3, 3, 8, 0.45);
}

.pf-play-button {
	position: relative;
	z-index: 1;
	width: 84px;
	height: 84px;
	border-radius: 50%;
	background: var(--pf-accent, #d10e35);
	box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease;
}

.pf-play-overlay:hover .pf-play-button {
	transform: scale(1.08);
}

.pf-play-button::before {
	content: '';
	width: 0;
	height: 0;
	border-top: 14px solid transparent;
	border-bottom: 14px solid transparent;
	border-left: 22px solid #fff;
	margin-left: 6px;
}

.pf-play-hidden {
	display: none !important;
}

/* Episodes sidebar: Season + Episode dropdowns and episode grid. */
.pf-ep-side {
	background: var(--pf-surface, #16161f);
	border: 1px solid var(--pf-border, #26262f);
	border-radius: 0.9rem;
	padding: 1.1rem 1.1rem 1.25rem;
}

.pf-ep-side-title {
	margin: 0 0 0.9rem;
	font-size: 1rem;
	font-weight: 800;
	color: var(--pf-text, #f4f4f7);
}

.pf-ep-ddrow {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0.6rem;
	margin-bottom: 1rem;
}

.pf-ep-dd {
	position: relative;
}

.pf-ep-dd-btn {
	width: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.5rem;
	padding: 0.65rem 0.85rem;
	border-radius: 0.6rem;
	border: 1px solid var(--pf-border, #26262f);
	background: rgba(255, 255, 255, 0.05);
	color: var(--pf-text, #f4f4f7);
	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;
	transition: border-color 0.2s ease;
	white-space: nowrap;
	overflow: hidden;
}

.pf-ep-dd-btn:hover,
.pf-ep-dd.is-open .pf-ep-dd-btn {
	border-color: var(--pf-accent, #d10e35);
}

.pf-ep-dd-btn > span:first-child {
	overflow: hidden;
	text-overflow: ellipsis;
}

.pf-ep-chevron {
	flex: none;
	width: 0;
	height: 0;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 7px solid var(--pf-text-dim, #b9b9c4);
	transition: transform 0.2s ease;
}

.pf-ep-dd.is-open .pf-ep-chevron {
	transform: rotate(180deg);
}

.pf-ep-dd-menu {
	display: none;
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	z-index: 40;
	max-height: min(70vh, 560px);
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	touch-action: pan-y;
	padding: 0.35rem;
	border-radius: 0.6rem;
	border: 1px solid var(--pf-border, #26262f);
	background: #1d1d28;
	box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
	/* Hide the native scrollbar (it renders white on some browsers) — the menu still scrolls. */
	scrollbar-width: none;
}

.pf-ep-dd-menu::-webkit-scrollbar {
	display: none;
}

.pf-ep-dd.is-open .pf-ep-dd-menu:not([hidden]) {
	display: block;
}

.pf-ep-dd-item {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	width: 100%;
	padding: 0.55rem 0.7rem;
	border: 0;
	border-radius: 0.45rem;
	background: none;
	color: var(--pf-text-dim, #b9b9c4);
	font-size: 0.85rem;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	text-align: left;
}

button.pf-ep-dd-item {
	font-family: inherit;
}

.pf-ep-dd-item:hover {
	background: rgba(255, 255, 255, 0.07);
	color: #fff;
}

.pf-ep-dd-item.is-active {
	background: rgba(243, 18, 63, 0.14);
	color: #fff;
}

.pf-ep-dd-num {
	flex: none;
	min-width: 1.6rem;
	height: 1.6rem;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 0.4rem;
	background: rgba(255, 255, 255, 0.08);
	font-size: 0.75rem;
	font-weight: 800;
}

.pf-ep-dd-name {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.pf-ep-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
	gap: 0.5rem;
}

/* The explicit display above beats the UA [hidden] rule — restore it. */
.pf-ep-grid[hidden] {
	display: none;
}

.pf-ep-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	border-radius: 0.6rem;
	border: 1px solid var(--pf-border, #26262f);
	background: rgba(255, 255, 255, 0.05);
	color: var(--pf-text, #f4f4f7);
	font-weight: 800;
	font-size: 0.9rem;
	text-decoration: none;
	transition: all 0.2s ease;
}

.pf-ep-btn:hover {
	border-color: var(--pf-accent, #d10e35);
	color: #fff;
	transform: translateY(-2px);
}

.pf-ep-btn.is-current {
	background: var(--pf-accent, #d10e35);
	border-color: var(--pf-accent, #d10e35);
	color: #fff;
	box-shadow: 0 4px 16px rgba(243, 18, 63, 0.4);
}

/* Server tabs sit BELOW the player, YouTube-style; centered so multiple
 * servers never crowd to one side. */
.pf-player-wrap .pf-server-tabs {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	margin: 1rem 0 0;
}

.pf-player-wrap .pf-server-tab {
	padding: 0.55rem 1.25rem;
	border-radius: 999px;
	border: 1px solid var(--pf-border, #26262f);
	background: rgba(255, 255, 255, 0.06);
	color: var(--pf-text-dim, #b9b9c4);
	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;
	transition: all 0.2s ease;
}

.pf-player-wrap .pf-server-tab:hover {
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	border-color: rgba(255, 255, 255, 0.2);
}

.pf-player-wrap .pf-server-tab.is-active {
	background: var(--pf-accent, #d10e35);
	border-color: var(--pf-accent, #d10e35);
	color: #fff;
	box-shadow: 0 4px 18px rgba(243, 18, 63, 0.35);
}

.pf-player-foot {
	margin-top: 0.75rem;
	display: flex;
	justify-content: flex-end;
}

.pf-report-link {
	background: none;
	border: 0;
	padding: 0.25rem 0;
	font-size: 0.8rem;
	color: var(--pf-text-faint, #8a8a96);
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.pf-report-link:hover {
	color: var(--pf-text, #f4f4f7);
}

.pf-report-link:disabled {
	opacity: 0.6;
	cursor: default;
	text-decoration: none;
}

/* Manual links list. */
.pf-manual-links {
	list-style: none;
	margin: 1.25rem 0 0;
	padding: 0;
	display: grid;
	gap: 0.5rem;
}

.pf-manual-links a {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.7rem 1rem;
	border: 1px solid var(--pf-border, #26262f);
	border-radius: 0.6rem;
	background: var(--pf-surface, #16161f);
	color: var(--pf-text, #f4f4f7);
	text-decoration: none;
	font-size: 0.9rem;
}

.pf-manual-links a:hover {
	border-color: var(--pf-accent, #d10e35);
}

.pf-link-type {
	font-weight: 700;
	text-transform: uppercase;
	font-size: 0.72rem;
	letter-spacing: 0.06em;
	color: var(--pf-accent, #d10e35);
}

.pf-link-quality,
.pf-link-language {
	font-size: 0.78rem;
	color: var(--pf-text-dim, #b9b9c4);
	margin-left: auto;
}

.pf-link-language {
	margin-left: 0;
}

/* Favorite / watchlist toggle buttons. */
.pf-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.45rem;
	padding: 0.55rem 1.1rem;
	border-radius: 999px;
	border: 1px solid var(--pf-border, #26262f);
	background: var(--pf-surface, #16161f);
	color: var(--pf-text-dim, #b9b9c4);
	font-size: 0.85rem;
	font-weight: 700;
	cursor: pointer;
	transition: all 0.2s ease;
}

.pf-toggle:hover {
	border-color: var(--pf-accent, #d10e35);
	color: #fff;
}

.pf-toggle.is-active {
	background: var(--pf-accent, #d10e35);
	border-color: var(--pf-accent, #d10e35);
	color: #fff;
}

/* Star rating. */
.pf-rating {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	flex-wrap: wrap;
}

.pf-stars {
	display: inline-flex;
	gap: 0.15rem;
}

.pf-star {
	background: none;
	border: 0;
	padding: 0.15rem;
	font-size: 1.6rem;
	line-height: 1;
	color: #4a4a55;
	cursor: pointer;
	transition: color 0.15s ease, transform 0.15s ease;
}

.pf-star:hover {
	transform: scale(1.15);
}

.pf-star.is-on {
	color: var(--pf-gold, #ffb020);
}

.pf-rating-meta {
	font-size: 0.82rem;
	color: var(--pf-text-dim, #b9b9c4);
}

/* Title request form + account. */
.pf-request-form {
	max-width: 34rem;
}

.pf-request-form input[type="text"],
.pf-request-form select,
.pf-request-form textarea {
	width: 100%;
	padding: 0.65rem 0.8rem;
	border-radius: 0.5rem;
	border: 1px solid var(--pf-border, #26262f);
	background: var(--pf-surface, #16161f);
	color: var(--pf-text, #f4f4f7);
	font-size: 0.95rem;
}

.pf-form-error,
.pf-form-success {
	padding: 0.8rem 1rem;
	border-radius: 0.5rem;
	font-size: 0.9rem;
}

.pf-form-error {
	background: rgba(243, 18, 63, 0.12);
	border: 1px solid rgba(243, 18, 63, 0.4);
	color: #ff8ba0;
}

.pf-form-success {
	background: rgba(46, 204, 113, 0.12);
	border: 1px solid rgba(46, 204, 113, 0.4);
	color: #7bed9f;
}

.pf-account-list {
	list-style: none;
	margin: 0 0 2rem;
	padding: 0;
	display: grid;
	gap: 0.5rem;
}

.pf-account-list a {
	color: var(--pf-text, #f4f4f7);
	text-decoration: none;
}

.pf-account-list a:hover {
	color: var(--pf-accent, #d10e35);
}

.pf-empty {
	color: var(--pf-text-faint, #8a8a96);
	font-size: 0.9rem;
}

/* TMDB attribution line. */
.pf-tmdb-credit {
	text-align: center;
	font-size: 0.72rem;
	color: var(--pf-text-faint, #8a8a96);
	margin: 0.5rem 0 0;
}

/* Mobile: the episode dropdown expands inline (not an overlay) so that
 * EVERY episode is reachable with a normal page scroll, no matter how
 * many episodes a season has (25, 100+). No nested scroller to fight with. */
@media (max-width: 640px) {
	/* When a dropdown is open, stack the two buttons so the open menu
	 * gets the full sidebar width. */
	.pf-ep-ddrow:has([data-pf-ep-dd].is-open) {
		grid-template-columns: 1fr;
	}
	.pf-ep-dd-menu[data-pf-ep-episode-menu] {
		position: static;
		max-height: none;
		overflow: visible;
		overscroll-behavior: auto;
		touch-action: auto;
		margin-top: 6px;
	}
}
