/**
 * Course Listing & Filter Widget Styles
 *
 * Scoped under .cl-widget-container with dynamic CSS variables.
 * @package PracticeProblems
 */

:root {
	--cl-primary: #238E23;
	--cl-text: #0f172a;
	--cl-muted: #64748b;
	--cl-border: #e2e8f0;
	--cl-card-bg: #ffffff;
	--cl-radius: 12px;
}

.cl-widget-container {
	position: relative;
	width: 100%;
	box-sizing: border-box;
	font-family: inherit;
	color: var(--cl-text);
}

.cl-widget-container * {
	box-sizing: border-box;
}

/* ==========================================================================
   Header Controls (Search & Filter)
   ========================================================================== */
.cl-header-controls {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin-bottom: 28px;
}

@media (min-width: 768px) {
	.cl-header-controls {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		flex-wrap: nowrap;
		gap: 20px;
	}
	.cl-search-wrapper {
		flex: 0 1 380px;
		max-width: 440px;
		min-width: 200px;
	}
	.cl-filter-nav {
		flex-shrink: 0;
		margin-left: auto;
		overflow: visible;
	}
}

/* Search Box */
.cl-search-wrapper {
	position: relative;
	width: 100%;
	max-width: 480px;
	display: flex;
	align-items: center;
}

.cl-search-input {
	width: 100%;
	height: 44px;
	padding: 0 40px 0 42px;
	font-size: 15px;
	color: var(--cl-text);
	background-color: #f8fafc;
	border: 1px solid var(--cl-border);
	border-radius: 10px;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.cl-icon-right .cl-search-input {
	padding: 0 42px 0 16px;
}

.cl-search-input::placeholder {
	color: #94a3b8;
}

.cl-search-input:focus {
	background-color: #ffffff;
	border-color: var(--cl-primary);
	box-shadow: 0 0 0 3px rgba(35, 142, 35, 0.2);
}

.cl-search-icon {
	position: absolute;
	left: 14px;
	top: 50%;
	transform: translateY(-50%);
	color: #94a3b8;
	pointer-events: none;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	width: 18px;
	height: 18px;
}

.cl-icon-right .cl-search-icon {
	left: auto;
	right: 14px;
}

.cl-search-clear {
	position: absolute;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	color: #94a3b8;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 4px;
	border-radius: 50%;
	transition: color 0.15s ease;
}

.cl-icon-right .cl-search-clear {
	right: 38px;
}

.cl-search-clear:hover {
	color: var(--cl-text);
}

/* Filter Navigation */
.cl-filter-nav {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}

/* Mobile Scroll Layout (Active ONLY on Mobile Devices) */
@media (max-width: 767px) {
	.cl-filter-nav.cl-overflow-scroll {
		flex-wrap: nowrap;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none; /* Firefox */
		padding-bottom: 4px;
	}

	.cl-filter-nav.cl-overflow-scroll::-webkit-scrollbar {
		display: none; /* Chrome/Safari */
	}
}

.cl-filter-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px 18px;
	font-size: 14px;
	font-weight: 500;
	color: #475569;
	background-color: #f1f5f9;
	border: 1px solid transparent;
	border-radius: 24px;
	cursor: pointer;
	white-space: nowrap;
	text-decoration: none;
	box-sizing: border-box;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.cl-filter-btn:hover {
	color: #0f172a;
	background-color: #e2e8f0;
}

.cl-filter-btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(35, 142, 35, 0.35);
}

.cl-filter-btn.is-active,
.cl-filter-btn[aria-pressed="true"] {
	color: #ffffff;
	background-color: var(--cl-primary);
	border-color: var(--cl-primary);
	font-weight: 500;
	box-shadow: 0 2px 8px rgba(35, 142, 35, 0.25);
}

.cl-filter-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 600;
	padding: 1px 7px;
	border-radius: 12px;
	background-color: rgba(0, 0, 0, 0.08);
	color: inherit;
}

.cl-filter-btn.is-active .cl-filter-count {
	background-color: rgba(255, 255, 255, 0.25);
	color: #ffffff;
}

/* ==========================================================================
   Course Grid
   ========================================================================== */
.cl-courses-grid {
	display: grid;
	grid-template-columns: repeat(var(--cl-grid-columns, 3), minmax(0, 1fr));
	gap: 24px;
	column-gap: var(--cl-col-gap, 24px);
	row-gap: var(--cl-row-gap, 24px);
	transition: opacity 0.2s ease;
	min-height: 200px;
}

@media (max-width: 991px) {
	.cl-courses-grid {
		grid-template-columns: repeat(var(--cl-grid-columns, 2), minmax(0, 1fr));
	}
}

@media (max-width: 640px) {
	.cl-courses-grid {
		grid-template-columns: repeat(var(--cl-grid-columns, 1), minmax(0, 1fr));
	}
}

/* ==========================================================================
   Skeleton Shimmer Placeholders
   ========================================================================== */
.cl-loading-skeleton {
	width: 100%;
}

.cl-skeleton-card {
	display: flex;
	flex-direction: column;
	background: var(--cl-card-bg, #ffffff);
	border: 1px solid var(--cl-border, #e2e8f0);
	border-radius: var(--cl-radius, 12px);
	overflow: hidden;
	height: 380px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.cl-skeleton-thumb {
	width: 100%;
	height: 190px;
	background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
	background-size: 200% 100%;
	animation: clShimmer 1.5s infinite;
}

.cl-skeleton-body {
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	flex: 1;
}

.cl-skeleton-pill {
	width: 70px;
	height: 20px;
	border-radius: 12px;
	background: #e2e8f0;
}

.cl-skeleton-line {
	height: 14px;
	border-radius: 4px;
	background: #e2e8f0;
}

.cl-skeleton-line.cl-line-title {
	width: 80%;
	height: 20px;
}

.cl-skeleton-line.cl-line-desc {
	width: 95%;
	height: 32px;
}

.cl-skeleton-meta {
	width: 60%;
	height: 14px;
	border-radius: 4px;
	background: #e2e8f0;
	margin-top: auto;
}

@keyframes clShimmer {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* ==========================================================================
   Course Card
   ========================================================================== */
.cl-course-card {
	display: flex;
	flex-direction: column;
	background-color: var(--cl-card-bg);
	border: 1px solid var(--cl-border);
	border-radius: var(--cl-radius);
	overflow: hidden;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
	transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.cl-course-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.1), 0 4px 8px -2px rgba(0, 0, 0, 0.04);
	border-color: #cbd5e1;
}

/* Thumbnail */
.cl-card-thumb {
	position: relative;
	width: 100%;
	height: 190px;
	background-color: #f1f5f9;
	overflow: hidden;
}

.cl-card-thumb a {
	display: block;
	width: 100%;
	height: 100%;
	text-decoration: none;
}

.cl-thumb-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
}

.cl-course-card:hover .cl-thumb-img {
	transform: scale(1.04);
}

.cl-thumb-placeholder {
	width: 100%;
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.cl-course-icon {
	font-size: 48px;
	width: 48px;
	height: 48px;
	color: #94a3b8;
}

/* Card Badges */
.cl-card-badges {
	position: absolute;
	top: 12px;
	left: 12px;
	right: 12px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	pointer-events: none;
}

.cl-badges-inline {
	position: static;
	margin-bottom: 12px;
}

.cl-badge {
	display: inline-flex;
	align-items: center;
	padding: 4px 10px;
	font-size: 11px;
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	border-radius: 6px;
	backdrop-filter: blur(8px);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cl-level-badge {
	background-color: rgba(255, 255, 255, 0.92);
	color: var(--cl-primary);
	border: 1px solid rgba(0, 0, 0, 0.06);
}

.cl-cat-badge {
	background-color: rgba(15, 23, 42, 0.85);
	color: #ffffff;
}

.cl-status-badge {
	margin-left: auto;
	background-color: #f59e0b;
	color: #ffffff;
}

/* Card Content Body */
.cl-card-content {
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	padding: 20px;
}

.cl-card-title {
	margin: 0 0 8px 0;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.35;
}

.cl-card-title a {
	color: inherit;
	text-decoration: none;
	transition: color 0.15s ease;
}

.cl-card-title a:hover {
	color: var(--cl-primary);
}

.cl-card-desc {
	margin: 0 0 16px 0;
	font-size: 14px;
	line-height: 1.5;
	color: var(--cl-muted);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* Card Meta Row (Chapters, Problems, Duration) */
.cl-card-meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 16px;
	margin-top: auto;
	padding-top: 14px;
	border-top: 1px solid #f1f5f9;
	font-size: 13px;
	color: #475569;
}

.cl-meta-item {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
}

.cl-meta-icon {
	color: #94a3b8;
	flex-shrink: 0;
}

.cl-meta-item strong {
	color: var(--cl-text);
	font-weight: 600;
}

.cl-card-instructor {
	margin-top: 10px;
	font-size: 12px;
	color: #64748b;
}

.cl-inst-label {
	color: #94a3b8;
}

/* Card Footer & CTA Button */
.cl-card-footer {
	margin-top: 16px;
}

.cl-card-cta-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	gap: 8px;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 600;
	color: var(--cl-primary);
	background-color: rgba(35, 142, 35, 0.08);
	border: 1px solid transparent;
	border-radius: 8px;
	text-decoration: none;
	transition: all 0.2s ease;
}

.cl-card-cta-btn:hover {
	color: #ffffff;
	background-color: var(--cl-primary);
}

.cl-cta-arrow {
	transition: transform 0.2s ease;
}

.cl-card-cta-btn:hover .cl-cta-arrow {
	transform: translateX(4px);
}

/* ==========================================================================
   Skeleton Shimmer UI
   ========================================================================== */
@keyframes cl-shimmer {
	0% {
		background-position: -468px 0;
	}
	100% {
		background-position: 468px 0;
	}
}

.cl-skeleton-card {
	background: #ffffff;
	border: 1px solid var(--cl-border);
	border-radius: var(--cl-radius);
	overflow: hidden;
}

.cl-skeleton-thumb {
	height: 190px;
	background: #f1f5f9;
	background-image: linear-gradient(to right, #f1f5f9 0%, #e2e8f0 20%, #f1f5f9 40%, #f1f5f9 100%);
	background-repeat: no-repeat;
	background-size: 800px 190px;
	animation: cl-shimmer 1.2s infinite linear forwards;
}

.cl-skeleton-body {
	padding: 20px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.cl-skeleton-pill {
	width: 80px;
	height: 20px;
	border-radius: 6px;
	background: #f1f5f9;
	animation: cl-shimmer 1.2s infinite linear forwards;
}

.cl-skeleton-line {
	height: 14px;
	border-radius: 4px;
	background: #f1f5f9;
	animation: cl-shimmer 1.2s infinite linear forwards;
}

.cl-skeleton-line.cl-line-title {
	width: 75%;
	height: 20px;
}

.cl-skeleton-line.cl-line-desc {
	width: 100%;
}

.cl-skeleton-meta {
	width: 60%;
	height: 14px;
	margin-top: 12px;
	border-radius: 4px;
	background: #f1f5f9;
	animation: cl-shimmer 1.2s infinite linear forwards;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.cl-empty-state {
	text-align: center;
	padding: 56px 24px;
	background: #f8fafc;
	border: 2px dashed #e2e8f0;
	border-radius: var(--cl-radius);
	margin-top: 16px;
}

.cl-empty-icon {
	font-size: 42px;
	color: #94a3b8;
	margin-bottom: 12px;
}

.cl-empty-title {
	margin: 0 0 8px 0;
	font-size: 20px;
	font-weight: 700;
	color: var(--cl-text);
}

.cl-empty-desc {
	margin: 0 auto 20px auto;
	max-width: 440px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--cl-muted);
}

.cl-empty-reset-btn {
	display: inline-flex;
	align-items: center;
	padding: 10px 22px;
	font-size: 14px;
	font-weight: 600;
	color: #ffffff;
	background-color: var(--cl-primary);
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.15s ease;
}

.cl-empty-reset-btn:hover {
	filter: brightness(0.95);
	transform: translateY(-1px);
}

/* ==========================================================================
   Pagination
   ========================================================================== */
.cl-pagination-wrapper {
	margin-top: 40px;
	display: flex;
	justify-content: center;
}

.cl-pagination-nav {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.cl-page-numbers {
	display: inline-flex;
	gap: 6px;
}

.cl-page-btn,
.cl-page-number {
	min-width: 38px;
	height: 38px;
	padding: 0 12px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 14px;
	font-weight: 600;
	color: #475569;
	background: #f8fafc;
	border: 1px solid var(--cl-border);
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.15s ease;
}

.cl-page-btn:hover:not(:disabled),
.cl-page-number:hover:not(.is-active) {
	background: #e2e8f0;
	color: var(--cl-text);
}

.cl-page-number.is-active,
.cl-page-number[aria-current="page"] {
	background: var(--cl-primary);
	border-color: var(--cl-primary);
	color: #ffffff;
	cursor: default;
}

.cl-page-btn:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* Load More Button */
.cl-load-more-btn {
	padding: 12px 32px;
	font-size: 15px;
	font-weight: 600;
	color: var(--cl-text);
	background: #ffffff;
	border: 1px solid var(--cl-border);
	border-radius: 28px;
	cursor: pointer;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
	transition: all 0.2s ease;
}

.cl-load-more-btn:hover {
	border-color: #cbd5e1;
	background: #f8fafc;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.cl-load-more-btn.is-loading {
	opacity: 0.7;
	pointer-events: none;
}

/* Infinite Scroll Sentinel Spinner */
.cl-spinner {
	display: inline-block;
	width: 32px;
	height: 32px;
	border: 3px solid rgba(35, 142, 35, 0.2);
	border-top-color: var(--cl-primary);
	border-radius: 50%;
	animation: cl-spin 0.8s linear infinite;
}

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