/**
 * Frontend Styles
 *
 * Styles for the frontend filter widget.
 *
 * @package EasyWooCommerceFilter
 * @since 1.0.0
 */

/* === JetEngine Grid Layout Fix (Applied only after AJAX via JS) === */
/* این CSS فقط برای backup است - اصلی از JS اعمال می‌شود */
.ewf-grid-fixed .jet-listing-grid,
.ewf-grid-fixed .jet-listing-grid__items {
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

.ewf-grid-fixed .jet-listing-grid__item .elementor {
	width: 100%;
	max-width: 100%;
	margin-left: auto;
	margin-right: auto;
}

/* Filter Widget Container */
.ewf-filters-widget {
	background: transparent;
	border: none;
	padding: 0;
	margin-bottom: 30px;
}

/* Filter Box */
.ewf-filter-box {
	background: #fff;
	border: 1px solid #e1e1e1;
	border-radius: 6px;
	padding: 0;
	margin-bottom: 15px;
	transition: all 0.3s ease;
	overflow: hidden;
}

.ewf-filter-box:hover {
	border-color: #1890ff;
	box-shadow: 0 2px 8px rgba(24, 144, 255, 0.1);
}

.ewf-filter-box:last-child {
	margin-bottom: 0;
}

/* Filter Group */
.ewf-filter-group {
	margin-bottom: 0;
}

.ewf-filter-group:last-child {
	margin-bottom: 0;
}

/* Accordion Mode */
.ewf-filter-group.ewf-accordion .ewf-filter-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 15px;
	cursor: pointer;
	transition: all 0.2s ease;
	border-bottom: 1px solid #e1e1e1;
	user-select: none;
}

.ewf-filter-group.ewf-accordion .ewf-filter-header:hover {
	background: #f9f9f9;
}

.ewf-filter-group.ewf-accordion .ewf-filter-header .ewf-filter-title {
	margin: 0;
	padding: 0;
	border: none;
	font-size: 14px;
	font-weight: 600;
	color: #333;
}

.ewf-filter-group.ewf-accordion .ewf-toggle-icon {
	transition: transform 0.3s ease;
	color: #666;
	font-size: 12px;
}

.ewf-filter-group.ewf-accordion.active .ewf-toggle-icon {
	transform: rotate(180deg);
}

.ewf-filter-group.ewf-accordion .ewf-filter-content {
	padding: 15px;
	border-top: none;
}

/* Non-Accordion Mode */
.ewf-filter-group:not(.ewf-accordion) .ewf-filter-title {
	font-size: 14px;
	font-weight: 600;
	color: #333;
	margin: 0;
	padding: 12px 15px;
	border-bottom: 1px solid #e1e1e1;
}

.ewf-filter-group:not(.ewf-accordion) .ewf-filter-content {
	padding: 15px;
}

/* Filter Options */
.ewf-filter-options {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.ewf-filter-options.ewf-scrollable {
	overflow-y: auto;
	overflow-x: hidden;
}

.ewf-filter-options.ewf-scrollable::-webkit-scrollbar {
	width: 6px;
}

.ewf-filter-options.ewf-scrollable::-webkit-scrollbar-track {
	background: #f1f1f1;
	border-radius: 3px;
}

.ewf-filter-options.ewf-scrollable::-webkit-scrollbar-thumb {
	background: #c1c1c1;
	border-radius: 3px;
}

.ewf-filter-options.ewf-scrollable::-webkit-scrollbar-thumb:hover {
	background: #a1a1a1;
}

.ewf-filter-option {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 6px 8px;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	margin: 0;
}

.ewf-filter-option:hover {
	background: #f5f5f5;
}

.ewf-filter-option input[type="checkbox"] {
	width: 16px;
	height: 16px;
	margin: 0;
	cursor: pointer;
	accent-color: #1890ff;
	flex-shrink: 0;
}

.ewf-option-label {
	flex: 1;
	font-size: 13px;
	color: #666;
	cursor: pointer;
	user-select: none;
	line-height: 1.4;
}

.ewf-filter-option input[type="checkbox"]:checked + .ewf-option-label {
	color: #1890ff;
	font-weight: 500;
}

.ewf-option-count {
	font-size: 11px;
	color: #999;
	background: #f5f5f5;
	padding: 2px 6px;
	border-radius: 10px;
	flex-shrink: 0;
}

/* Apply Button Container */
.ewf-apply-container {
	margin-top: 12px;
	padding-top: 12px;
	border-top: 1px solid #f0f0f0;
}

/* Single Apply Button (appears when selection is made) */
.ewf-apply-single-filter {
	width: 100%;
	padding: 10px 16px;
	margin: 0;
	font-size: 13px;
	font-weight: 500;
	border: 1px solid #1890ff;
	border-radius: 5px;
	cursor: pointer;
	transition: all 0.25s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: linear-gradient(135deg, #1890ff 0%, #0d7ae4 100%);
	color: #fff;
	text-transform: none;
	letter-spacing: 0.3px;
	box-shadow: 0 2px 4px rgba(24, 144, 255, 0.15);
	line-height: 1.5;
}

.ewf-apply-single-filter:hover {
	background: linear-gradient(135deg, #0d7ae4 0%, #0056b3 100%);
	transform: translateY(-2px);
	box-shadow: 0 4px 10px rgba(24, 144, 255, 0.35);
	border-color: #0d7ae4;
}

.ewf-apply-single-filter:active {
	transform: translateY(0);
	box-shadow: 0 1px 3px rgba(24, 144, 255, 0.25);
}

.ewf-apply-single-filter:focus {
	outline: 2px solid #1890ff;
	outline-offset: 2px;
}

.ewf-apply-single-filter i {
	font-size: 11px;
	margin-right: -2px;
}

/* Filter Actions (Main Apply/Reset buttons) */
.ewf-filter-actions {
	display: flex;
	gap: 10px;
	margin-top: 20px;
	padding: 0 5px;
}

.ewf-filter-actions button {
	flex: 1;
	padding: 10px 20px;
	font-size: 13px;
	font-weight: 600;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.3s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
}

.ewf-apply-filters {
	background: #28a745;
	color: #fff;
}

.ewf-apply-filters:hover {
	background: #218838;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.ewf-reset-filters {
	background: #6c757d;
	color: #fff;
}

.ewf-reset-filters:hover {
	background: #5a6268;
}

/* Loading State */
.ewf-loading {
	text-align: center;
	padding: 20px;
}

.ewf-spinner {
	display: inline-block;
	width: 40px;
	height: 40px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #1890ff;
	border-radius: 50%;
	animation: spin 1s linear infinite;
}

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

/* Products Loading */
.ewf-loading-products {
	opacity: 0.5;
	pointer-events: none;
	position: relative;
}

.ewf-loading-products::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(255, 255, 255, 0.8);
	z-index: 10;
}

/* Stacked Display Mode */
.ewf-filter-stacked .ewf-filter-group {
	padding-bottom: 20px;
	margin-bottom: 20px;
	border-bottom: 1px solid #e1e1e1;
}

.ewf-filter-stacked .ewf-filter-group:last-child {
	border-bottom: none;
	padding-bottom: 0;
	margin-bottom: 0;
}

/* Hide Elements */
.ewf-hide-titles .ewf-filter-title {
	display: none;
}

.ewf-hide-count .ewf-option-count {
	display: none;
}

.ewf-hide-buttons .ewf-filter-actions {
	display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
	.ewf-filters-widget {
		padding: 0;
	}
	
	.ewf-filter-box {
		padding: 0;
	}
	
	.ewf-filter-title {
		font-size: 13px;
	}
	
	.ewf-filter-actions {
		flex-direction: column;
	}
	
	.ewf-filter-actions button {
		width: 100%;
	}
}

/* Accessibility */
.ewf-filter-option input[type="checkbox"]:focus {
	outline: 2px solid #1890ff;
	outline-offset: 2px;
}

.ewf-filter-actions button:focus {
	outline: 2px solid #1890ff;
	outline-offset: 2px;
}

.ewf-filter-group.ewf-accordion .ewf-filter-header:focus {
	outline: 2px solid #1890ff;
	outline-offset: -2px;
}

/* Animations */
@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.ewf-filter-box {
	animation: fadeIn 0.3s ease;
}

.ewf-filter-group.ewf-accordion .ewf-filter-content {
	animation: slideDown 0.3s ease;
}

@keyframes slideDown {
	from {
		opacity: 0;
		max-height: 0;
	}
	to {
		opacity: 1;
		max-height: 1000px;
	}
}

/* WooCommerce Integration */
.woocommerce .ewf-filters-widget {
	margin-bottom: 30px;
}

.woocommerce-info {
	padding: 20px;
	background: #f5f5f5;
	border-left: 4px solid #1890ff;
	margin: 20px 0;
}

/* RTL Support */
[dir="rtl"] .ewf-filter-option {
	flex-direction: row-reverse;
}

[dir="rtl"] .ewf-filter-title {
	border-right: 2px solid #1890ff;
	border-left: none;
	padding-right: 0;
	padding-left: 10px;
}

[dir="rtl"] .ewf-filter-group.ewf-accordion .ewf-toggle-icon {
	transform: rotate(0);
}

[dir="rtl"] .ewf-filter-group.ewf-accordion.active .ewf-toggle-icon {
	transform: rotate(180deg);
}
