/**
 * Hospital Waste Management - Waste Report Frontend Styles
 * Uses same filter pattern as Hospital List shortcode
 *
 * @package HospitalWasteManagement
 */

/* =========================================================
   CSS VARIABLES & RESET
   ========================================================= */

.hwm-report-wrapper,
.hwm-report-wrapper *,
.hwm-report-wrapper *::before,
.hwm-report-wrapper *::after {
	box-sizing: border-box;
}

.hwm-report-wrapper {
	--hwm-medical-50: #f0f7ff;
	--hwm-medical-100: #e0effe;
	--hwm-medical-500: #0070bb;
	--hwm-medical-600: #005fa3;
	--hwm-medical-700: #004e89;
	--hwm-white: #ffffff;
	--hwm-gray-200: #e5e7eb;
	--hwm-gray-300: #d1d5db;
	--hwm-gray-400: #9ca3af;
	--hwm-gray-500: #6b7280;
	--hwm-gray-600: #4b5563;

	width: 100%;
	margin: 0 auto;
	padding: 0 1rem 2rem;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
	color: var(--hwm-gray-600);
	line-height: 1.5;
}

/* =========================================================
   FILTER SECTION (Same as Hospital List)
   ========================================================= */

.hwm-filters {
	background-color: var(--hwm-medical-50);
	border-radius: 1rem;
	padding: 1.5rem;
	margin-bottom: 1.5rem;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.hwm-filter-form {
	margin: 0;
}

.hwm-filter-header {
	display: flex;
	flex-direction: column;
	gap: 1rem;
	margin-bottom: 1rem;
}

@media (min-width: 768px) {
	.hwm-filter-header {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
	}
}

.hwm-filter-title {
	margin: 0;
	color: var(--hwm-medical-700);
	font-size: 1.125rem;
	font-weight: 600;
}

.hwm-filter-controls {
	display: grid;
	grid-template-columns: 1fr;
	gap: 0.75rem;
	flex-grow: 1;
}

@media (min-width: 640px) {
	.hwm-filter-controls {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (min-width: 1024px) {
	.hwm-filter-controls {
		grid-template-columns: repeat(3, 1fr);
	}
}

.hwm-filter-field {
	position: relative;
}

.hwm-search-input {
	width: 100%;
	height: 2.5rem;
	padding: 0.625rem 1rem;
	border: 1px solid var(--hwm-gray-300);
	border-radius: 9999px;
	background-color: var(--hwm-white);
	color: var(--hwm-gray-600);
	font-size: 0.875rem;
	font-weight: 400;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hwm-search-input:focus {
	border-color: var(--hwm-medical-500);
	box-shadow: 0 0 0 3px rgba(0, 112, 187, 0.1);
}

/* Date input specific styling */
input[type="date"].hwm-search-input {
	height: 2.5rem;
	padding: 0.625rem 1rem;
	border: 1px solid var(--hwm-gray-300);
	border-radius: 9999px;
	background-color: var(--hwm-white);
	color: var(--hwm-gray-600);
	font-size: 0.875rem;
	font-weight: 400;
	outline: none;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="date"].hwm-search-input:focus {
	border-color: var(--hwm-medical-500);
	box-shadow: 0 0 0 3px rgba(0, 112, 187, 0.1);
}

/* =========================================================
   CUSTOM SEARCHABLE SELECT (cs2) - Zero Dependency
   ========================================================= */

.cs2-native {
	position: absolute;
	opacity: 0;
	pointer-events: none;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.cs2-wrap {
	position: relative;
	width: 100%;
	font-size: 14px;
}

.cs2-trigger {
	display: flex;
	align-items: center;
	gap: 6px;
	padding: 0.5rem 1rem;
	height: 2.5rem;
	background: var(--hwm-white);
	border: 1px solid var(--hwm-gray-300);
	border-radius: 9999px;
	cursor: pointer;
	user-select: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
	box-sizing: border-box;
}

.cs2-trigger:hover {
	border-color: var(--hwm-gray-400);
}

.cs2-trigger:focus {
	outline: none;
	border-color: var(--hwm-medical-500);
	box-shadow: 0 0 0 3px rgba(0, 112, 187, 0.1);
}

.cs2-trigger.open {
	border-color: var(--hwm-medical-500);
	box-shadow: 0 0 0 3px rgba(0, 112, 187, 0.1);
}

.cs2-value {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: var(--hwm-gray-600);
	font-size: 0.875rem;
}

.cs2-value.placeholder {
	color: var(--hwm-gray-400);
}

.cs2-clear {
	display: none;
	background: none;
	border: none;
	cursor: pointer;
	color: var(--hwm-gray-400);
	font-size: 14px;
	line-height: 1;
	padding: 0 2px;
	flex-shrink: 0;
}

.cs2-clear:hover {
	color: var(--hwm-gray-600);
}

.cs2-wrap.has-value .cs2-clear {
	display: inline-flex;
}

.cs2-arrow {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	color: var(--hwm-gray-400);
	transition: transform 0.2s;
}

.cs2-trigger.open .cs2-arrow {
	transform: rotate(180deg);
}

.cs2-dropdown {
	display: none;
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	background: var(--hwm-white);
	border: 1px solid var(--hwm-gray-300);
	border-radius: 0.5rem;
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
	z-index: 1000;
	max-height: 200px;
	overflow-y: auto;
}

.cs2-dropdown.open {
	display: block;
}

.cs2-search-wrap {
	padding: 0.5rem;
	border-bottom: 1px solid var(--hwm-gray-200);
}

.cs2-search {
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid var(--hwm-gray-300);
	border-radius: 0.375rem;
	font-size: 0.875rem;
	outline: none;
}

.cs2-search:focus {
	border-color: var(--hwm-medical-500);
}

.cs2-list {
	padding: 0.25rem;
}

.cs2-option {
	padding: 0.5rem 0.75rem;
	cursor: pointer;
	border-radius: 0.25rem;
	color: var(--hwm-gray-600);
	font-size: 0.875rem;
	transition: background-color 0.15s ease;
}

.cs2-option:hover {
	background-color: var(--hwm-medical-50);
}

.cs2-option.selected {
	background-color: var(--hwm-medical-100);
	color: var(--hwm-medical-700);
	font-weight: 500;
}

/* =========================================================
   FILTER ACTIONS
   ========================================================= */

.hwm-filter-actions {
	display: flex;
	gap: 0.75rem;
	justify-content: flex-start;
}

@media (min-width: 768px) {
	.hwm-filter-actions {
		justify-content: flex-end;
	}
}

.hwm-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.625rem 1.25rem;
	border-radius: 0.5rem;
	font-size: 0.875rem;
	font-weight: 500;
	text-decoration: none;
	cursor: pointer;
	transition: all 0.2s ease;
	border: 1px solid transparent;
}

.hwm-button-primary {
	background-color: var(--hwm-medical-600);
	color: var(--hwm-white);
}

.hwm-button-primary:hover {
	background-color: var(--hwm-medical-700);
}

.hwm-button-outline {
	background-color: var(--hwm-white);
	color: var(--hwm-medical-600);
	border-color: var(--hwm-medical-600);
}

.hwm-button-outline:hover {
	background-color: var(--hwm-medical-50);
}

.hwm-button-disabled {
	background-color: var(--hwm-gray-300);
	color: var(--hwm-gray-500);
	cursor: not-allowed;
}

.hwm-button-sm {
	padding: 0.375rem 0.875rem;
	font-size: 0.8125rem;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 640px) {
	.hwm-filter-controls {
		grid-template-columns: 1fr;
	}

	.hwm-filter-actions {
		flex-direction: column;
		width: 100%;
	}

	.hwm-button {
		width: 100%;
	}
}

/* =========================================================
   HOSPITAL NAME
   ========================================================= */

.hwm-report-hospital-name {
	margin: 0 0 1.5rem 0;
	color: var(--hwm-medical-600);
	font-size: 2rem;
	font-weight: 700;
	line-height: 1.2;
}

/* =========================================================
   TABLE STYLES
   ========================================================= */

.hwm-report-table-wrapper {
	background-color: var(--hwm-white);
	border: 1px solid var(--hwm-gray-300);
	border-radius: 0.75rem;
	overflow: hidden;
	margin-bottom: 1.5rem;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.hwm-table-header {
	padding: 1rem;
	border-bottom: 1px solid var(--hwm-gray-300);
	display: flex;
	justify-content: space-between;
	align-items: center;
	background-color: var(--hwm-medical-50);
}

.hwm-table-header-left {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.hwm-table-header-left span {
	color: var(--hwm-gray-500);
	font-size: 0.875rem;
}

.hwm-table-header-select {
	padding: 0.375rem 0.5rem;
	border: 1px solid var(--hwm-gray-300);
	border-radius: 0.25rem;
	background-color: var(--hwm-white);
	color: var(--hwm-gray-600);
	font-size: 0.875rem;
	outline: none;
}

.hwm-table-header-select:focus {
	border-color: var(--hwm-medical-500);
}

.hwm-table-header-right {
	position: relative;
}

.hwm-table-search-icon {
	position: absolute;
	left: 0.75rem;
	top: 50%;
	transform: translateY(-50%);
	color: var(--hwm-gray-500);
	width: 1rem;
	height: 1rem;
}

.hwm-table-search-input {
	padding: 0.375rem 1rem 0.375rem 2.25rem;
	border: 1px solid var(--hwm-gray-300);
	border-radius: 9999px;
	font-size: 0.875rem;
	width: 16rem;
	outline: none;
}

.hwm-table-search-input:focus {
	border-color: var(--hwm-medical-500);
	box-shadow: 0 0 0 3px rgba(0, 112, 187, 0.1);
}

.hwm-table-scroll {
	overflow-x: auto;
}

.hwm-table-scroll::-webkit-scrollbar {
	width: 6px;
	height: 6px;
}

.hwm-table-scroll::-webkit-scrollbar-track {
	background: #f1f5f9;
}

.hwm-table-scroll::-webkit-scrollbar-thumb {
	background: #cbd5e1;
	border-radius: 10px;
}

.hwm-report-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	min-width: 1200px;
	font-size: 0.875rem;
}

.hwm-report-table thead {
	background-color: var(--hwm-medical-600);
}

.hwm-report-table th {
	padding: 1rem !important;
	text-align: left !important;
	color: #ffffff !important;
	font-weight: 600 !important;
	font-size: 0.75rem !important;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	border-right: 1px solid rgba(255, 255, 255, 0.2);
	white-space: nowrap;
	position: sticky;
	top: 0;
	z-index: 10;
}

.hwm-report-table th:last-child {
	border-right: none;
}

.hwm-th-primary {
	background-color: var(--hwm-medical-600);
}

.hwm-th-yellow {
	background-color: #ca8a04;
}

.hwm-th-red {
	background-color: #dc2626;
}

.hwm-th-blue {
	background-color: #2563eb;
}

.hwm-th-white {
	background-color: #334155;
}

.hwm-report-table tbody tr:nth-child(odd) {
	background-color: var(--hwm-white);
}

.hwm-report-table tbody tr:nth-child(even) {
	background-color: rgba(0, 112, 187, 0.05);
}

.hwm-report-table tbody tr:hover {
	background-color: var(--hwm-medical-50);
	transition: background-color 0.15s ease;
}

.hwm-report-table td {
	padding: 1rem;
	color: var(--hwm-gray-600);
	border-bottom: 1px solid var(--hwm-gray-200);
	white-space: nowrap;
}

.hwm-report-table td:last-child {
	border-bottom: none;
}

.hwm-td-mono {
	font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.hwm-td-bold {
	font-weight: 700;
}

.hwm-td-primary {
	color: var(--hwm-medical-600);
}

.hwm-td-center {
	text-align: center;
}

.hwm-td-yellow-bg {
	background-color: #fef9c3;
}

.hwm-td-red-bg {
	background-color: #fee2e2;
}

.hwm-td-blue-bg {
	background-color: #dbeafe;
}

.hwm-td-white-bg {
	background-color: #f1f5f9;
}

/* =========================================================
   PAGINATION STYLES
   ========================================================= */

.hwm-pagination-wrapper {
	background-color: var(--hwm-medical-50);
	border: 1px solid var(--hwm-gray-300);
	border-top: none;
	border-radius: 0 0 0.75rem 0.75rem;
	padding: 1rem;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 1rem;
}

.hwm-pagination-left {
	flex-shrink: 0;
}

.hwm-pagination-info {
	margin: 0;
	color: var(--hwm-gray-500);
	font-size: 0.875rem;
}

.hwm-pagination-right {
	display: flex;
	align-items: center;
	gap: 0.25rem;
}

.hwm-page-btn {
	padding: 0.375rem 0.75rem;
	border: 1px solid var(--hwm-gray-300);
	border-radius: 0.25rem;
	background-color: var(--hwm-white);
	color: var(--hwm-gray-600);
	font-size: 0.875rem;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease;
}

.hwm-page-btn:hover:not(:disabled) {
	background-color: var(--hwm-medical-50);
	border-color: var(--hwm-gray-400);
}

.hwm-page-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.hwm-page-current {
	background-color: var(--hwm-medical-600);
	color: var(--hwm-white);
	border-color: var(--hwm-medical-600);
}

.hwm-page-current:hover {
	background-color: var(--hwm-medical-600);
	border-color: var(--hwm-medical-600);
}

.hwm-page-ellipsis {
	padding: 0 0.5rem;
	color: var(--hwm-gray-500);
}

/* =========================================================
   NO RESULTS
   ========================================================= */

.hwm-no-results {
	background-color: var(--hwm-white);
	border: 1px solid var(--hwm-gray-300);
	border-radius: 0.75rem;
	padding: 2rem;
	text-align: center;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.hwm-no-results p {
	margin: 0;
	color: var(--hwm-gray-500);
	font-size: 0.875rem;
}

/* =========================================================
   TABLE RESPONSIVE
   ========================================================= */

@media (max-width: 768px) {
	.hwm-pagination-wrapper {
		flex-direction: column;
		gap: 1rem;
		align-items: center;
	}

	.hwm-pagination-left,
	.hwm-pagination-right {
		width: 100%;
		justify-content: center;
	}

	.hwm-per-page-form {
		justify-content: center;
	}
}

/* =========================================================
   STICKY COLUMNS FOR FRONTEND TABLE
   ========================================================= */

.hwm-report-wrapper .hwm-report-table {
	position: relative;
}

/* Sticky column 1 - SNo */
.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-1 {
	position: sticky;
	left: 0;
	min-width: 60px;
	z-index: 5;
	background: inherit;
}

.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-1 {
	z-index: 15;
}

/* Sticky column 2 - Date */
.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-2 {
	position: sticky;
	left: 60px;
	min-width: 100px;
	z-index: 5;
	background: inherit;
}

.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-2 {
	z-index: 15;
}

/* Sticky column 3 - Time */
.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-3 {
	position: sticky;
	left: 160px;
	min-width: 80px;
	z-index: 5;
	background: inherit;
}

.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-3 {
	z-index: 15;
}

/* Sticky column 4 - Total Bags */
.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-4 {
	position: sticky;
	left: 240px;
	min-width: 90px;
	z-index: 5;
	background: inherit;
}

.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-4 {
	z-index: 15;
}

/* Sticky column 5 - Total Weight */
.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-5 {
	position: sticky;
	left: 330px;
	min-width: 120px;
	z-index: 5;
	background: inherit;
}

.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-5 {
	z-index: 15;
}

/* Ensure background color is set for body cells when scrolling */
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-1,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-2,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-3,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-4,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-5 {
	background-color: var(--hwm-white);
}

.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-1,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-2,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-3,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-4,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-5 {
	background-color: rgba(0, 112, 187, 0.05);
}

.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-1,
.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-2,
.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-3,
.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-4,
.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-5 {
	background-color: var(--hwm-medical-50);
}

/* Fix sticky header background only - do not touch body td */
.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-1,
.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-2,
.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-3,
.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-4,
.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-5 {
	background-color: var(--hwm-medical-600);
	z-index: 50;
}

/* Fix alternate row sticky columns showing colors from behind */
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-1,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-2,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-3,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-4,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-5 {
	background-color: #f2f8fc;
	z-index: 20;
}

/* Keep odd row sticky columns solid */
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-1,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-2,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-3,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-4,
.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-5 {
	background-color: #ffffff;
	z-index: 20;
}

/* Mobile: keep only first 2 columns sticky */
@media (max-width: 768px) {

	/* Keep column 1 sticky */
	.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-1 {
		position: sticky !important;
		left: 0 !important;
		min-width: 60px !important;
		width: 60px !important;
		z-index: 20 !important;
	}

	/* Keep column 2 sticky */
	.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-2 {
		position: sticky !important;
		left: 60px !important;
		min-width: 100px !important;
		width: 100px !important;
		z-index: 20 !important;
	}

	/* Header first 2 columns should stay above body */
	.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-1,
	.hwm-report-wrapper .hwm-report-table thead .hwm-sticky-col-2 {
		z-index: 50 !important;
		background-color: var(--hwm-medical-600);
	}

	/* Disable sticky from column 3 to 5 on mobile */
	.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-3,
	.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-4,
	.hwm-report-wrapper .hwm-report-table .hwm-sticky-col-5 {
		position: static !important;
		left: auto !important;
		z-index: auto !important;
		min-width: auto !important;
		width: auto !important;
	}

	/* Solid background for mobile sticky body columns */
	.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-1,
	.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(odd) .hwm-sticky-col-2 {
		background-color: #ffffff;
	}

	.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-1,
	.hwm-report-wrapper .hwm-report-table tbody tr:nth-child(even) .hwm-sticky-col-2 {
		background-color: #f2f8fc;
	}

	.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-1,
	.hwm-report-wrapper .hwm-report-table tbody tr:hover .hwm-sticky-col-2 {
		background-color: var(--hwm-medical-50);
	}

	/* Normal horizontal scroll */
	.hwm-table-scroll {
		overflow-x: auto;
	}

	.hwm-report-table {
		min-width: 1200px;
	}
}
