/*
 * NicheMetrix — Trending Videos Tool
 * Matches the dark glassmorphism design language of the main niche finder.
 */

/* ─── Reset & base ─────────────────────────────────────── */
.nm-tv-wrap *,
.nm-tv-wrap *::before,
.nm-tv-wrap *::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

.nm-tv-wrap {
	--nm-bg:           #0f1117;
	--nm-surface:      #1a1d2e;
	--nm-surface2:     #222538;
	--nm-border:       rgba(255,255,255,0.08);
	--nm-border-hover: rgba(255,255,255,0.16);
	--nm-accent:       #6c63ff;
	--nm-accent2:      #e74c3c;
	--nm-accent-glow:  rgba(108,99,255,0.35);
	--nm-text:         #e8eaf6;
	--nm-text-muted:   #8b8fa8;
	--nm-text-dim:     #5a5e78;
	--nm-radius:       14px;
	--nm-radius-sm:    8px;
	--nm-shadow:       0 4px 24px rgba(0,0,0,0.4);
	--nm-font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
	--nm-transition:   0.2s ease;

	font-family: var(--nm-font);
	color:       var(--nm-text);
	max-width: 1200px;
	margin: 0 auto;
}

.nm-tv-hero {
	background:  var(--nm-bg);
	border-radius: calc(var(--nm-radius) + 4px);
	padding: 40px 32px 48px;
	position: relative;
	overflow: visible;
}

/* Subtle radial glow background */
.nm-tv-hero::before {
	content: '';
	position: absolute;
	inset: 0;
	background:
		radial-gradient(ellipse 60% 40% at 20% 0%, rgba(108,99,255,0.12) 0%, transparent 70%),
		radial-gradient(ellipse 40% 30% at 80% 100%, rgba(231,76,60,0.08) 0%, transparent 70%);
	pointer-events: none;
	z-index: 0;
}

.nm-tv-hero > * {
	position: relative;
	z-index: 1;
}

/* ─── Header ────────────────────────────────────────────── */
.nm-tv-header {
	text-align: center;
	margin-bottom: 36px;
}

.nm-tv-title {
	font-size: clamp(1.6rem, 4vw, 2.4rem);
	font-weight: 800;
	letter-spacing: -0.5px;
	background: linear-gradient(135deg, #fff 0%, #a8b2ff 100%);
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	background-clip: text;
	display: inline-flex;
	align-items: center;
	gap: 10px;
}

.nm-tv-title-icon {
	-webkit-text-fill-color: initial;
	font-size: 1.8rem;
	filter: drop-shadow(0 0 8px rgba(255,120,0,0.6));
}

.nm-tv-subtitle {
	color: var(--nm-text-muted);
	font-size: 1rem;
	margin-top: 10px;
	line-height: 1.6;
}

/* ─── Controls bar (Pill shaped) ────────────────────────── */
.nm-tv-controls {
	display: flex;
	gap: 0;
	align-items: center;
	margin-bottom: 36px;
	background: rgba(255, 255, 255, 0.06);
	border: 1px solid var(--nm-border);
	border-radius: 50px;
	padding: 6px 6px 6px 20px;
	backdrop-filter: blur(20px);
	box-shadow: var(--nm-shadow), 0 0 40px rgba(102, 126, 234, 0.15);
	transition: border-color var(--nm-transition), box-shadow var(--nm-transition);
	max-width: 800px;
	margin-left: auto;
	margin-right: auto;
	position: relative;
	z-index: 100;
}

/* ─── Credits Badge ─────────────────────────────────────── */
.nm-tv-credits-badge {
	text-align: center;
	font-size: 13px;
	font-weight: 500;
	padding: 8px 16px;
	border-radius: 50px;
	margin-top: 16px;
	margin-bottom: 24px;
	display: table;
	margin-left: auto;
	margin-right: auto;
	color: var(--nm-text-secondary);
}

.nm-tv-credits-badge strong {
	font-weight: 700;
}

.nm-tv-credits-free {
	background: rgba(108, 99, 255, 0.15);
	border: 1px solid rgba(108, 99, 255, 0.3);
	color: #a8b2ff;
}

.nm-tv-credits-paid {
	background: rgba(34, 197, 94, 0.1);
	border: 1px solid rgba(34, 197, 94, 0.2);
	color: #22c55e;
}

.nm-tv-credits-empty {
	background: rgba(239, 68, 68, 0.1);
	border: 1px solid rgba(239, 68, 68, 0.2);
	color: #ef4444;
}

.nm-tv-controls:focus-within {
	border-color: #667eea;
	box-shadow: var(--nm-shadow), 0 0 60px rgba(102, 126, 234, 0.25);
}

/* ─── Custom Dropdown ───────────────────────────────────── */
.nm-tv-dropdown-wrap {
	position: relative;
	flex: 1;
	min-width: 200px;
}

.nm-tv-dropdown {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	background: transparent;
	border: none;
	border-radius: 0;
	padding: 12px 16px;
	cursor: pointer;
	color: var(--nm-text);
	font-size: 0.95rem;
	font-weight: 500;
	transition: color var(--nm-transition);
	user-select: none;
	outline: none;
	min-height: 48px;
}

.nm-tv-dropdown:hover,
.nm-tv-dropdown:focus {
	color: #fff;
}

/* Add a subtle separator between the two dropdowns */
#nm-tv-country-wrap::after {
	content: '';
	position: absolute;
	right: 0;
	top: 15%;
	bottom: 15%;
	width: 1px;
	background: var(--nm-border);
}

.nm-tv-dropdown-selected {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.nm-tv-dropdown-arrow {
	flex-shrink: 0;
	color: var(--nm-text-muted);
	transition: transform var(--nm-transition);
}

.nm-tv-dropdown[aria-expanded="true"] .nm-tv-dropdown-arrow {
	transform: rotate(180deg);
}

/* Dropdown list */
.nm-tv-dropdown-list {
	position: absolute;
	top: calc(100% + 6px);
	left: 0;
	right: 0;
	background: var(--nm-surface2);
	border: 1.5px solid var(--nm-border);
	border-radius: var(--nm-radius-sm);
	box-shadow: 0 8px 32px rgba(0,0,0,0.5);
	z-index: 9999;
	display: none;
	flex-direction: column;
	overflow: hidden;
}

.nm-tv-dropdown-list.nm-tv-list-open {
	display: flex;
}

/* Search box inside dropdown */
.nm-tv-dropdown-search {
	padding: 10px 12px;
	border-bottom: 1px solid var(--nm-border);
}

.nm-tv-search-input {
	width: 100%;
	background: var(--nm-bg);
	border: 1px solid var(--nm-border);
	border-radius: 6px;
	padding: 8px 12px;
	color: var(--nm-text);
	font-family: var(--nm-font);
	font-size: 0.875rem;
	outline: none;
	transition: border-color var(--nm-transition);
}

.nm-tv-search-input:focus {
	border-color: var(--nm-accent);
}

/* Items scroll */
.nm-tv-dropdown-items {
	overflow-y: auto;
	max-height: 240px;
	padding: 6px 0;
	scrollbar-width: thin;
	scrollbar-color: var(--nm-accent) transparent;
}

.nm-tv-dropdown-items::-webkit-scrollbar {
	width: 4px;
}

.nm-tv-dropdown-items::-webkit-scrollbar-track {
	background: transparent;
}

.nm-tv-dropdown-items::-webkit-scrollbar-thumb {
	background: var(--nm-accent);
	border-radius: 99px;
}

.nm-tv-dropdown-item {
	padding: 9px 16px;
	font-size: 0.9rem;
	color: var(--nm-text-muted);
	cursor: pointer;
	transition: background var(--nm-transition), color var(--nm-transition);
	border-radius: 0;
}

.nm-tv-dropdown-item:hover {
	background: rgba(108,99,255,0.12);
	color: var(--nm-text);
}

.nm-tv-item-selected {
	color: var(--nm-accent);
	font-weight: 600;
}

/* ─── CTA Button ────────────────────────────────────────── */
.nm-tv-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #fff;
	border: none;
	border-radius: 12px;
	padding: 12px 28px;
	font-family: var(--nm-font);
	font-size: 0.95rem;
	font-weight: 600;
	cursor: pointer;
	transition: transform var(--nm-transition), box-shadow var(--nm-transition);
	min-height: 48px;
	white-space: nowrap;
	flex-shrink: 0;
	margin-left: 10px;
}

.nm-tv-btn:hover:not(:disabled) {
	transform: translateY(-1px);
	box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
}

.nm-tv-btn:active:not(:disabled) {
	transform: translateY(0);
}

.nm-tv-btn:disabled {
	opacity: 0.7;
	cursor: not-allowed;
}

/* Spinner */
.nm-tv-btn-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255,255,255,0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: nm-tv-spin 0.7s linear infinite;
}

.nm-tv-btn-loading .nm-tv-btn-text {
	opacity: 0.7;
}

.nm-tv-btn-loading .nm-tv-btn-spinner {
	display: block;
}

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

/* ─── Results header ────────────────────────────────────── */
.nm-tv-results-header {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-top: 40px;
	margin-bottom: 32px;
	flex-wrap: wrap;
}

.nm-tv-results-title {
	font-size: clamp(1.1rem, 3vw, 1.5rem);
	font-weight: 700;
	color: var(--nm-text);
}

.nm-tv-cached-badge {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: rgba(108,99,255,0.15);
	border: 1px solid rgba(108,99,255,0.3);
	color: #a8b2ff;
	font-size: 0.75rem;
	font-weight: 600;
	padding: 4px 10px;
	border-radius: 99px;
}

/* ─── Loading skeletons ─────────────────────────────────── */
.nm-tv-skeleton-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 20px;
}

.nm-tv-skeleton-card {
	background: var(--nm-surface);
	border: 1px solid var(--nm-border);
	border-radius: var(--nm-radius);
	overflow: hidden;
}

.nm-tv-skeleton-thumb {
	width: 100%;
	padding-top: 56.25%; /* 16:9 */
	background: var(--nm-surface2);
	animation: nm-tv-shimmer 1.5s infinite;
}

.nm-tv-skeleton-body {
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.nm-tv-skeleton-line {
	border-radius: 4px;
	background: var(--nm-surface2);
	animation: nm-tv-shimmer 1.5s infinite;
}

.nm-tv-skeleton-title  { height: 16px; width: 90%; }
.nm-tv-skeleton-meta   { height: 12px; width: 60%; animation-delay: 0.1s; }
.nm-tv-skeleton-stats  { height: 12px; width: 75%; animation-delay: 0.2s; }

@keyframes nm-tv-shimmer {
	0%   { opacity: 0.5; }
	50%  { opacity: 1;   }
	100% { opacity: 0.5; }
}

/* ─── Empty / Error states ──────────────────────────────── */
.nm-tv-empty,
.nm-tv-error {
	text-align: center;
	padding: 60px 20px;
}

.nm-tv-empty-icon,
.nm-tv-error-icon {
	font-size: 3rem;
	margin-bottom: 16px;
}

.nm-tv-empty-text,
.nm-tv-error-text {
	color: var(--nm-text-muted);
	font-size: 1rem;
	line-height: 1.6;
	max-width: 400px;
	margin: 0 auto;
}

.nm-tv-error-text {
	color: #e74c3c;
}

/* ─── Video card grid ───────────────────────────────────── */
.nm-tv-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
	gap: 24px;
}

/* ─── Individual video card ─────────────────────────────── */
.nm-tv-card {
	background: var(--nm-surface);
	border: 1px solid var(--nm-border);
	border-radius: var(--nm-radius);
	overflow: hidden;
	transition: transform var(--nm-transition), box-shadow var(--nm-transition), border-color var(--nm-transition);
	display: flex;
	flex-direction: column;
}

.nm-tv-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 12px 32px rgba(0,0,0,0.5);
	border-color: var(--nm-border-hover);
}

/* Thumbnail */
.nm-tv-card-thumb-link {
	display: block;
	text-decoration: none;
}

.nm-tv-card-thumb {
	position: relative;
	width: 100%;
	padding-top: 56.25%; /* 16:9 */
	overflow: hidden;
	background: var(--nm-surface2);
}

.nm-tv-card-thumb img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.35s ease;
	display: block;
}

.nm-tv-card:hover .nm-tv-card-thumb img {
	transform: scale(1.05);
}

.nm-tv-thumb-placeholder {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 2.5rem;
	color: var(--nm-text-dim);
}

/* Play overlay on hover */
.nm-tv-thumb-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0,0,0,0.45);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity var(--nm-transition);
}

.nm-tv-card:hover .nm-tv-thumb-overlay {
	opacity: 1;
}

.nm-tv-play-icon {
	width: 52px;
	height: 52px;
	background: rgba(255,255,255,0.9);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	color: var(--nm-accent2);
	font-size: 1.1rem;
	padding-left: 4px;
	box-shadow: 0 4px 16px rgba(0,0,0,0.5);
	transition: transform var(--nm-transition);
}

.nm-tv-card:hover .nm-tv-play-icon {
	transform: scale(1.1);
}

/* Card body */
.nm-tv-card-body {
	padding: 18px;
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.nm-tv-card-title {
	font-size: 0.97rem;
	font-weight: 600;
	color: var(--nm-text);
	text-decoration: none;
	line-height: 1.45;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: color var(--nm-transition);
}

.nm-tv-card-title:hover {
	color: #a8b2ff;
}

.nm-tv-card-meta {
	font-size: 0.82rem;
	color: var(--nm-text-muted);
	display: flex;
	align-items: center;
	gap: 6px;
	flex-wrap: wrap;
}

.nm-tv-card-channel {
	font-weight: 500;
	color: #a8b2ff;
}

.nm-tv-card-dot {
	color: var(--nm-text-dim);
}

.nm-tv-card-niche {
	font-size: 0.82rem;
	color: var(--nm-text-muted);
}

.nm-tv-card-niche strong {
	color: var(--nm-text);
}

/* Stats row */
.nm-tv-card-stats {
	display: flex;
	gap: 14px;
	margin-top: auto;
	padding-top: 10px;
	border-top: 1px solid var(--nm-border);
	flex-wrap: wrap;
}

.nm-tv-stat {
	font-size: 0.85rem;
	font-weight: 600;
	color: var(--nm-text);
	display: flex;
	align-items: center;
	gap: 6px;
}

.nm-tv-stat-icon {
	width: 26px;
	height: 26px;
	border-radius: 50%;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.nm-tv-icon-red {
	background: rgba(231,76,60,0.15);
	color: #e74c3c;
}

.nm-tv-icon-blue {
	background: rgba(108,99,255,0.15);
	color: #6c63ff;
}

.nm-tv-icon-green {
	background: rgba(34,197,94,0.15);
	color: #22c55e;
}

/* ─── Credits modal ─────────────────────────────────────── */
.nm-tv-modal-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0,0,0,0.75);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	animation: nm-tv-fade-in 0.2s ease;
}

.nm-tv-modal {
	background: var(--nm-surface);
	border: 1px solid var(--nm-border);
	border-radius: calc(var(--nm-radius) + 4px);
	padding: 40px 36px;
	max-width: 440px;
	width: 100%;
	text-align: center;
	box-shadow: 0 24px 80px rgba(0,0,0,0.7);
	animation: nm-tv-slide-up 0.3s ease;
}

.nm-tv-modal-icon {
	font-size: 3rem;
	margin-bottom: 16px;
}

.nm-tv-modal-title {
	font-size: 1.3rem;
	font-weight: 700;
	color: var(--nm-text);
	margin-bottom: 12px;
}

.nm-tv-modal-body {
	color: var(--nm-text-muted);
	font-size: 0.95rem;
	line-height: 1.6;
	margin-bottom: 28px;
}

.nm-tv-modal-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.nm-tv-modal-btn {
	display: block;
	width: 100%;
	padding: 13px 20px;
	border-radius: var(--nm-radius-sm);
	font-family: var(--nm-font);
	font-size: 0.95rem;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: transform var(--nm-transition), box-shadow var(--nm-transition);
	border: none;
}

.nm-tv-modal-btn-primary {
	background: linear-gradient(135deg, var(--nm-accent) 0%, #8b5cf6 100%);
	color: #fff;
	box-shadow: 0 4px 16px var(--nm-accent-glow);
}

.nm-tv-modal-btn-primary:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 24px var(--nm-accent-glow);
}

.nm-tv-modal-btn-secondary {
	background: transparent;
	color: var(--nm-text-muted);
	border: 1px solid var(--nm-border);
}

.nm-tv-modal-btn-secondary:hover {
	color: var(--nm-text);
	border-color: var(--nm-border-hover);
}

@keyframes nm-tv-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes nm-tv-slide-up {
	from { opacity: 0; transform: translateY(20px); }
	to   { opacity: 1; transform: translateY(0);    }
}

/* ─── Responsive ────────────────────────────────────────── */
@media ( max-width: 768px ) {
	.nm-tv-wrap {
		padding: 28px 18px 36px;
	}

	.nm-tv-controls {
		flex-direction: column;
		border-radius: 16px;
		padding: 12px;
		gap: 12px;
	}

	.nm-tv-dropdown-wrap {
		width: 100%;
	}

	#nm-tv-country-wrap::after {
		display: none;
	}

	.nm-tv-dropdown {
		background: rgba(255, 255, 255, 0.04);
		border-radius: 8px;
	}

	.nm-tv-btn {
		width: 100%;
		margin-left: 0;
	}

	.nm-tv-grid {
		grid-template-columns: 1fr;
	}
}

@media ( max-width: 480px ) {
	.nm-tv-card-stats {
		gap: 10px;
	}
}
