/**
 * JG DataTables Options - Filter Bar Styles
 * Mobile-friendly responsive styles for filter UI
 */

/* Filter bar container */
.jgdo_filterbar {
	padding: 0 0.75em;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
}

/* Collapsible header - whole bar is clickable to expand/collapse */
.jgdo_filterbar_header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	cursor: pointer;
}

.jgdo_filterbar_title {
	font-weight: 600;
	font-size: 0.95em;
	color: #23282d;
}

.jgdo_filterbar_toggle {
	background: transparent;
	border: none;
	cursor: pointer;
	padding: 4px;
	color: #555;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

.jgdo_filterbar_toggle:hover {
	color: #2271b1;
}

.jgdo_filterbar_toggle:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.jgdo_filterbar_toggle .dashicons {
	font-size: 20px;
	width: 20px;
	height: 20px;
}

/* Collapsible content wrapper */
.jgdo_filterbar_content {
	/* For slideToggle animation */
}

/* Chips container for active filters */
.jgdo_filterbar_chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	margin-bottom: 0.75em;
	padding-bottom: 0.75em;
	border-bottom: 1px solid #ddd;
}

.jgdo_filterbar_chips:empty {
	display: none;
}

/* Filter chip */
.jgdo_filterbar_chip {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.3em 0.6em;
	background: #2271b1;
	color: #fff;
	border-radius: 3px;
	font-size: 0.85em;
	line-height: 1.4;
}

.jgdo_filterbar_chip_clear_all {
	cursor: pointer;
	border: none;
}

.jgdo_filterbar_chip_clear_all:hover {
	background: #135e96;
}

/* Chip remove button */
.jgdo_filterbar_chip_remove {
	background: transparent;
	border: none;
	color: #fff;
	cursor: pointer;
	font-size: 1.1em;
	line-height: 1;
	padding: 0;
	margin-left: 0.25em;
	width: 1.1em;
	height: 1.1em;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: background-color 0.2s;
}

.jgdo_filterbar_chip_remove:hover {
	background: rgba( 255, 255, 255, 0.2 );
}

.jgdo_filterbar_chip_remove:focus {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Filters container - horizontal by default on desktop */
.jgdo_filterbar_filters {
	display: flex;
	flex-wrap: nowrap;
	gap: 1em;
	overflow-x: auto;
	padding-bottom: 0.25em; /* Space for scrollbar */
}

/* Individual filter */
.jgdo_filterbar_filter {
	flex: 0 0 auto;
	min-width: 150px;
	max-width: 220px;
}

/* Filter label */
.jgdo_filterbar_label {
	display: block;
	margin-bottom: 0.4em;
	font-weight: 600;
	font-size: 0.9em;
	color: #23282d;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Facet filter - checkboxes container */
.jgdo_filterbar_checkboxes {
	display: flex;
	flex-direction: column;
	gap: 0.4em;
	max-height: 150px;
	overflow-y: auto;
	padding: 0.4em;
	background: #fff;
	border: 1px solid #ccc;
	border-radius: 3px;
}

/* Checkbox wrapper */
.jgdo_filterbar_checkbox_wrapper {
	display: flex;
	align-items: center;
	gap: 0.4em;
}

/* Checkbox input */
.jgdo_filterbar_checkbox {
	margin: 0;
	flex-shrink: 0;
}

/* Checkbox label */
.jgdo_filterbar_checkbox_label {
	margin: 0;
	font-weight: normal;
	font-size: 0.9em;
	cursor: pointer;
	user-select: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* Range filter inputs container */
.jgdo_filterbar_range_inputs {
	display: flex;
	gap: 0.5em;
	align-items: flex-end;
}

/* Range input wrapper */
.jgdo_filterbar_range_input_wrapper {
	display: flex;
	flex-direction: column;
	gap: 0.2em;
	flex: 1 1 auto;
}

.jgdo_filterbar_range_input_wrapper label {
	font-size: 0.8em;
	font-weight: 500;
	color: #555;
}

/* Range input */
.jgdo_filterbar_range_input {
	width: 100%;
	padding: 0.4em;
	border: 1px solid #8c8f94;
	border-radius: 3px;
	font-size: 0.9em;
}

.jgdo_filterbar_range_input:focus {
	border-color: #2271b1;
	outline: none;
	box-shadow: 0 0 0 1px #2271b1;
}

/* Range suffix */
.jgdo_filterbar_range_suffix {
	margin-left: 0.25em;
	font-size: 0.85em;
	color: #555;
}

/* Mobile responsive styles */
@media screen and ( max-width: 782px ) {
	.jgdo_filterbar {
		padding: 0.6em;
	}

	.jgdo_filterbar_filters {
		flex-direction: column;
		flex-wrap: wrap;
		gap: 0.75em;
		overflow-x: visible;
	}

	.jgdo_filterbar_filter {
		min-width: 100%;
		max-width: 100%;
		width: 100%;
	}

	/* Single column layout for checkboxes on mobile */
	.jgdo_filterbar_checkboxes {
		max-height: 120px;
	}

	.jgdo_filterbar_range_inputs {
		flex-direction: row;
		gap: 0.5em;
	}

	.jgdo_filterbar_range_input_wrapper {
		width: auto;
	}
}

/* Accessibility improvements */
.jgdo_filterbar_checkbox:focus,
.jgdo_filterbar_range_input:focus {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* ===== Left sidebar mode ===== */

/* Target wrapper becomes a flex row with two columns */
.jgdo_filterbar_target--left {
	display: flex;
	gap: 1em;
	align-items: flex-start;
}

/* Col 1 – sidebar: width is set inline by JS from the saved option */
.jgdo_filterbar_target--left > .jgdo_filterbar {
	flex-shrink: 0;
	/* width / flex-basis applied via JS */
}

/* Col 2 – table area: re-open button, chips, and scrollable table stack vertically */
.jgdo_filterbar_target--left > .jgct_datatable_wrapper {
	flex: 1 1 0;
	min-width: 0; /* prevent table overflowing flex parent */
	display: flex;
	flex-direction: column;
}

/* In sidebar, filters stack vertically instead of scrolling horizontally */
.jgdo_filterbar_target--left .jgdo_filterbar_filters {
	flex-direction: column;
	flex-wrap: nowrap;
	overflow-x: visible;
	gap: 0.75em;
}

/* Each filter takes full sidebar width */
.jgdo_filterbar_target--left .jgdo_filterbar_filter {
	min-width: 0;
	max-width: none;
	width: 100%;
}

/* Taller checkbox list in sidebar */
.jgdo_filterbar_target--left .jgdo_filterbar_checkboxes {
	max-height: 220px;
}

/* Chips above table (inside the right column, above the scrollable area) */
.jgdo_filterbar_chips_above {
	margin-bottom: 0.5em;
}

/* Re-open button shown when sidebar is hidden */
.jgdo_filterbar_sidebar_reopen {
	display: inline-flex;
	align-items: center;
	gap: 0.3em;
	margin-bottom: 0.5em;
	padding: 0.35em 0.75em;
	background: #f9f9f9;
	border: 1px solid #ddd;
	border-radius: 4px;
	cursor: pointer;
	font-size: 0.9em;
	color: #23282d;
	line-height: 1.4;
}

.jgdo_filterbar_sidebar_reopen:hover {
	background: #f0f0f0;
	border-color: #aaa;
}

.jgdo_filterbar_sidebar_reopen .dashicons {
	font-size: 16px;
	width: 16px;
	height: 16px;
}

/*
 * DataTables scrollX header alignment fix for left sidebar mode.
 *
 * With scrollX:true, DataTables sets an explicit pixel width on the
 * dt-scroll-headInner div (based on the table width at init time).
 * When the sidebar narrows the available space, the body table shrinks
 * but the header inner div retains its old pixel width — causing column
 * misalignment.  Forcing width:100% here makes the header inner always
 * track its container width, matching the body table which also has
 * width:100% (via the plugin's table.dataTable rule).
 *
 * This applies to both DataTables 2.x (.dt-scroll-headInner) and
 * the legacy 1.x class name (.dataTables_scrollHeadInner).
 */
.jgdo_filterbar_target--left .dt-scroll-headInner,
.jgdo_filterbar_target--left .dataTables_scrollHeadInner {
	width: 100% !important;
}

/* Mobile: revert to stacked layout, undo flex-column on datatable wrapper */
@media screen and ( max-width: 782px ) {
	.jgdo_filterbar_target--left {
		flex-direction: column;
	}

	.jgdo_filterbar_target--left > .jgdo_filterbar {
		width: 100% !important;
		flex-basis: auto !important;
	}

	.jgdo_filterbar_target--left > .jgct_datatable_wrapper {
		width: 100%;
		display: block;
	}
}

/* Print styles */
@media print {
	.jgdo_filterbar {
		display: none;
	}
}
