/* Reset e base */
*,
*::before,
*::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

:root {
	--color-primary: #1a56db;
	--color-primary-dark: #1e40af;
	--color-secondary: #10b981;
	--color-bg: #f8fafc;
	--color-surface: #ffffff;
	--color-text: #1e293b;
	--color-text-muted: #64748b;
	--color-border: #e2e8f0;
	--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
	--shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
	--shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
	--radius: 8px;
	--radius-lg: 12px;
}

html {
	font-size: 16px;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	background: var(--color-bg);
	color: var(--color-text);
	line-height: 1.5;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
}

/* Header */
header {
	background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
	color: white;
	padding: 1.5rem 1rem;
	text-align: center;
	box-shadow: var(--shadow-md);
}

header h1 {
	font-size: 1.5rem;
	font-weight: 700;
	margin-bottom: 0.25rem;
}

header .subtitle {
	font-size: 0.875rem;
	opacity: 0.9;
}

/* Main */
main {
	flex: 1;
	max-width: 1200px;
	width: 100%;
	margin: 0 auto;
	padding: 1.5rem 1rem;
}

/* Controls Section */
.controls {
	background: var(--color-surface);
	border-radius: var(--radius-lg);
	padding: 1.25rem;
	box-shadow: var(--shadow-sm);
	margin-bottom: 1.5rem;
	display: flex;
	flex-wrap: wrap;
	gap: 1rem;
	align-items: center;
}

.select-wrapper {
	flex: 1;
	min-width: 250px;
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.select-wrapper label {
	font-weight: 600;
	color: var(--color-text-muted);
	white-space: nowrap;
}

select {
	flex: 1;
	padding: 0.75rem 1rem;
	border: 2px solid var(--color-border);
	border-radius: var(--radius);
	font-size: 1rem;
	background: var(--color-surface);
	color: var(--color-text);
	cursor: pointer;
	transition: border-color 0.2s, box-shadow 0.2s;
}

select:hover:not(:disabled) {
	border-color: var(--color-primary);
}

select:focus {
	outline: none;
	border-color: var(--color-primary);
	box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

select:disabled {
	background: var(--color-bg);
	cursor: not-allowed;
	opacity: 0.7;
}

/* Toggle Checkbox */
.toggle-checkbox {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	cursor: pointer;
	font-size: 0.875rem;
	color: var(--color-text-muted);
	white-space: nowrap;
	user-select: none;
}

.toggle-checkbox input[type="checkbox"] {
	width: 18px;
	height: 18px;
	accent-color: var(--color-primary);
	cursor: pointer;
}

.toggle-checkbox span {
	font-weight: 500;
}

/* Metric Toggle */
.metric-toggle {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.metric-toggle label {
	font-weight: 600;
	color: var(--color-text-muted);
	margin-right: 0.25rem;
}

.toggle-btn {
	padding: 0.5rem 1rem;
	border: 2px solid var(--color-border);
	border-radius: var(--radius);
	background: var(--color-surface);
	color: var(--color-text-muted);
	font-size: 0.875rem;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s;
}

.toggle-btn:hover {
	border-color: var(--color-primary);
	color: var(--color-primary);
}

.toggle-btn.active {
	background: var(--color-primary);
	border-color: var(--color-primary);
	color: white;
}

/* Chart Section */
.chart-section {
	margin-bottom: 1.5rem;
}

#chart-container {
	background: var(--color-surface);
	border-radius: var(--radius-lg);
	box-shadow: var(--shadow-md);
	padding: 1rem;
	min-height: 400px;
	position: relative;
	overflow: hidden;
}

/* Loading Indicator */
.loading {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.95);
	display: none;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 1rem;
	z-index: 10;
}

.loading.visible {
	display: flex;
}

.spinner {
	width: 40px;
	height: 40px;
	border: 3px solid var(--color-border);
	border-top-color: var(--color-primary);
	border-radius: 50%;
	animation: spin 0.8s linear infinite;
}

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

.loading span {
	color: var(--color-text-muted);
	font-size: 0.875rem;
}

/* Info Section */
.info-section {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: 1rem;
	align-items: start;
}

#info-card {
	background: var(--color-surface);
	border-radius: var(--radius);
	padding: 1rem 1.25rem;
	box-shadow: var(--shadow-sm);
}

#info-text {
	color: var(--color-text-muted);
	font-size: 0.9375rem;
}

#stats-card {
	background: var(--color-surface);
	border-radius: var(--radius);
	padding: 1rem 1.25rem;
	box-shadow: var(--shadow-sm);
	display: flex;
	gap: 1.5rem;
}

#stats-card.hidden {
	display: none;
}

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

.stat-label {
	font-size: 0.75rem;
	color: var(--color-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.05em;
	margin-bottom: 0.25rem;
}

.stat-value {
	font-size: 1rem;
	font-weight: 600;
	color: var(--color-text);
}

/* Footer */
footer {
	background: var(--color-surface);
	border-top: 1px solid var(--color-border);
	padding: 1rem;
	text-align: center;
	font-size: 0.875rem;
	color: var(--color-text-muted);
}

footer p {
	margin: 0.25rem 0;
}

footer a {
	color: var(--color-primary);
	text-decoration: none;
}

footer a:hover {
	text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
	header h1 {
		font-size: 1.25rem;
	}

	.controls {
		flex-direction: column;
		align-items: stretch;
	}

	.select-wrapper {
		flex-direction: column;
		align-items: stretch;
		gap: 0.75rem;
	}

	.toggle-checkbox {
		justify-content: flex-start;
	}

	.metric-toggle {
		justify-content: center;
		flex-wrap: wrap;
	}

	#chart-container {
		padding: 0.5rem;
		min-height: 300px;
	}

	.info-section {
		grid-template-columns: 1fr;
	}

	#stats-card {
		justify-content: space-around;
	}
}

@media (max-width: 480px) {
	.toggle-btn {
		padding: 0.4rem 0.75rem;
		font-size: 0.8rem;
	}

	.stat-value {
		font-size: 0.875rem;
	}
}

/* Print */
@media print {
	header,
	.controls,
	footer {
		display: none;
	}

	#chart-container {
		box-shadow: none;
		border: 1px solid #000;
	}
}
