/* ===== CSS Variables ===== */
:root {
	--bg-light: #f9fafb;
	--bg-header: #ffffff;
	--bg-card: #ffffff;
	--border-light: #e5e7eb;
	--text-main: #1f2937;
	--text-muted: #6b7280;
	--accent: #4caf50;
	--shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.08);
	--radius: 10px;
}

/* ===== Base Styles ===== */
body {
	font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	margin: 0;
	padding: 0;
	background-color: var(--bg-light);
	color: var(--text-main);
	line-height: 1.5;
}

/* ===== Header ===== */
header {
	background-color: var(--bg-header);
	padding: 20px;
	border-bottom: 1px solid var(--border-light);
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.controls {
	max-width: 1200px;
	margin: 0 auto;
	display: flex;
	gap: 24px;
	align-items: flex-start;
	flex-wrap: wrap;
}

/* Back button */
#back-to-shows {
	background: none;
	border: none;
	color: var(--accent);
	font-weight: 600;
	font-size: 14px;
	cursor: pointer;
	margin-bottom: 10px;
}

#back-to-shows:hover {
	text-decoration: underline;
}

/* ===== Form Controls ===== */
.search-container,
.selector-container {
	display: flex;
	align-items: center;
	gap: 12px;
	flex: 1 1 480px;
	min-width: 480px;
}

label {
	font-weight: 600;
	font-size: 13px;
	color: var(--text-muted);
	white-space: nowrap;
}

/* Inputs */
#search-input,
#episode-selector,
#show-selector {
	flex: 1;
	padding: 10px 12px;
	font-size: 15px;
	border: 1px solid var(--border-light);
	border-radius: var(--radius);
	box-sizing: border-box;
	height: 42px;
	background-color: #fff;
	transition: border-color 0.2s, box-shadow 0.2s;
	min-width: 0;
}

#search-input:focus,
#episode-selector:focus,
#show-selector:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

/* Episode count */
#episode-count {
	font-size: 13px;
	color: var(--text-muted);
	white-space: nowrap;
	flex-shrink: 0;
}

/* ===== Placeholder ===== */
#placeholder {
	text-align: center;
	font-size: 16px;
	color: var(--text-muted);
	padding: 40px 0;
}

/* ===== Grid ===== */
#root {
	display: grid;
	gap: 20px;
	grid-template-columns: repeat(4, 1fr);
	padding: 24px;
	max-width: 1600px;
	margin: 0 auto;
}

#root.single-episode {
	display: flex;
	justify-content: center;
	padding: 40px 20px;
}

#root.single-episode section {
	width: 360px;
}

/* ===== Cards ===== */
section {
	background-color: var(--bg-card);
	border-radius: var(--radius);
	box-shadow: var(--shadow-soft);
	padding: 16px;
	display: flex;
	flex-direction: column;
	transition: transform 0.2s, box-shadow 0.2s;
}

section:hover {
	transform: translateY(-3px);
	box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

section img {
	width: 100%;
	height: auto;
	border-radius: 6px;
	margin-bottom: 10px;
}

section h3 {
	margin: 8px 0;
	font-size: 17px;
	line-height: 1.3;
}

section p,
section time {
	font-size: 14px;
	color: var(--text-muted);
	margin: 4px 0;
}

/* Labels */
section p[data-tv-show-genres]::before {
	content: "Genres: ";
	font-weight: 600;
	color: var(--text-main);
}

section p[data-tv-show-status]::before {
	content: "Status: ";
	font-weight: 600;
	color: var(--text-main);
}

section p[data-tv-show-rating]::before {
	content: "Rating: ";
	font-weight: 600;
	color: var(--text-main);
}

section time[data-tv-show-runtime]::before {
	content: "Runtime: ";
	font-weight: 600;
	color: var(--text-main);
}

/* Episode link */
section a[data-episode-link] {
	margin-top: auto;
	padding-top: 12px;
	color: var(--accent);
	font-weight: 600;
	text-decoration: none;
}

section a[data-episode-link]:hover {
	text-decoration: underline;
}

/* ===== Footer ===== */
footer {
	text-align: center;
	padding: 20px;
	background-color: var(--bg-header);
	border-top: 1px solid var(--border-light);
	margin-top: 40px;
	font-size: 13px;
	color: var(--text-muted);
}

/* ===== Media Queries ===== */
@media (max-width: 1200px) {
	#root {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 900px) {
	#root {
		grid-template-columns: repeat(2, 1fr);
	}

	.search-container,
	.selector-container {
		min-width: 100%;
		flex-direction: column;
		align-items: stretch;
	}
}

@media (max-width: 600px) {
	#root {
		grid-template-columns: 1fr;
	}

	header {
		padding: 16px;
	}

	label {
		font-size: 12px;
	}

	#search-input,
	#episode-selector,
	#show-selector {
		font-size: 14px;
	}
}