/**
 * Frontend Styles for WooCommerce Product Filter
 *
 * @package WooCommerce_Product_Filter
 */

.wcpf-filters {
	margin-bottom: 30px;
	padding: 20px;
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
}

.wcpf-filter {
	margin-bottom: 25px;
	padding-bottom: 20px;
	border-bottom: 1px solid #e0e0e0;
}

.wcpf-filter:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.wcpf-filter-title {
	margin: 0 0 15px 0;
	font-size: 16px;
	font-weight: 600;
	color: #333;
}

.wcpf-filter-content {
	margin-left: 0;
	position: relative;
}

/* Filter Search */
.wcpf-filter-search {
	margin-bottom: 10px;
}

.wcpf-search-input {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #ddd;
	border-radius: 3px;
	font-size: 14px;
	box-sizing: border-box;
}

.wcpf-search-input:focus {
	outline: none;
	border-color: #0073aa;
	box-shadow: 0 0 0 1px #0073aa;
}

.wcpf-filter-item.filter-hidden {
	display: none;
}

/* Category Hierarchy Styles */
.wcpf-category-item-wrapper {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wcpf-category-toggle {
	width: 20px;
	height: 20px;
	padding: 0;
	margin: 0;
	border: 1px solid #ddd;
	background: #fff;
	border-radius: 3px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: all 0.2s ease;
}

.wcpf-category-toggle:hover {
	background: #f5f5f5;
	border-color: #0073aa;
}

.wcpf-category-toggle[aria-expanded="true"] .wcpf-category-toggle-icon {
	transform: rotate(0deg);
}

.wcpf-category-toggle-icon {
	display: inline-block;
	font-size: 14px;
	font-weight: bold;
	color: #666;
	line-height: 1;
	transition: transform 0.2s ease;
}

.wcpf-category-toggle[aria-expanded="true"] .wcpf-category-toggle-icon::before {
	content: '−';
}

.wcpf-category-toggle[aria-expanded="false"] .wcpf-category-toggle-icon::before {
	content: '+';
}

.wcpf-category-toggle-spacer {
	width: 20px;
	flex-shrink: 0;
}

.wcpf-filter-item-has-children .wcpf-category-label {
	font-weight: 600;
}

.wcpf-filter-item-child {
	margin-left: 28px;
	/* 20px toggle + 8px gap */
}

.wcpf-filter-item-level-1 {
	margin-left: 28px;
}

.wcpf-filter-item-level-2 {
	margin-left: 56px;
}

.wcpf-filter-item-level-3 {
	margin-left: 84px;
}

.wcpf-filter-children {
	list-style: none;
	margin: 5px 0 5px 0;
	padding-left: 0;
}

.wcpf-filter-children .wcpf-filter-item {
	border-left: 1px solid #e0e0e0;
	padding-left: 12px;
	margin-left: 0;
}

.wcpf-filter-list {
	list-style: none;
	margin: 0;
	padding: 0;
	max-height: 360px;
	/* Approximately 8-10 items (10 items * ~36px each) */
	overflow-y: auto;
	overflow-x: hidden;
	padding-right: 8px;
	margin-right: -8px;
	scrollbar-width: thin;
	scrollbar-color: #c1c1c1 #f1f1f1;
	-webkit-overflow-scrolling: touch;
	/* Smooth scrolling on iOS */
}

/* Custom scrollbar for webkit browsers */
.wcpf-filter-list::-webkit-scrollbar {
	width: 6px;
}

.wcpf-filter-list::-webkit-scrollbar-track {
	background: #f1f1f1;
	border-radius: 3px;
}

.wcpf-filter-list::-webkit-scrollbar-thumb {
	background: #c1c1c1;
	border-radius: 3px;
}

.wcpf-filter-list::-webkit-scrollbar-thumb:hover {
	background: #a8a8a8;
}

/* Fade effect at bottom to indicate more items */
.wcpf-filter-content::after {
	content: '';
	position: absolute;
	bottom: 0;
	left: 0;
	right: 8px;
	height: 40px;
	background: linear-gradient(to bottom, rgba(249, 249, 249, 0), rgba(249, 249, 249, 0.98));
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.3s ease;
	z-index: 1;
}

.wcpf-filter-content.has-scroll::after {
	opacity: 1;
}

.wcpf-filter-item {
	margin-bottom: 10px;
	position: relative;
	z-index: 2;
}

.wcpf-filter-item label {
	display: flex;
	align-items: center;
	cursor: pointer;
	font-size: 14px;
}

.wcpf-filter-checkbox {
	margin-right: 8px;
	width: 18px;
	height: 18px;
	cursor: pointer;
}

.wcpf-filter-label {
	flex: 1;
}

.wcpf-filter-count {
	color: #999;
	font-size: 13px;
	margin-left: 5px;
}

/* Price Filter */
.wcpf-price-range {
	display: flex;
	flex-direction: column;
	gap: 15px;
}

.wcpf-price-inputs {
	display: flex;
	gap: 15px;
	align-items: center;
}

.wcpf-price-inputs label {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 14px;
}

.wcpf-price-input {
	width: 100px;
	padding: 8px;
	border: 1px solid #ddd;
	border-radius: 3px;
	font-size: 14px;
}

.wcpf-price-slider {
	position: relative;
	height: 6px;
	background: #e0e0e0;
	border-radius: 3px;
	margin: 10px 0;
}

.wcpf-price-slider-input {
	position: absolute;
	width: 100%;
	height: 6px;
	background: transparent;
	outline: none;
	-webkit-appearance: none;
	appearance: none;
}

.wcpf-price-slider-input::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 18px;
	height: 18px;
	background: #0073aa;
	border-radius: 50%;
	cursor: pointer;
}

.wcpf-price-slider-input::-moz-range-thumb {
	width: 18px;
	height: 18px;
	background: #0073aa;
	border-radius: 50%;
	cursor: pointer;
	border: none;
}

.wcpf-price-display {
	font-size: 14px;
	font-weight: 600;
	color: #333;
}

/* Apply Button */
.wcpf-apply-filters {
	margin-top: 20px;
	padding-top: 20px;
	border-top: 1px solid #e0e0e0;
}

.wcpf-apply-button {
	padding: 12px 24px;
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 3px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.3s;
	width: 100%;
}

.wcpf-apply-button:hover {
	background: #005a87;
}

/* Mobile Apply Button - Hidden on desktop, shown on mobile */
.wcpf-mobile-apply-only {
	display: none;
}

/* Active Filters */
.wcpf-active-filters {
	margin-bottom: 20px;
	padding-bottom: 15px;
	border-bottom: 1px solid #e0e0e0;
	font-size: 14px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
}

.wcpf-active-filters:empty {
	display: none;
}

.wcpf-clear-all-filters {
	padding: 8px 16px;
	background: #dc3232;
	color: #fff;
	border: none;
	border-radius: 3px;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.3s;
	margin-left: auto;
}

.wcpf-clear-all-filters:hover {
	background: #a00;
}

.wcpf-active-filters strong {
	margin-right: 5px;
}

.wcpf-active-filter-item {
	display: inline-block;
	margin: 5px 10px 5px 0;
	padding: 6px 12px;
	background: #0073aa;
	color: #fff;
	border-radius: 3px;
	font-size: 13px;
}

.wcpf-remove-filter {
	margin-left: 8px;
	cursor: pointer;
	font-weight: bold;
	font-size: 16px;
	line-height: 1;
}

.wcpf-remove-filter:hover {
	color: #ff0000;
}

/* Loading Overlay - Transparent overlay that keeps products visible */
.wcpf-loading-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.85);
	display: none;
	z-index: 999;
	align-items: center;
	justify-content: center;
	backdrop-filter: blur(2px);
	-webkit-backdrop-filter: blur(2px);
}

.wcpf-loading-spinner {
	text-align: center;
	padding: 20px;
	font-size: 16px;
	color: #666;
	background: #fff;
	border: 1px solid #eee;
	border-radius: 4px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.wcpf-loading-spinner::before {
	content: '';
	border: 3px solid #f3f3f3;
	border-top: 3px solid #3498db;
	border-radius: 50%;
	width: 20px;
	height: 20px;
	animation: spin 1s linear infinite;
}

/* Legacy Loading (kept for backward compatibility) */
.wcpf-loading {
	text-align: center;
	padding: 40px 20px;
	font-size: 16px;
	color: #666;
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	margin: 20px 0;
	min-height: 200px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wcpf-loading:before {
	content: '';
	display: inline-block;
	width: 20px;
	height: 20px;
	border: 3px solid #f3f3f3;
	border-top: 3px solid #0073aa;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin-right: 10px;
}

@keyframes spin {
	0% {
		transform: rotate(0deg);
	}

	100% {
		transform: rotate(360deg);
	}
}

/* Mobile Filter Toggle Button */
.wcpf-mobile-toggle {
	display: none;
	position: fixed;
	bottom: 20px;
	right: 20px;
	z-index: 998;
	padding: 14px 24px;
	background: #0073aa;
	color: #fff;
	border: none;
	border-radius: 50px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
	transition: all 0.3s ease;
	align-items: center;
	gap: 8px;
	position: relative;
}

.wcpf-mobile-toggle:hover {
	background: #005a87;
	box-shadow: 0 6px 16px rgba(0, 115, 170, 0.5);
	transform: translateY(-2px);
}

.wcpf-mobile-toggle.has-active-filters {
	background: #dc3232;
	box-shadow: 0 4px 12px rgba(220, 50, 50, 0.4);
}

.wcpf-mobile-toggle.has-active-filters:hover {
	background: #a00;
	box-shadow: 0 6px 16px rgba(220, 50, 50, 0.5);
}

.wcpf-mobile-toggle-icon {
	font-size: 20px;
	line-height: 1;
}

.wcpf-mobile-toggle-text {
	line-height: 1;
}

/* Filter Count Badge */
.wcpf-filter-count-badge {
	position: absolute;
	top: -8px;
	right: -8px;
	background: #dc3232;
	color: #fff;
	border: 2px solid #fff;
	border-radius: 50%;
	min-width: 24px;
	height: 24px;
	font-size: 12px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 6px;
	box-shadow: 0 2px 6px rgba(220, 50, 50, 0.4);
	animation: pulse 2s infinite;
}

@keyframes pulse {

	0%,
	100% {
		transform: scale(1);
	}

	50% {
		transform: scale(1.1);
	}
}

.wcpf-filter-count-badge:empty {
	display: none;
}

/* Mobile Filter Overlay */
.wcpf-mobile-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 9998;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.wcpf-mobile-overlay.active {
	display: block;
	opacity: 1;
}

/* Mobile Filter Header */
.wcpf-mobile-header {
	display: none;
	padding: 20px;
	background: #0073aa;
	color: #fff;
	border-bottom: 1px solid rgba(255, 255, 255, 0.2);
	position: sticky;
	top: 0;
	z-index: 10;
	align-items: center;
	justify-content: space-between;
}

.wcpf-mobile-title {
	margin: 0;
	font-size: 20px;
	font-weight: 600;
	color: #fff;
}

.wcpf-mobile-close {
	width: 36px;
	height: 36px;
	padding: 0;
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
	border: none;
	border-radius: 50%;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}

.wcpf-mobile-close:hover {
	background: rgba(255, 255, 255, 0.3);
}

/* Responsive */
@media (max-width: 991px) {

	/* Show mobile toggle button */
	.wcpf-mobile-toggle {
		display: flex;
	}

	/* Hide filters by default on mobile */
	.wcpf-filters {
		position: fixed;
		top: 0;
		right: -100%;
		width: 85%;
		max-width: 400px;
		height: 100vh;
		overflow-y: auto;
		background: #fff;
		box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
		z-index: 9999;
		padding: 0;
		margin: 0;
		border: none;
		border-radius: 0;
		transition: right 0.3s ease;
		-webkit-overflow-scrolling: touch;
	}

	.wcpf-filters.active {
		right: 0;
	}

	/* Show mobile header */
	.wcpf-mobile-header {
		display: flex;
	}

	/* Filter content padding */
	.wcpf-filters>.wcpf-active-filters,
	.wcpf-filters>.wcpf-filter {
		padding: 15px 20px;
	}

	.wcpf-filter {
		margin-bottom: 0;
		padding-bottom: 20px;
		border-bottom: 1px solid #e0e0e0;
	}

	.wcpf-price-inputs {
		flex-direction: column;
		align-items: flex-start;
		gap: 10px;
	}

	.wcpf-price-input {
		width: 100%;
	}

	.wcpf-filter-list {
		max-height: 300px;
	}

	/* Show mobile apply button */
	.wcpf-mobile-apply-only {
		display: block;
		position: sticky;
		bottom: 0;
		background: #fff;
		padding: 15px 20px;
		margin: 0 -20px -20px -20px;
		border-top: 1px solid #e0e0e0;
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
		z-index: 10;
	}

	.wcpf-mobile-apply-button {
		padding: 14px 24px;
		font-size: 16px;
		font-weight: 600;
		background: #0073aa;
		color: #fff;
		border: none;
		border-radius: 4px;
		width: 100%;
		cursor: pointer;
		transition: all 0.3s ease;
		box-shadow: 0 2px 8px rgba(0, 115, 170, 0.3);
	}

	.wcpf-mobile-apply-button:hover,
	.wcpf-mobile-apply-button:active {
		background: #005a87;
		box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
		transform: translateY(-1px);
	}

	/* Prevent body scroll when filter is open */
	body.wcpf-filter-open {
		overflow: hidden;
	}

	/* Hide floating toggle button when bottom nav is visible */
	.wcpf-mobile-toggle {
		display: none !important;
	}
}

/* Mobile Bottom Navigation Bar */
.wcpf-mobile-bottom-nav {
	display: none;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: #fff;
	border-top: 1px solid #e0e0e0;
	box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
	z-index: 997;
	padding: 0;
	margin: 0;
}

.wcpf-bottom-nav-btn {
	flex: 1;
	padding: 12px 16px;
	background: transparent;
	border: none;
	border-right: 1px solid #e0e0e0;
	color: #333;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	transition: all 0.2s ease;
	position: relative;
}

.wcpf-bottom-nav-btn:last-child {
	border-right: none;
}

.wcpf-bottom-nav-btn:active {
	background: #f5f5f5;
}

.wcpf-bottom-nav-icon {
	font-size: 20px;
	line-height: 1;
}

.wcpf-bottom-nav-label {
	font-size: 12px;
	line-height: 1;
}

.wcpf-bottom-nav-badge {
	position: absolute;
	top: 8px;
	right: 8px;
	background: #dc3232;
	color: #fff;
	border-radius: 50%;
	min-width: 18px;
	height: 18px;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 4px;
	border: 2px solid #fff;
}

.wcpf-bottom-filter-btn.has-active-filters {
	color: #dc3232;
}

.wcpf-bottom-filter-btn.has-active-filters .wcpf-bottom-nav-icon {
	color: #dc3232;
}

/* Sort Dropdown Modal */
.wcpf-sort-modal {
	display: block;
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: #fff;
	border-top-left-radius: 16px;
	border-top-right-radius: 16px;
	box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
	z-index: 10000;
	max-height: 70vh;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	transform: translateY(100%);
	transition: transform 0.3s ease;
	visibility: hidden;
}

.wcpf-sort-modal.active {
	transform: translateY(0);
	visibility: visible;
}

.wcpf-sort-modal-header {
	padding: 20px;
	border-bottom: 1px solid #e0e0e0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	background: #fff;
	z-index: 10;
}

.wcpf-sort-modal-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: #333;
}

.wcpf-sort-modal-close {
	width: 32px;
	height: 32px;
	padding: 0;
	background: transparent;
	border: none;
	font-size: 24px;
	line-height: 1;
	color: #666;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wcpf-sort-modal-content {
	padding: 0;
}

.wcpf-sort-option {
	padding: 16px 20px;
	border-bottom: 1px solid #f0f0f0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: space-between;
	transition: background 0.2s ease;
}

.wcpf-sort-option:hover,
.wcpf-sort-option:active {
	background: #f9f9f9;
}

.wcpf-sort-option.active {
	background: #f0f7ff;
	color: #0073aa;
	font-weight: 600;
}

.wcpf-sort-option.active::after {
	content: '✓';
	color: #0073aa;
	font-weight: bold;
	margin-left: 10px;
}

/* Responsive - Show bottom nav on mobile */
@media (max-width: 991px) {
	.wcpf-mobile-bottom-nav {
		display: flex !important;
		position: fixed !important;
		bottom: 0 !important;
		left: 0 !important;
		right: 0 !important;
		z-index: 997 !important;
	}

	/* Add padding to body to prevent content from being hidden behind bottom nav */
	body {
		padding-bottom: 60px;
	}

	/* Ensure products area has space */
	.woocommerce-products-header,
	ul.products {
		margin-bottom: 80px;
	}

	/* Hide default WooCommerce sorting dropdown on mobile */
	form.woocommerce-ordering,
	.woocommerce-ordering,
	select.orderby {
		display: none !important;
	}
}

@media (max-width: 480px) {
	.wcpf-filters {
		width: 100%;
		max-width: 100%;
	}

	.wcpf-mobile-toggle {
		bottom: 15px;
		right: 15px;
		padding: 12px 20px;
		font-size: 14px;
	}

	.wcpf-mobile-toggle-text {
		display: none;
	}

	.wcpf-mobile-toggle-icon {
		font-size: 22px;
	}
}