/**
 * Election Stats Display Styles
 * Modern UI/UX for election statistics display
 */

.election-stats-container {
	margin: 0;
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	padding: 0;
	height: 100%;
	display: flex;
	flex-direction: column;
}

.election-stats-header {
	background: #FF6B35;
	color: #ffffff;
	padding: 1.75rem 2rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 1rem;
	border-bottom: 3px solid rgba(255, 255, 255, 0.1);
	min-height: 127px;
}

.election-stats-title {
	font-size: 23px;
	font-weight: 400;
	margin: 0;
	color: #ffffff;
	line-height: 1.4;
	letter-spacing: -0.01em;
}

.election-stats-date {
	font-size: 0.9rem;
	font-weight: 400;
	opacity: 0.95;
}

.election-stats-toggle-btn {
	background: rgba(255, 255, 255, 0.15);
	border: 2px solid rgba(255, 255, 255, 0.4);
	color: #ffffff;
	padding: 0.75rem 1.5rem;
	border-radius: 8px;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
	white-space: nowrap;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.election-stats-toggle-btn:hover {
	background: rgba(255, 255, 255, 0.3);
	border-color: rgba(255, 255, 255, 0.5);
	transform: translateY(-1px);
}

.election-stats-toggle-btn:active {
	transform: translateY(0);
}

.election-stats-view {
	display: none;
	padding: 2rem;
	flex: 1 1 auto;
	min-height: 0;
}

.election-stats-view.active {
	display: block;
}

.election-registration-stats .election-stats-view.active {
	display: block;
}

.election-registration-stats .election-stats-summary.active {
	overflow: visible;
	overflow-y: visible;
	overflow-x: visible;
	max-height: none;
	height: auto;
}

.election-registration-stats .election-stats-summary .election-stats-table-wrapper {
	overflow: visible;
	max-height: none;
}

.election-stats-detail {
	overflow-y: auto;
	overflow-x: hidden;
	padding-right: 1rem;
	margin-right: -1rem;
}

.election-stats-detail .election-stats-table-wrapper {
	padding-right: 1rem;
	position: relative;
	max-height: 100%;
}

.election-stats-detail::-webkit-scrollbar {
	width: 8px;
}

.election-stats-detail::-webkit-scrollbar-track {
	background: #f1f1f1;
	border-radius: 4px;
}

.election-stats-detail::-webkit-scrollbar-thumb {
	background: #c1c1c1;
	border-radius: 4px;
	transition: background 0.2s ease;
}

.election-stats-detail::-webkit-scrollbar-thumb:hover {
	background: #a8a8a8;
}

.election-stats-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 2.5rem;
	align-items: center;
	width: 100%;
	overflow: visible;
}

.election-stats-summary .election-stats-grid {
	overflow: visible;
	max-height: none;
}

@media (max-width: 968px) {
	.election-stats-grid {
		grid-template-columns: 1fr;
		gap: 2rem;
	}
}

.election-stats-table-wrapper {
	overflow-x: auto;
}

.election-stats-summary .election-stats-table-wrapper {
	overflow-x: visible;
	overflow-y: visible;
	max-height: none;
	height: auto;
}

.election-stats-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9375rem;
}

.election-stats-summary .election-stats-table {
	overflow: visible;
}

.election-stats-table thead {
	background: #f8f9fa;
}

.election-stats-table thead th {
	padding: 1rem;
	text-align: left;
	font-weight: 700;
	color: #333;
	border-bottom: 2px solid #dee2e6;
	font-size: 0.8125rem;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	background: #f8f9fa;
	vertical-align: middle;
}

.election-stats-table thead th:last-child,
.election-stats-table thead th:nth-child(3) {
	text-align: right;
}

.election-stats-table tbody tr td:nth-child(2),
.election-stats-table tbody tr td:nth-child(3) {
	text-align: right;
}

.election-vbm-requests .election-stats-table td:nth-child(2) {
	text-align: right;
}

.election-vbm-requests .election-vbm-view {
	padding: 2rem;
	display: grid;
	align-items: flex-start;
}

.election-vbm-requests .election-stats-table-wrapper {
	margin: 0;
}

.election-vbm-requests .election-stats-table {
	margin-bottom: 0;
}

.election-vbm-requests .election-stats-table thead th {
	padding: 0.75rem 1rem;
	font-size: 0.75rem;
}

.election-vbm-requests .election-stats-table td {
	padding: 0.625rem 1rem;
	font-size: 0.9375rem;
}

.election-vbm-requests .election-stats-table tbody tr:last-child td {
	padding-bottom: 0.875rem;
}

.election-vbm-requests .election-stats-today-row td {
	padding-top: 0.875rem;
	padding-bottom: 0.875rem;
}

.election-stats-table td,
.election-stats-table tbody th {
	padding: 0.875rem 1rem;
	border-bottom: 1px solid #e9ecef;
	color: #333;
	text-align: left;
	font-size: 0.9375rem;
	line-height: 1.4;
	vertical-align: middle;
}

.election-stats-table tbody tr {
	transition: background-color 0.2s ease;
}

.election-stats-table tbody tr:hover {
	background: #f5f7fa;
}

.election-stats-table tbody tr:last-child td {
	border-bottom: none;
}

.election-stats-count {
	font-weight: 700;
	color: #333;
	text-align: right;
	font-variant-numeric: tabular-nums;
	font-size: 0.9375rem;
	letter-spacing: -0.02em;
}

.election-stats-percentage {
	text-align: right;
	color: #666;
	font-variant-numeric: tabular-nums;
}

.election-stats-total-row {
	background: #f8f9fa !important;
	border-top: 3px solid #dee2e6;
}

.election-stats-total-row td,
.election-stats-total-row th {
	padding-top: 1.25rem;
	padding-bottom: 1.25rem;
	font-size: 1rem;
	font-weight: 700;
	color: #333;
}

.election-stats-today-row {
	background: #fff9e6;
	font-weight: 600;
	border-left: 4px solid #ffc107;
}

.election-stats-today-row td {
	padding-left: calc(1rem - 4px);
}

.election-stats-chart-wrapper {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	padding: 1.5rem 0.5rem;
	gap: 1.25rem;
	background: transparent;
	border-radius: 12px;
	position: relative;
	min-height: 350px;
}

.election-stats-chart-container {
	position: relative;
	display: inline-block;
	transform-style: preserve-3d;
	perspective: 1000px;
	filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.08));
}

.election-stats-pie-chart {
	max-width: 100%;
	height: auto;
	display: block;
	cursor: pointer;
	transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
	image-rendering: -webkit-optimize-contrast;
	image-rendering: crisp-edges;
	border-radius: 50%;
	background: transparent;
}

.election-stats-pie-chart:hover {
	transform: translateZ(8px) scale(1.02);
}

.election-stats-tooltip {
	position: absolute;
	display: none;
	background: rgba(40, 40, 40, 0.98);
	border: none;
	border-radius: 10px;
	padding: 0.875rem 1.125rem;
	box-shadow: 
		0 8px 20px rgba(0, 0, 0, 0.3),
		0 0 0 1px rgba(255, 255, 255, 0.1) inset;
	pointer-events: none;
	z-index: 1000;
	transform: translate(-50%, -50%);
	white-space: nowrap;
	font-size: 0.875rem;
	animation: tooltipFadeIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
}

.election-stats-tooltip .tooltip-label {
	font-weight: 700;
	color: #ffffff;
	margin-bottom: 0.375rem;
	display: block;
	font-size: 0.9375rem;
	letter-spacing: 0.5px;
}

.election-stats-tooltip .tooltip-value {
	color: rgba(255, 255, 255, 0.9);
	font-size: 0.8125rem;
	display: block;
	font-weight: 600;
	letter-spacing: 0.3px;
}

@keyframes tooltipFadeIn {
	from {
		opacity: 0;
		transform: translate(-50%, -50%) scale(0.85) translateY(-5px);
	}
	to {
		opacity: 1;
		transform: translate(-50%, -50%) scale(1) translateY(0);
	}
}

.election-stats-legend {
	width: 100%;
	max-width: 100%;
}

.election-stats-legend-items {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 1rem;
	justify-content: center;
	align-items: center;
	padding: 0.25rem 0;
}

.election-stats-legend-item {
	display: flex;
	align-items: center;
	gap: 0rem;
	font-size: 0.875rem;
	transition: transform 0.2s ease, opacity 0.2s ease;
	cursor: pointer;
	padding: 0rem;
	border-radius: 4px;
	margin: 0;
}

.election-stats-legend-item:hover {
	transform: translateX(5px);
	opacity: 0.85;
	background: rgba(0, 0, 0, 0.03);
}

.election-stats-legend-color {
	width: 16px;
	height: 16px;
	border-radius: 3px;
	flex-shrink: 0;
	border: 1.5px solid rgba(255, 255, 255, 0.9);
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.election-stats-legend-item:hover .election-stats-legend-color {
	transform: scale(1.1);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.election-stats-legend-label {
	font-weight: 600;
	color: #333;
	font-size: 0.875rem;
	line-height: 1.3;
	white-space: nowrap;
}

.election-stats-legend-percentage {
	display: none;
}

.election-stats-combined {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 2.5rem;
	margin: 2rem 0;
	align-items: stretch;
}

.election-stats-combined .election-stats-container {
	display: flex;
	flex-direction: column;
	height: 100%;
	min-height: 500px;
}

@media (max-width: 1374px) {
	.election-stats-combined {
		grid-template-columns: 1fr;
		gap: 2rem;
	}
}

.election-stats-message {
	padding: 1.5rem;
	background: #f8f9fa;
	border-left: 4px solid #FF6B35;
	border-radius: 4px;
	color: #666;
	margin: 1rem 0;
}

/* Detail View Specific Styles */
.election-stats-detail .election-stats-table-detailed {
	font-size: 0.9375rem;
	width: 100%;
}

.election-stats-detail .election-stats-table-detailed thead {
	position: sticky;
	top: 0;
	z-index: 10;
	background: #f8f9fa;
}

.election-stats-detail .election-stats-table-detailed thead th {
	background: #f8f9fa;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.election-stats-detail .election-stats-table-detailed tbody tr:nth-child(even) {
	background: #fafbfc;
}

.election-stats-detail .election-stats-table-detailed td {
	padding: 0.75rem 1rem;
	vertical-align: middle;
}

.election-stats-detail .election-stats-table-detailed th {
	padding: 0.875rem 1rem;
	vertical-align: middle;
}

.election-stats-detail .election-stats-table-detailed td:nth-child(2) {
	text-align: right;
}

.election-stats-detail .election-stats-table-detailed .election-stats-total-row {
	position: sticky;
	bottom: 0;
	z-index: 10;
	background: #f8f9fa !important;
	box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
}

.election-stats-detail .election-stats-table-detailed .election-stats-total-row td {
	background: #f8f9fa !important;
	border-top: 3px solid #dee2e6;
}

/* Responsive Design */
@media (max-width: 1374px) {
	.election-stats-grid {
		grid-template-columns: 1fr;
		gap: 2rem;
	}
	
	.election-stats-chart-wrapper {
		max-width: 100%;
		overflow: hidden;
	}
	
	.election-stats-pie-chart {
		max-width: 100%;
		height: auto;
	}
}

@media (max-width: 1374px) {
	.election-stats-header {
		padding: 1.25rem 1.5rem;
	}
	
	.election-stats-title {
		font-size: 1.25rem;
	}
	
	.election-stats-view {
		padding: 1.5rem;
	}
	
	.election-stats-table {
		font-size: 0.875rem;
	}
	
	.election-stats-table th,
	.election-stats-table td {
		padding: 0.75rem 0.875rem;
	}
	
	.election-stats-toggle-btn {
		width: 100%;
		justify-content: center;
	}
	
	.election-stats-pie-chart {
		max-width: 300px;
		max-height: 300px;
	}
	
	.election-stats-legend-items {
		gap: 0.75rem;
	}
	
	.election-stats-legend-item {
		font-size: 0.8125rem;
		padding: 0.25rem 0.375rem;
	}
	
	.election-stats-legend-label {
		font-size: 0.8125rem;
	}
}

@media (max-width: 480px) {
	.election-stats-header {
		padding: 1rem;
	}
	
	.election-stats-title {
		font-size: 1.125rem;
		width: 100%;
	}
	
	.election-stats-view {
		padding: 1rem;
	}
	
	.election-stats-table {
		font-size: 0.8125rem;
	}
	
	.election-stats-table th,
	.election-stats-table td {
		padding: 0.625rem 0.75rem;
	}
	
	.election-stats-pie-chart {
		max-width: 250px;
		max-height: 250px;
	}
	
	.election-stats-legend-color {
		width: 14px;
		height: 14px;
	}
	
	.election-stats-legend-label {
		font-size: 0.75rem;
	}
	
	.election-stats-legend-item {
		font-size: 0.75rem;
		gap: 0.375rem;
		padding: 0.25rem 0.375rem;
	}
}

/* Print Styles */
@media print {
	.election-stats-container {
		box-shadow: none;
		border: 1px solid #ddd;
	}
	
	.election-stats-header {
		background: #f8f9fa;
		color: #333;
	}
	
	.election-stats-toggle-btn {
		display: none;
	}
	
	.election-stats-view {
		display: block !important;
	}
	
	.election-stats-chart-wrapper {
		display: none;
	}
}

/* Accessibility Improvements */
.election-stats-table th {
	position: relative;
}

.election-stats-toggle-btn:focus {
	outline: 3px solid rgba(255, 255, 255, 0.5);
	outline-offset: 2px;
}

.election-stats-table tbody tr:focus-within {
	background: #e3f2fd;
	outline: 2px solid #2196F3;
	outline-offset: -2px;
}

/* Animation for view switching */
.election-stats-view {
	animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

