/* CouchSurfer Plex Integration — poster grid + modal + library pages
   Color vars mirror the theme so the plugin renders under any active theme. */

/* ── Library pages ───────────────────────────────────────────────────── */

.cs-library { margin: 0; }

.cs-library__toolbar {
	display: flex;
	align-items: center;
	gap: 1rem;
	flex-wrap: wrap;
	margin-bottom: 1rem;
}

.cs-library__title {
	font-size: 1.35rem;
	font-weight: 800;
	letter-spacing: 0.06em;
	text-transform: uppercase;
	color: #FFCC00;
	margin: 0;
	flex-shrink: 0;
}

.cs-library__count {
	font-size: 0.8rem;
	color: #777;
	font-weight: 600;
}

.cs-library__search {
	margin-left: auto;
	background: #111;
	border: 1px solid rgba(255,255,255,0.12);
	border-radius: 8px;
	color: #f2f2f2;
	font-size: 0.9rem;
	padding: 0.5rem 0.85rem;
	width: 220px;
	outline: none;
	transition: border-color 0.2s;
}
.cs-library__search:focus { border-color: #FF6600; }
.cs-library__search::placeholder { color: #555; }

/* A-Z filter */
.cs-library__alpha {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
	margin-bottom: 1.5rem;
}

.cs-alpha-btn {
	background: rgba(255,255,255,0.05);
	border: 1px solid rgba(255,255,255,0.1);
	border-radius: 5px;
	color: #aaa;
	font-size: 0.78rem;
	font-weight: 700;
	padding: 0.3rem 0.55rem;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
	min-width: 32px;
	text-align: center;
}
.cs-alpha-btn:hover { background: rgba(255,102,0,0.12); color: #FF6600; border-color: rgba(255,102,0,0.3); }
.cs-alpha-btn--active { background: #FF6600; border-color: #FF6600; color: #0a0a0a; }

/* Multi-row movie grid */
.cs-plex-library-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
	gap: 1.25rem;
}

.cs-library__empty { color: #666; font-size: 0.95rem; margin-top: 2rem; }

/* ── TV show grid ─────────────────────────────────────────────────────── */

.cs-tv-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
	gap: 1.25rem;
	margin-bottom: 0;
}

.cs-tv-card {
	display: flex;
	flex-direction: column;
	background: #141414;
	border: 1px solid rgba(255,255,255,0.07);
	border-radius: 10px;
	overflow: hidden;
	cursor: pointer;
	transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
	outline: none;
	user-select: none;
}

.cs-tv-card:hover,
.cs-tv-card:focus-visible {
	transform: translateY(-5px);
	border-color: #0099CC;
	box-shadow: 0 10px 28px rgba(0,153,204,0.25);
}

.cs-tv-card--active {
	border-color: #FF6600 !important;
	box-shadow: 0 0 0 2px rgba(255,102,0,0.35) !important;
}

.cs-tv-card__poster {
	position: relative;
	aspect-ratio: 2 / 3;
	background: #0a0a0a;
	overflow: hidden;
}
.cs-tv-card__poster img {
	display: block; width: 100%; height: 100%; object-fit: cover;
	transition: transform 0.3s;
}
.cs-tv-card:hover .cs-tv-card__poster img { transform: scale(1.04); }

.cs-tv-card__overlay {
	position: absolute; inset: 0;
	display: flex; align-items: center; justify-content: center;
	opacity: 0; transition: opacity 0.2s;
}
.cs-tv-card:hover .cs-tv-card__overlay,
.cs-tv-card:focus-visible .cs-tv-card__overlay { opacity: 1; }

.cs-tv-card__seasons {
	display: block;
	font-size: 0.72rem;
	color: #0099CC;
	font-weight: 600;
	margin: 0 0.7rem 0.7rem;
	letter-spacing: 0.03em;
}

/* ── TV detail panel ──────────────────────────────────────────────────── */

.cs-tv-detail {
	margin-top: 1.5rem;
	background: #161616;
	border: 1px solid rgba(255,102,0,0.3);
	border-radius: 12px;
	overflow: hidden;
}

.cs-tv-detail__header {
	display: flex;
	gap: 1.25rem;
	align-items: flex-start;
	padding: 1.25rem;
	background: rgba(255,102,0,0.05);
	border-bottom: 1px solid rgba(255,255,255,0.07);
	position: relative;
}

.cs-tv-detail__art {
	width: 80px;
	height: 120px;
	object-fit: cover;
	border-radius: 6px;
	flex-shrink: 0;
	background: #0a0a0a;
}

.cs-tv-detail__meta { flex: 1; min-width: 0; }

.cs-tv-detail__show-title {
	font-size: 1.25rem;
	font-weight: 800;
	color: #f2f2f2;
	margin: 0 0 0.5rem;
}

.cs-tv-detail__summary {
	color: #999;
	font-size: 0.875rem;
	line-height: 1.55;
	margin: 0;
	display: -webkit-box;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.cs-tv-detail__close {
	position: absolute; top: 0.75rem; right: 1rem;
	background: none; border: none;
	color: #666; font-size: 1.75rem; line-height: 1;
	cursor: pointer; padding: 0; transition: color 0.15s;
}
.cs-tv-detail__close:hover { color: #FF6600; }

/* Season tabs */
.cs-tv-detail__season-tabs {
	display: flex;
	gap: 0.5rem;
	flex-wrap: wrap;
	padding: 1rem 1.25rem 0.75rem;
	border-bottom: 1px solid rgba(255,255,255,0.06);
}

.cs-tv-season-btn {
	background: rgba(255,255,255,0.06);
	border: 1px solid rgba(255,255,255,0.1);
	border-radius: 6px;
	color: #ccc;
	font-size: 0.82rem;
	font-weight: 700;
	padding: 0.4rem 1rem;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cs-tv-season-btn:hover { background: rgba(255,102,0,0.12); color: #FF6600; }
.cs-tv-season-btn--active {
	background: #FF6600;
	border-color: #FF6600;
	color: #0a0a0a;
}

/* Episode scroll row */
.cs-tv-detail__episodes {
	padding: 1rem 1.25rem 1.25rem;
}

.cs-tv-episodes-row {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	gap: 1rem;
	overflow-x: auto;
	padding-bottom: 0.5rem;
	scrollbar-width: thin;
	scrollbar-color: rgba(255,102,0,0.4) transparent;
}
.cs-tv-episodes-row::-webkit-scrollbar { height: 4px; }
.cs-tv-episodes-row::-webkit-scrollbar-thumb { background: rgba(255,102,0,0.4); border-radius: 99px; }

/* Episode card (wide 16:9 thumb) */
.cs-episode-card {
	flex: 0 0 200px;
	width: 200px;
}

.cs-episode-card__thumb {
	aspect-ratio: 16 / 9 !important;
}

.cs-episode-num {
	display: block;
	font-size: 0.72rem;
	color: #FF6600;
	font-weight: 700;
	margin-bottom: 0.1rem;
}

.cs-tv-no-episodes { color: #555; font-size: 0.9rem; }

.cs-tv-detail__spinner {
	display: flex;
	justify-content: center;
	padding: 2rem;
}

/* ── Section ─────────────────────────────────────────────────────────── */

.cs-plex-section {
	margin: 0 0 3.5rem;
}

.cs-plex-section__title {
	font-size: 1.35rem;
	font-weight: 800;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	margin: 0 0 1.25rem;
	padding-bottom: 0.6rem;
	color: #FFCC00;
	border-bottom: 2px solid rgba(255, 102, 0, 0.45);
}

/* ── Grid ─────────────────────────────────────────────────────────────── */

.cs-plex-grid {
	display: flex;
	flex-direction: row;
	flex-wrap: nowrap;
	gap: 1.25rem;
	overflow-x: auto;
	padding-bottom: 0.75rem;
	/* Hide scrollbar on IE/Edge, show on hover for others */
	-ms-overflow-style: none;
	scrollbar-width: thin;
	scrollbar-color: rgba(255,102,0,0.4) transparent;
}

.cs-plex-grid::-webkit-scrollbar {
	height: 5px;
}

.cs-plex-grid::-webkit-scrollbar-track {
	background: transparent;
}

.cs-plex-grid::-webkit-scrollbar-thumb {
	background: rgba(255, 102, 0, 0.4);
	border-radius: 99px;
}

/* ── Card ─────────────────────────────────────────────────────────────── */

.cs-plex-card {
	display: flex;
	flex-direction: column;
	flex: 0 0 148px;
	width: 148px;
	background: #141414;
	border: 1px solid rgba(255, 255, 255, 0.07);
	border-radius: 10px;
	overflow: hidden;
	cursor: pointer;
	transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
	outline: none;
	-webkit-user-select: none;
	user-select: none;
}

.cs-plex-card:hover,
.cs-plex-card:focus-visible {
	transform: translateY(-5px);
	border-color: #0099CC;
	box-shadow: 0 10px 28px rgba(0, 153, 204, 0.28);
}

/* Poster wrapper */
.cs-plex-card__poster {
	position: relative;
	aspect-ratio: 2 / 3;
	background: #0a0a0a;
	overflow: hidden;
}

.cs-plex-card__poster img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.cs-plex-card:hover .cs-plex-card__poster img {
	transform: scale(1.04);
}

.cs-plex-card__placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #1c1c1c 0%, #0a0a0a 100%);
}

/* Play overlay */
.cs-plex-card__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.cs-plex-card:hover .cs-plex-card__overlay,
.cs-plex-card:focus-visible .cs-plex-card__overlay {
	opacity: 1;
}

/* Title */
.cs-plex-card__title {
	font-size: 0.88rem;
	line-height: 1.3;
	margin: 0.7rem 0.7rem 0.8rem;
	color: #f2f2f2;
	font-weight: 600;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.cs-plex-card__year {
	display: block;
	font-size: 0.72rem;
	font-weight: 400;
	color: #999;
	margin-top: 0.15rem;
}

.cs-plex-card__ep-label {
	display: block;
	font-size: 0.72rem;
	font-weight: 700;
	color: #FF6600;
	margin-top: 0.2rem;
	letter-spacing: 0.04em;
}

/* ── Modal ───────────────────────────────────────────────────────────── */

.cs-modal {
	position: fixed;
	inset: 0;
	z-index: 9000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
}

.cs-modal[hidden] { display: none; }

.cs-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.85);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	cursor: pointer;
}

.cs-modal__box {
	position: relative;
	z-index: 1;
	background: #1a1a1a;
	border: 1px solid rgba(255, 255, 255, 0.1);
	border-radius: 14px;
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
	max-width: 800px;
	width: 100%;
	max-height: 90vh;
	overflow-y: auto;
	animation: cs-modal-in 0.22s ease;
}

@keyframes cs-modal-in {
	from { opacity: 0; transform: translateY(18px) scale(0.97); }
	to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

.cs-modal__close {
	position: absolute;
	top: 0.85rem;
	right: 1rem;
	background: none;
	border: none;
	color: #ccc;
	font-size: 2rem;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	z-index: 2;
	transition: color 0.15s;
}
.cs-modal__close:hover { color: #FF6600; }

/* Hide the absolute close button when video panel is active
   (the video header row has its own close / back button) */
.cs-modal__video-panel:not([hidden]) ~ .cs-modal__close,
.cs-modal__box:has(.cs-modal__video-panel:not([style*="none"])) .cs-modal__close {
	display: none;
}

.cs-modal__inner {
	display: flex;
	gap: 1.75rem;
	padding: 1.75rem;
}

/* Poster column */
.cs-modal__poster-wrap {
	flex-shrink: 0;
	width: 200px;
	border-radius: 8px;
	overflow: hidden;
	background: #0a0a0a;
	aspect-ratio: 2 / 3;
	position: relative;
}

.cs-modal__poster {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cs-modal__poster-placeholder {
	position: absolute;
	inset: 0;
	background: linear-gradient(135deg, #1c1c1c, #0a0a0a);
	display: none;
}

/* Info column */
.cs-modal__info {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
}

.cs-modal__title {
	font-size: 1.55rem;
	font-weight: 800;
	color: #f2f2f2;
	margin: 0 2rem 0.75rem 0;
	line-height: 1.2;
}

.cs-modal__meta {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	flex-wrap: wrap;
	margin-bottom: 1rem;
}

.cs-modal__badge {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	padding: 0.2rem 0.65rem;
	border-radius: 4px;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.cs-modal__badge--year   { background: rgba(255, 102, 0, 0.15); color: #FF6600; border: 1px solid rgba(255,102,0,0.3); }
.cs-modal__badge--cr     { background: rgba(255, 255, 255, 0.07); color: #ccc; border: 1px solid rgba(255,255,255,0.12); }
.cs-modal__badge--rating { background: rgba(255, 204, 0, 0.12); color: #FFCC00; border: 1px solid rgba(255,204,0,0.25); }

.cs-modal__badge:empty { display: none; }

.cs-modal__summary {
	color: #bbb;
	font-size: 0.95rem;
	line-height: 1.65;
	flex: 1;
	margin: 0 0 1.25rem;
}


/* ── Modal actions ───────────────────────────────────────────────────── */

.cs-modal__actions {
	display: flex;
	gap: 0.75rem;
	flex-wrap: wrap;
	align-items: center;
}

.cs-modal__watch-btn--primary {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.7rem 1.4rem;
	font-size: 0.9rem;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	cursor: pointer;
	border: none;
	color: #0a0a0a;
	background: linear-gradient(90deg, #FF6600, #FFCC00);
	border-radius: 6px;
	transition: filter 0.2s, transform 0.15s;
	text-decoration: none;
}

.cs-modal__watch-btn--primary:hover {
	filter: brightness(1.1);
	transform: scale(1.03);
	color: #0a0a0a;
}

.cs-modal__watch-btn--secondary {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.65rem 1.1rem;
	font-size: 0.82rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	text-decoration: none;
	color: #ccc;
	background: rgba(255, 255, 255, 0.07);
	border: 1px solid rgba(255, 255, 255, 0.15);
	border-radius: 6px;
	transition: background 0.2s, color 0.2s;
}

.cs-modal__watch-btn--secondary:hover {
	background: rgba(255, 255, 255, 0.13);
	color: #fff;
}

.cs-modal__cast {
	display: flex;
	align-items: baseline;
	gap: 0.5rem;
	margin: 0 0 1rem;
	flex-wrap: wrap;
}

.cs-modal__cast-label {
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #FF6600;
	flex-shrink: 0;
}

.cs-modal__cast-list {
	font-size: 0.85rem;
	color: #bbb;
	line-height: 1.5;
}

.cs-modal__login-note {
	font-size: 0.82rem;
	color: #888;
	margin: 0.75rem 0 0;
}

.cs-modal__login-note a { color: #0099CC; }

/* ── Video panel ─────────────────────────────────────────────────────── */

.cs-modal__video-panel {
	display: none; /* JS sets display:flex when active */
	flex-direction: column;
}

.cs-modal__video-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
	padding: 0.75rem 1rem 0.75rem 1.25rem;
	border-bottom: 1px solid rgba(255, 255, 255, 0.08);
	/* no right overflow — close button sits inside this row now */
}

.cs-modal__back-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	background: none;
	border: 1px solid rgba(255,255,255,0.2);
	color: #ccc;
	font-size: 0.85rem;
	font-weight: 600;
	padding: 0.4rem 0.9rem;
	border-radius: 5px;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	flex-shrink: 0;
}

.cs-modal__back-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.cs-modal__video-title {
	font-size: 1rem;
	font-weight: 700;
	color: #f2f2f2;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	/* flex:1 removed — cc-wrap uses margin-left:auto instead */
}

/* CC button */
.cs-cc-wrap {
	position: relative;
	flex-shrink: 0;
	margin-left: auto; /* push CC + close all the way right */
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.cs-cc-btn {
	display: inline-flex;
	align-items: center;
	gap: 0.3rem;
	background: rgba(255,255,255,0.08);
	border: 1px solid rgba(255,255,255,0.18);
	border-radius: 6px;
	color: #ccc;
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.04em;
	padding: 0.35rem 0.65rem;
	cursor: pointer;
	transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.cs-cc-btn:hover,
.cs-cc-btn--active {
	background: rgba(255, 204, 0, 0.15);
	border-color: #FFCC00;
	color: #FFCC00;
}

/* CC dropdown menu — opens downward, anchored left so it can't overflow right edge */
.cs-cc-menu {
	position: absolute;
	top: calc(100% + 0.4rem);
	right: 0;         /* right-align to button */
	min-width: 170px;
	background: #1e1e1e;
	border: 1px solid rgba(255,255,255,0.12);
	border-radius: 8px;
	padding: 0.3rem;
	box-shadow: 0 8px 24px rgba(0,0,0,0.6);
	z-index: 100;
	/* Clamp so it never overflows the modal box */
	max-width: calc(100vw - 2rem);
}

.cs-cc-option {
	display: block;
	width: 100%;
	text-align: left;
	background: none;
	border: none;
	color: #ccc;
	font-size: 0.85rem;
	padding: 0.5rem 0.75rem;
	border-radius: 5px;
	cursor: pointer;
	transition: background 0.12s, color 0.12s;
}

.cs-cc-option:hover { background: rgba(255,255,255,0.07); color: #fff; }
.cs-cc-option--active { color: #FFCC00; font-weight: 700; }

.cs-modal__video-wrap {
	position: relative;
	background: #000;
	aspect-ratio: 16 / 9;
	display: flex;
	align-items: center;
	justify-content: center;
}

.cs-modal__video {
	width: 100%;
	height: 100%;
	display: block;
	background: #000;
}

/* Spinner */
.cs-modal__video-spinner {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.6);
	z-index: 2;
}

.cs-spinner {
	width: 48px;
	height: 48px;
	border: 4px solid rgba(255,255,255,0.15);
	border-top-color: #FF6600;
	border-radius: 50%;
	animation: cs-spin 0.8s linear infinite;
}

@keyframes cs-spin {
	to { transform: rotate(360deg); }
}

.cs-modal__video-error {
	position: absolute;
	inset: 0;
	display: none; /* JS sets display:flex on error */
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	color: #aaa;
	font-size: 0.9rem;
	background: rgba(0,0,0,0.7);
}

.cs-modal__video-error a { color: #FF6600; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
	.cs-plex-grid {
		gap: 0.85rem;
	}

	.cs-plex-card {
		flex: 0 0 120px;
		width: 120px;
	}

	.cs-plex-section__title { font-size: 1.1rem; }

	.cs-modal__inner {
		flex-direction: column;
		padding: 1.25rem;
	}

	.cs-modal__poster-wrap {
		width: 100%;
		max-width: 220px;
		margin: 0 auto;
	}

	.cs-modal__title { font-size: 1.25rem; margin-right: 1.5rem; }
}
