/**
 * Muni Graphs Frontend Styles
 *
 * @package MuniGraphs
 */

/* Graph Container */
.muni-graph-container {
	position: relative;
	width: 100%;
	max-width: 100%;
	margin: 20px 0;
	padding: 15px;
	background: #fff;
	border: 1px solid #e1e1e1;
	border-radius: 4px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Canvas Styling */
.muni-graph-canvas {
	max-width: 100%;
	height: 400px !important;
	display: block;
}

/* Grouped Bar Chart Container */
.muni-grouped-bar-chart-container {
	position: relative;
	width: 100% !important;
	max-width: 100%;
	overflow: hidden;
}

.muni-grouped-bar-chart-container canvas {
	max-width: 100%;
	width: 100% !important;
	height: auto !important;
	display: block;
}

/* Responsive Design */
@media (max-width: 1200px) {
	/* Stack the bar charts into single column */
	.muni-combined-inspection-charts {
		grid-template-columns: 1fr !important;
	}

	/* Stack the donut charts into single column */
	.muni-combined-donut-charts {
		grid-template-columns: 1fr !important;
	}

	/* Summary boxes: 2 rows of 5 columns */
	.muni-inspection-summary {
		grid-template-columns: repeat(5, 1fr) !important;
	}
}

@media (max-width: 768px) {
	.muni-graph-container {
		margin: 15px 0;
		padding: 10px;
	}

	.muni-graph-canvas {
		height: 300px !important;
	}

	/* Summary boxes: stack into fewer columns on smaller screens */
	.muni-inspection-summary {
		grid-template-columns: repeat(2, 1fr) !important;
	}
}

@media (max-width: 480px) {
	.muni-graph-container {
		margin: 10px 0;
		padding: 8px;
	}

	.muni-graph-canvas {
		height: 250px !important;
	}
}

/* Error Messages */
.muni-graph-error {
	padding: 15px;
	background: #f8d7da;
	color: #721c24;
	border: 1px solid #f5c6cb;
	border-radius: 4px;
	margin: 20px 0;
	font-size: 14px;
}

/* Loading State */
.muni-graph-loading {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 200px;
	background: #f8f9fa;
	border: 1px solid #e1e1e1;
	border-radius: 4px;
	margin: 20px 0;
}

.muni-graph-loading::after {
	content: "Loading chart...";
	color: #6c757d;
	font-size: 16px;
}

/* API Loading and Error States */
.muni-graph-container.loading {
	opacity: 0.7;
	pointer-events: none;
}

.loading-indicator {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: rgba(255, 255, 255, 0.95);
	border: 1px solid #ddd;
	border-radius: 4px;
	padding: 15px 20px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	z-index: 1000;
	display: none;
}

.loading-indicator span {
	display: inline-block;
	color: #666;
	font-size: 14px;
	font-weight: 500;
}

.loading-indicator span::after {
	content: '';
	display: inline-block;
	width: 12px;
	height: 12px;
	border: 2px solid #ddd;
	border-radius: 50%;
	border-top-color: #007cba;
	animation: loading-spin 1s ease-in-out infinite;
	margin-left: 8px;
}

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

.error-indicator {
	position: absolute;
	top: 10px;
	right: 10px;
	background: #dc3545;
	color: white;
	border-radius: 4px;
	padding: 8px 12px;
	font-size: 12px;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	z-index: 1001;
	display: none;
	max-width: 300px;
}

.error-indicator .error-message {
	display: block;
}

/* Filter Loading States */
.filter-loading {
	opacity: 0.6;
	pointer-events: none;
}

.filter-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	right: 10px;
	transform: translateY(-50%);
	width: 16px;
	height: 16px;
	border: 2px solid #ddd;
	border-radius: 50%;
	border-top-color: #007cba;
	animation: loading-spin 1s linear infinite;
}

/* DataTables Custom Styling */
.datatable-controls {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	margin-bottom: 15px;
	gap: 10px;
}

/* DataTables buttons styling */
.dt-buttons {
	display: flex;
	gap: 8px;
	flex-wrap: wrap;
}

.dt-button {
	background: #007cba;
	color: #fff;
	border: none;
	padding: 8px 16px;
	border-radius: 4px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: background 0.2s ease;
	text-decoration: none;
	display: inline-block;
}

.dt-button:hover {
	background: #005a87;
	color: #fff;
}

.dt-button-copy {
	background: #6c757d;
}

.dt-button-copy:hover {
	background: #545b62;
}

.dt-button-csv {
	background: #28a745;
}

.dt-button-csv:hover {
	background: #218838;
}

.dt-button-excel {
	background: #217346;
}

.dt-button-excel:hover {
	background: #1a5c37;
}

.dt-button-pdf {
	background: #dc3545;
}

.dt-button-pdf:hover {
	background: #c82333;
}

.dt-button-print {
	background: #6610f2;
}

.dt-button-print:hover {
	background: #560bd0;
}

/* Length menu (Show entries dropdown) */
.dataTables_length {
	display: flex;
	align-items: center;
	gap: 8px;
}

.dataTables_length label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 500;
	color: #495057;
}

.dataTables_length select {
	padding: 6px 10px;
	border: 1px solid #ced4da;
	border-radius: 4px;
	font-size: 14px;
	background: #fff;
	cursor: pointer;
}

/* Filter/search box */
.dataTables_filter {
	display: flex;
	align-items: center;
	gap: 8px;
}

.dataTables_filter label {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 500;
	color: #495057;
}

.dataTables_filter input {
	padding: 6px 10px;
	border: 1px solid #ced4da;
	border-radius: 4px;
	font-size: 14px;
	min-width: 200px;
}

.dataTables_filter input:focus {
	outline: none;
	border-color: #007cba;
	box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Table info and pagination wrapper */
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
	margin-top: 15px;
	font-size: 14px;
	color: #495057;
}

/* Pagination styling */
.dataTables_paginate {
	display: flex;
	gap: 5px;
	align-items: center;
}

.dataTables_paginate .paginate_button {
	padding: 6px 12px;
	margin: 0 2px;
	border: 1px solid #dee2e6;
	background: #fff;
	color: #007cba;
	border-radius: 4px;
	cursor: pointer;
	text-decoration: none;
	display: inline-block;
	transition: all 0.2s ease;
}

.dataTables_paginate .paginate_button:hover {
	background: #e9ecef;
	border-color: #adb5bd;
	color: #005a87;
}

.dataTables_paginate .paginate_button.current {
	background: #007cba;
	color: #fff;
	border-color: #007cba;
	font-weight: bold;
}

.dataTables_paginate .paginate_button.disabled {
	opacity: 0.5;
	cursor: not-allowed;
	pointer-events: none;
}

/* Responsive table wrapper */
.dataTables_wrapper .dataTables_scroll {
	overflow-x: auto;
}

/* Table styling improvements */
table.dataTable {
	border-collapse: collapse;
	width: 100%;
	margin: 0;
}

table.dataTable thead th {
	background: #f8f9fa;
	font-weight: 600;
	padding: 12px 8px;
	border-bottom: 2px solid #dee2e6;
	cursor: pointer;
	user-select: none;
}

table.dataTable tbody td {
	padding: 10px 8px;
	border-bottom: 1px solid #dee2e6;
}

table.dataTable tbody tr:hover {
	background-color: #f8f9fa;
}

/* Sorting indicators */
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc {
	position: relative;
	padding-right: 24px;
}

table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:after {
	position: absolute;
	right: 8px;
	top: 50%;
	transform: translateY(-50%);
	opacity: 0.3;
	font-size: 12px;
}

table.dataTable thead .sorting:after {
	content: "⇅";
}

table.dataTable thead .sorting_asc:after {
	content: "↑";
	opacity: 1;
}

table.dataTable thead .sorting_desc:after {
	content: "↓";
	opacity: 1;
}

/* Mobile responsive */
@media (max-width: 768px) {
	.datatable-controls {
		flex-direction: column;
		align-items: stretch;
	}

	.dt-buttons {
		order: 3;
		margin-top: 10px;
	}

	.dataTables_length {
		order: 1;
	}

	.dataTables_filter {
		order: 2;
	}

	.dataTables_filter input {
		min-width: 100%;
	}

	.dt-button {
		flex: 1;
		text-align: center;
	}
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
	/* .muni-graph-container {
		background: #2c3e50;
		border-color: #34495e;
		color: #ecf0f1;
	} */

	.muni-graph-error {
		background: #e74c3c;
		color: #ecf0f1;
		border-color: #c0392b;
	}

	.muni-graph-loading {
		background: #34495e;
		border-color: #2c3e50;
		color: #bdc3c7;
	}
}

/* Clickable Chart Overlay for Elementor Tab Navigation */
.muni-chart-clickable {
	position: relative;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.muni-chart-clickable:hover {
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.muni-chart-clickable::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 10;
	background: transparent;
}

/* ===== AB 939 Charts ===== */

.ab939-filter-container {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 12px 16px;
	background: #f8f9fa;
	border: 1px solid #dee2e6;
	border-radius: 6px;
	margin-bottom: 20px;
}

.ab939-filter-container label {
	font-weight: 600;
	font-size: 14px;
	color: #333;
	white-space: nowrap;
}

.ab939-year-range-select {
	padding: 6px 12px;
	border: 1px solid #ced4da;
	border-radius: 4px;
	font-size: 14px;
	background: #fff;
	cursor: pointer;
}

.ab939-chart-wrapper {
	margin-bottom: 30px;
}

.ab939-chart-title {
	text-align: center;
	margin: 0;
	padding: 10px 0 20px 0;
	font-size: 20px;
	font-weight: bold;
	color: #333;
}

.ab939-table-wrapper {
	margin-top: 30px;
}

.ab939-table-title {
	text-align: center;
	margin: 0 0 15px 0;
	font-size: 20px;
	font-weight: bold;
	color: #333;
}

.ab939-table-wrapper .dataTables_wrapper {
	overflow-x: auto;
}

.ab939-data-table th {
	font-size: 13px;
	white-space: nowrap;
}

.ab939-data-table td {
	font-size: 13px;
	text-align: right;
	white-space: nowrap;
}

.ab939-data-table td:first-child {
	text-align: center;
	font-weight: 600;
}

@media (max-width: 768px) {
	.ab939-filter-container {
		flex-direction: column;
		align-items: flex-start;
	}

	.ab939-year-range-select {
		width: 100%;
	}
}