/* Summary Cards */
.stats-summary-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
	gap: 1.5rem;
	margin-bottom: 3rem;
}

.stat-card {
	background-color: var(--card-bg);
	border-radius: 0.75rem;
	padding: 1.5rem;
	box-shadow: var(--shadow);
	border: 1px solid var(--border-color);
	transition: transform 0.3s ease;
	display: flex;
	align-items: center;
	gap: 1rem;
}

.stat-card:hover {
	transform: translateY(-5px);
	box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.stat-icon {
	width: 3.5rem;
	height: 3.5rem;
	border-radius: 50%;
	background-color: var(--accent-color-light);
	color: var(--accent-color);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
}

.stat-content {
	flex: 1;
}

.stat-content h3 {
	font-size: 1rem;
	font-weight: 600;
	margin-bottom: 0.25rem;
	color: var(--text-primary);
}

.stat-value {
	font-size: 1.75rem;
	font-weight: 700;
	color: var(--accent-color);
	line-height: 1;
}

.stat-description {
	font-size: 0.85rem;
	color: var(--text-secondary);
	margin-top: 0.25rem;
}

/* Stats Description */
.stats-description {
	max-width: 1600px;
	margin: 0 auto 2rem auto;
	text-align: center;
	color: var(--text-secondary);
	line-height: 1.6;
	padding: 0 1rem;
}

.stats-description p {
	margin-bottom: 1rem;
}

.stats-description a {
	color: var(--accent-color);
	text-decoration: none;
	transition: color 0.2s ease;
}

.stats-description a:hover {
	color: var(--accent-color-hover);
	text-decoration: underline;
}

/* Charts Section */
.charts-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1.5rem;
	margin-bottom: 3rem;
}

.full-width-chart {
	grid-column: 1 / -1;
}

.half-width-chart {
	grid-column: span 1;
}

.chart-container {
	background-color: var(--card-bg);
	border-radius: 0.75rem;
	padding: 1rem;
	box-shadow: var(--shadow);
	border: 1px solid var(--border-color);
	height: 400px;
	position: relative;
}

/* Chart Canvas Styles */
.chart-container canvas {
	display: block;
	width: 100% !important;
	height: calc(100% - 40px) !important;
	min-height: 300px;
	max-height: 350px;
}

.chart-container h3 {
	font-size: 1.1rem;
	font-weight: 600;
	margin-bottom: 1rem;
	color: var(--text-primary);
}

/* Detailed Stats */
.detailed-stats {
	background-color: var(--card-bg);
	border-radius: 0.75rem;
	padding: 1.5rem;
	box-shadow: var(--shadow);
	border: 1px solid var(--border-color);
	margin-bottom: 3rem;
}

.detailed-stats h3 {
	font-size: 1.25rem;
	font-weight: 600;
	margin-bottom: 1.5rem;
	color: var(--text-primary);
}

.stats-controls {
	display: flex;
	justify-content: space-between;
	margin-bottom: 1.5rem;
	flex-wrap: wrap;
	gap: 1rem;
}

.search-control {
	position: relative;
	flex: 1;
	min-width: 250px;
}

.search-control i {
	position: absolute;
	left: 1rem;
	top: 50%;
	transform: translateY(-50%);
	color: var(--text-secondary);
}

.search-control input {
	width: 100%;
	padding: 0.75rem 1rem 0.75rem 2.5rem;
	border-radius: 0.5rem;
	border: 1px solid var(--border-color);
	background-color: var(--bg-primary);
	color: var(--text-primary);
	transition: border-color 0.3s ease;
}

.search-control input:focus {
	outline: none;
	border-color: var(--accent-color);
}

.sort-control {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.sort-control label {
	color: var(--text-secondary);
	font-size: 0.9rem;
}

.sort-control select {
	padding: 0.5rem 1rem;
	border-radius: 0.5rem;
	border: 1px solid var(--border-color);
	background-color: var(--bg-primary);
	color: var(--text-primary);
	cursor: pointer;
}

.stats-table-container {
	overflow-x: auto;
}

.stats-table {
	width: 100%;
	border-collapse: collapse;
}

.stats-table th {
	text-align: left;
	padding: 1rem;
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	font-weight: 600;
	border-bottom: 2px solid var(--border-color);
}

.stats-table td {
	padding: 1rem;
	border-bottom: 1px solid var(--border-color);
	color: var(--text-primary);
}

.stats-table tr:hover td {
	background-color: var(--bg-tertiary);
}

.view-details-btn {
	padding: 0.5rem 1rem;
	background-color: var(--accent-color);
	color: white;
	border: none;
	border-radius: 0.5rem;
	cursor: pointer;
	font-size: 0.85rem;
	transition: background-color 0.3s ease;
}

.view-details-btn:hover {
	background-color: var(--accent-color-dark);
}

.pagination-controls {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 1rem;
	margin-top: 1.5rem;
}

.pagination-controls button {
	padding: 0.5rem 1rem;
	background-color: var(--bg-secondary);
	color: var(--text-primary);
	border: 1px solid var(--border-color);
	border-radius: 0.5rem;
	cursor: pointer;
	transition: all 0.3s ease;
}

.pagination-controls button:hover:not(:disabled) {
	background-color: var(--bg-tertiary);
	border-color: var(--accent-color);
}

.pagination-controls button:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.pagination-controls #pageInfo {
	color: var(--text-primary);
	font-size: 0.9rem;
}

/* Modal Styles */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 1000;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
}

.modal-overlay.active {
	opacity: 1;
	visibility: visible;
}

.modal-content {
	background-color: var(--card-bg);
	border-radius: 0.75rem;
	padding: 2rem;
	box-shadow: var(--shadow);
	border: 1px solid var(--border-color);
	max-width: 600px;
	width: 90%;
	max-height: 80vh;
	overflow-y: auto;
	transform: translateY(-20px);
	transition: transform 0.3s ease;
}

.modal-overlay.active .modal-content {
	transform: translateY(0);
}

.modal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1.5rem;
}

.modal-title {
	font-size: 1.5rem;
	font-weight: 600;
	color: var(--text-primary);
	margin: 0;
}

.modal-close {
	background: none;
	border: none;
	font-size: 1.5rem;
	cursor: pointer;
	color: var(--text-secondary);
	transition: color 0.3s ease;
}

.modal-close:hover {
	color: var(--text-primary);
}

.modal-body {
	margin-bottom: 1.5rem;
}

.modal-stats-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 1rem;
	margin-bottom: 1.5rem;
}

.modal-stat-item {
	background-color: var(--bg-secondary);
	padding: 1rem;
	border-radius: 0.5rem;
}

.modal-stat-label {
	font-size: 0.9rem;
	color: var(--text-secondary);
	margin-bottom: 0.25rem;
}

.modal-stat-value {
	font-size: 1.25rem;
	font-weight: 600;
	color: var(--accent-color);
}

/* Chart.js overrides for theme support */
.chart-container canvas {
	/* Force chart text to use theme colors */
	color: var(--text-primary) !important;
}

/* I hate chart.js #1 */
.chartjs-tooltip {
	background-color: var(--card-bg) !important;
	border: 1px solid var(--border-color) !important;
	border-radius: 0.5rem !important;
	box-shadow: var(--shadow-lg) !important;
	color: var(--text-primary) !important;
	padding: 0.75rem 1rem !important;
	opacity: 1 !important;
	pointer-events: none !important;
	position: absolute !important;
	transform: translate(-50%, 0) !important;
	transition: all 0.1s ease !important;
	z-index: 1000 !important;
}

/* I hate chart.js #2 */
.chart-container canvas {
	/* Force chart text to use theme colors, (im not asking) */
	color: var(--text-primary) !important;
}

/* I hate chart.js #3 */
.chartjs-render-monitor text {
	fill: var(--text-primary) !important;
	color: var(--text-primary) !important;
	font-family: var(--font-body) !important;
}

/* I hate chart.js #4 */
.chartjs-render-monitor .chart-axis-label text {
	fill: var(--text-primary) !important;
	color: var(--text-primary) !important;
}

/* I hate chart.js #5 */
.chartjs-render-monitor .chart-grid-line {
	stroke: var(--border-color) !important;
}

/* I hate chart.js #5 */
.chartjs-render-monitor .chart-legend text {
	fill: var(--text-primary) !important;
	color: var(--text-primary) !important;
}

/* I hate chart.js #6 */
.chartjs-tooltip {
	background-color: var(--card-bg) !important;
	border: 1px solid var(--border-color) !important;
	color: var(--text-primary) !important;
	padding: 8px 12px !important;
	border-radius: 4px !important;
	box-shadow: var(--shadow) !important;
}

/* I hate chart.js #7 */
.chartjs-tooltip-header {
	color: var(--text-primary) !important;
	font-weight: bold !important;
	margin-bottom: 4px !important;
}

/* I hate chart.js #8 */
.chartjs-tooltip-body {
	color: var(--text-primary) !important;
}

/* I hate chart.js #9 */
.chartjs-tooltip-key {
	display: inline-block !important;
	width: 10px !important;
	height: 10px !important;
	margin-right: 5px !important;
	border-radius: 2px !important;
}

/* I hate chart.js #10 */
.chartjs-chart text {
	fill: var(--text-primary) !important;
	color: var(--text-primary) !important;
}

/* I hate chart.js #11 */
.chartjs-scale,
.chartjs-scale-x,
.chartjs-scale-y {
	color: var(--text-primary) !important;
}

/* I hate chart.js #12 */
.chartjs-datalabels {
	color: var(--text-primary) !important;
	text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7) !important;
}

/* I hate chart.js #13 */
.dark-theme .chartjs-tooltip {
	background-color: var(--bg-dark-secondary) !important;
	border-color: var(--border-color) !important;
}

.dark-theme .chartjs-tooltip::before {
	border-top-color: var(--bg-dark-secondary) !important;
}

/* I hate chart.js #14 */
body.chart-theme-updated {
	/* This class forces Chart.js to redraw with new colors (forcefully) */
	/* Because why not, we gotta add 116 lines of CSS to make this work */
}

/* Loading Overlay */
.loading-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 1001;
	transition: opacity 0.3s ease, visibility 0.3s ease;
}


.loading-overlay.hidden {
	opacity: 0;
	visibility: hidden;
}

.loader-spinner {
	width: 50px;
	height: 50px;
	border: 5px solid rgba(var(--accent-color-hover), 0.2);
	border-radius: 50%;
	border-top-color: var(--accent-color);
	animation: spin 1s ease-in-out infinite;
	margin-bottom: 1.5rem;
}

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

.loading-text {
	color: var(--text-primary);
	font-size: 1.25rem;
	font-weight: 500;
	margin-bottom: 0.5rem;
}

.loading-subtext {
	color: var(--text-secondary);
	font-size: 0.9rem;
	max-width: 300px;
	text-align: center;
}

.loading-progress {
	width: 200px;
	height: 4px;
	background-color: rgba(var(--accent-color-hover), 0.2);
	border-radius: 2px;
	margin-top: 1rem;
	overflow: hidden;
}

.loading-progress-bar {
	height: 100%;
	background-color: var(--accent-color);
	width: 0%;
	transition: width 0.3s ease;
}

/* Responsive Styles */
@media (min-width: 768px) {
	.charts-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.full-width-chart {
		grid-column: 1 / -1;
	}
}

@media (max-width: 768px) {
	.stats-summary-grid {
		grid-template-columns: 1fr 1fr;
	}

	.stats-controls {
		flex-direction: column;
	}

	.search-control {
		min-width: 100%;
	}

	.modal-stats-grid {
		grid-template-columns: 1fr;
	}
}

@media (max-width: 480px) {
	.stats-summary-grid {
		grid-template-columns: 1fr;
	}

	.stat-card {
		flex-direction: column;
		text-align: center;
	}

	.stat-icon {
		margin-bottom: 1rem;
	}
}