/**
 * Filter Popup Widget – layout and structure only.
 * Colors, typography, borders, etc. are controlled via Elementor.
 */

/* Bar: flex container, filter button left, active pills right */
.jcew-filter-popup__bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
}
@media (max-width: 768px) {
	.jcew-filter-popup__bar {
		flex-direction: column;
		align-items: flex-start;
		justify-content: flex-start;
		gap:24px;
	}
}

button.jcew-filter-popup__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.25rem;
	border: none;
	cursor: pointer;
	text-decoration: none;
	transition: opacity 0.2s ease;
}

button.jcew-filter-popup__btn:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.jcew-filter-popup__btn-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.jcew-filter-popup__btn-icon svg {
	width: 1em;
	height: 1em;
}

/* Active filters container: 50% width, wraps */
.jcew-filter-popup__active-wrap {
	flex: 1;
	min-width: 0;
}

@media (max-width: 768px) {
	.jcew-filter-popup__active-wrap {
		flex: 0 0 100%;
		width: 100% !important;
	}
}

.jcew-filter-popup__active-list {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: flex-end;
	list-style: none;
	margin: 0;
	padding: 0;
}

@media (max-width: 768px) {
	.jcew-filter-popup__active-list {
		justify-content: flex-start !important;
	}
}

.jcew-filter-popup__pill {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	border: 1px solid currentColor;
	border-radius: 9999px;
	padding: 0.25em 0.5em;
}

button.jcew-filter-popup__pill-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: none !important;
	background: transparent;
	cursor: pointer;
	transition: color 0.2s ease, background-color 0.2s ease;
}

button.jcew-filter-popup__pill-close svg {
	width: 1em;
	height: 1em;
	display: block;
}

button.jcew-filter-popup__pill-close svg path {
	transition: fill 0.2s ease;
}

button.jcew-filter-popup__pill-close:focus {
	outline: 2px solid currentColor;
	outline-offset: 1px;
}

/* Overlay: behind content when closed so the filter button stays clickable */
.jcew-filter-popup__overlay {
	position: fixed;
	inset: 0;
	z-index: -1;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

.jcew-filter-popup__overlay:not(.is-open) {
	z-index: -1 !important;
}

.jcew-filter-popup__overlay.is-open {
	/* z-index when open is set via Elementor Overlay Z-Index control */
	pointer-events: auto;
	opacity: 1;
	visibility: visible;
}

/* Popup dropdown: positioned below bar, full width of container; above overlay */
.jcew-filter-popup__dropdown {
	position: absolute;
	left: 0;
	top: 0;
	width: 100%;
	z-index: 1001;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
	pointer-events: none;
}

@media (max-width: 768px) {
	.jcew-filter-popup__dropdown {
		width: 100% !important;
	}
}

.jcew-filter-popup__dropdown.is-open {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.jcew-filter-popup__dropdown-inner {
	position: relative;
}

.jcew-filter-popup__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.jcew-filter-popup__title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 600;
}

button.jcew-filter-popup__close-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	align-self: flex-start;
	background: none;
	cursor: pointer;
	transition: opacity 0.2s ease;
}

button.jcew-filter-popup__close-btn:hover {
	background-color: transparent !important;
}

button.jcew-filter-popup__close-btn:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
	background-color: transparent !important;
}

/* Filter options: toggleable pills */
.jcew-filter-popup__options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}

.jcew-filter-popup__option {
	display: inline-flex;
	align-items: center;
	border: 1px solid currentColor;
	border-radius: 9999px;
	padding: 0.35em 0.75em;
	cursor: pointer;
	background: transparent;
	transition: opacity 0.2s ease;
}

.jcew-filter-popup__option:hover {
	opacity: 0.9;
}

.jcew-filter-popup__option:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.jcew-filter-popup__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
}

/* button selector so widget typography/controls override global button styles */
button.jcew-filter-popup__clear {
	background: none;
	border: none !important;
	cursor: pointer;
	text-decoration: underline;
	padding: 0;
	transition: all 0.3s;
}

button.jcew-filter-popup__clear:hover {
	opacity: 0.8;
	background-color: transparent !important;
}

button.jcew-filter-popup__clear:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

button.jcew-filter-popup__apply {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.5em 1em;
	border: none;
	cursor: pointer;
	border-radius: 4px;
	transition: all 0.3s;
}

button.jcew-filter-popup__apply:focus {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Loading overlay on target container */
.jcew-filter-popup__loading-wrap {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(255, 255, 255, 0.7);
	z-index: 10;
}

.jcew-filter-popup__spinner {
	width: 40px;
	height: 40px;
	border: 3px solid rgba(0, 0, 0, 0.1);
	border-top-color: currentColor;
	border-radius: 50%;
	animation: jcew-spin 0.8s linear infinite;
}

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

/* Error message in target container */
.jcew-filter-popup__error {
	display: block;
	padding: 1rem;
	text-align: center;
}

/* Wrapper needs position for absolute dropdown */
.elementor-widget-filter_popup_widget .elementor-widget-container {
	position: relative;
}
