/**
 * بهبودهای جستجوی پیشرفته
 * فاز 1: اسلایدر محدوده قیمت، انیمیشن‌ها، دکمه بازنشانی، تعداد نتایج
 */

/* ========== اسلایدر محدوده قیمت ========== */
.mlm-price-filter-wrapper {
	position: relative;
}

.mlm-range-slider-container {
	padding: 15px 10px;
}

.mlm-range-slider-wrapper {
	position: relative;
	height: 50px;
	margin-bottom: 10px;
}

.mlm-range-slider {
	position: absolute;
	width: 100%;
	height: 6px;
	background: transparent;
	outline: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	pointer-events: none;
	z-index: 2;
}

.mlm-range-slider::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 20px;
	height: 20px;
	background: #fea000;
	border-radius: 50%;
	cursor: pointer;
	pointer-events: all;
	box-shadow: 0 2px 6px rgba(254, 160, 0, 0.4);
	transition: all 0.3s ease;
	position: relative;
	z-index: 3;
}

.mlm-range-slider::-webkit-slider-thumb:hover {
	transform: scale(1.15);
	box-shadow: 0 3px 10px rgba(254, 160, 0, 0.6);
	background: #ffb733;
}

.mlm-range-slider::-moz-range-thumb {
	width: 20px;
	height: 20px;
	background: #fea000;
	border-radius: 50%;
	cursor: pointer;
	pointer-events: all;
	box-shadow: 0 2px 6px rgba(254, 160, 0, 0.4);
	transition: all 0.3s ease;
	border: none;
	position: relative;
	z-index: 3;
}

.mlm-range-slider::-moz-range-thumb:hover {
	transform: scale(1.15);
	box-shadow: 0 3px 10px rgba(254, 160, 0, 0.6);
	background: #ffb733;
}

.mlm-range-slider-track {
	position: absolute;
	top: 50%;
	left: 0;
	right: 0;
	height: 6px;
	background: #e0e0e0;
	border-radius: 3px;
	transform: translateY(-50%);
	z-index: 1;
}

.mlm-range-slider-progress {
	position: absolute;
	height: 100%;
	background: linear-gradient(90deg, #fea000 0%, #ffb733 100%);
	border-radius: 3px;
	transition: all 0.3s ease;
}

.mlm-range-values {
	padding: 8px 0;
	font-size: 13px;
}

.mlm-range-value-min,
.mlm-range-value-max {
	display: flex;
	align-items: center;
	gap: 5px;
	font-weight: 600;
	color: #333;
}

.mlm-range-label {
	color: #666;
	font-weight: 400;
	font-size: 12px;
}

.mlm-range-value-text {
	color: #fea000;
	font-size: 14px;
	font-weight: 700;
}

.mlm-range-currency {
	color: #666;
	font-size: 11px;
	margin-right: 2px;
}

.mlm-range-separator {
	color: #999;
	font-weight: 300;
	margin: 0 10px;
}

/* ========== انیمیشن‌های پایه ========== */

/* انیمیشن سایدبار موبایل */
@media (max-width: 991px) {
	.app-search-page-wrapper {
		backdrop-filter: blur(5px);
		-webkit-backdrop-filter: blur(5px);
		transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
		box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
	}
	
	.app-search-page-wrapper.open {
		animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	}
	
	.app-search-page-wrapper:not(.open) {
		animation: slideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	}
	
	@keyframes slideInRight {
		from {
			right: -250px;
			opacity: 0;
		}
		to {
			right: 0;
			opacity: 1;
		}
	}
	
	@keyframes slideOutRight {
		from {
			right: 0;
			opacity: 1;
		}
		to {
			right: -250px;
			opacity: 0;
		}
	}
	
	/* پس‌زمینه برای سایدبار موبایل */
	.app-search-page-wrapper::before {
		content: '';
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: rgba(0, 0, 0, 0.5);
		opacity: 0;
		pointer-events: none;
		transition: opacity 0.3s ease;
		z-index: -1;
	}
	
	.app-search-page-wrapper.open::before {
		opacity: 1;
		pointer-events: all;
	}
}

/* انیمیشن ویجت‌های فیلتر */
.mlm-filters-widget {
	animation: fadeInUp 0.4s ease-out;
	opacity: 0;
	animation-fill-mode: forwards;
}

.mlm-filters-widget:nth-child(1) { animation-delay: 0.1s; }
.mlm-filters-widget:nth-child(2) { animation-delay: 0.2s; }
.mlm-filters-widget:nth-child(3) { animation-delay: 0.3s; }
.mlm-filters-widget:nth-child(4) { animation-delay: 0.4s; }
.mlm-filters-widget:nth-child(5) { animation-delay: 0.5s; }

@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* انیمیشن باز و بسته شدن دسته‌بندی */
.mlm-filters-widget .category-item .childs {
	display: none !important;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.3s ease-out, padding 0.3s ease-out;
	padding-top: 0;
	padding-bottom: 0;
}

.mlm-filters-widget .category-item.open .childs {
	display: block !important;
	max-height: 1000px;
	padding-top: 8px;
	padding-bottom: 8px;
	animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

.mlm-filters-widget .category-item .toggle {
	transition: transform 0.3s ease;
}

.mlm-filters-widget .category-item.open .toggle {
	transform: rotate(90deg);
}

/* انیمیشن چک‌باکس */
.mlm-filters-widget .form-check-input {
	transition: all 0.2s ease;
	cursor: pointer;
}

.mlm-filters-widget .form-check-input:checked {
	animation: checkmarkPulse 0.4s ease;
}

@keyframes checkmarkPulse {
	0% {
		transform: scale(1);
	}
	50% {
		transform: scale(1.2);
	}
	100% {
		transform: scale(1);
	}
}

.mlm-filters-widget .form-check-label {
	transition: color 0.2s ease;
	cursor: pointer;
}

.mlm-filters-widget .form-check-input:checked + .form-check-label {
	color: #fea000;
	font-weight: 600;
}

/* ========== دکمه پاک کردن فیلترها ========== */
.mlm-reset-filters-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: #6c757d;
	color: white;
	border: none;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.3s ease;
	margin-top: 15px;
	margin-bottom: 10px;
}

.mlm-reset-filters-btn:hover {
	background: #5a6268;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.mlm-reset-filters-btn:active {
	transform: translateY(0);
}

.mlm-reset-filters-btn svg {
	width: 16px;
	height: 16px;
	transition: transform 0.3s ease;
}

.mlm-reset-filters-btn:hover svg {
	transform: rotate(-180deg);
}

/* ========== نمایش تعداد نتایج ========== */
.mlm-search-results-count {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	background: #f8f9fa;
	border-radius: 6px;
	font-size: 13px;
	color: #666;
	margin-bottom: 15px;
}

.mlm-search-results-count .count-number {
	font-weight: 700;
	color: #fea000;
	font-size: 15px;
}

.mlm-active-filters-count {
	display: inline-block;
	margin-right: 8px;
	padding: 2px 8px;
	background: #fea000;
	color: white;
	border-radius: 12px;
	font-size: 11px;
	font-weight: 600;
	min-width: 20px;
	text-align: center;
}

/* ========== حالت بارگذاری ========== */
.mlm-search-loading {
	position: relative;
	opacity: 0.6;
	pointer-events: none;
}

.mlm-search-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #fea000;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	z-index: 10;
}

@keyframes spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* ========== واکنش‌گرا ========== */
@media (max-width: 767px) {
	.mlm-range-values {
		flex-direction: column;
		gap: 10px;
		align-items: flex-start;
	}
	
	.mlm-range-separator {
		display: none;
	}
	
	.mlm-range-value-min,
	.mlm-range-value-max {
		width: 100%;
		justify-content: space-between;
	}
}

/* ========== فاز 2: انیمیشن‌های پیشرفته و بهبودهای UI ========== */

/* انیمیشن تدریجی برای نتایج جستجو (Stagger Animation) */
/* اطمینان از نمایش دکمه hover بالای کارت‌های دیگر */
.app-products-archive .row,
.modern-product-grid,
.modern-search-grid {
	position: relative;
	overflow: visible; /* اجازه نمایش دکمه‌ها از کارت */
	z-index: 1;
}

.app-products-archive .col-12,
.app-products-archive .col-sm-6,
.app-products-archive .col-xl-4,
.modern-product-grid .modern-product-item,
.modern-search-grid .modern-product-item {
	opacity: 0;
	transform: translateY(20px);
	animation: fadeInUpStagger 0.5s ease-out forwards;
	position: relative; /* برای z-index */
	z-index: 1; /* z-index پایه برای ایجاد stacking context */
	overflow: visible; /* اجازه نمایش دکمه‌های hover */
}

/* افزایش z-index برای column هنگام hover کارت محصول داخلش */
.app-products-archive .col-12:has(.modern-product-card:hover),
.app-products-archive .col-sm-6:has(.modern-product-card:hover),
.app-products-archive .col-xl-4:has(.modern-product-card:hover),
.app-products-archive .col-12:has(.archive-item:hover),
.app-products-archive .col-sm-6:has(.archive-item:hover),
.app-products-archive .col-xl-4:has(.archive-item:hover) {
	z-index: 100; /* افزایش z-index هنگام hover کارت برای نمایش بالای columns دیگر */
}

/* Fallback برای مرورگرهایی که :has را پشتیبانی نمی‌کنند */
@supports not selector(:has(*)) {
	.app-products-archive .col-12:hover,
	.app-products-archive .col-sm-6:hover,
	.app-products-archive .col-xl-4:hover {
		z-index: 100;
	}
}

.app-products-archive .col-12:nth-child(1),
.modern-product-grid .modern-product-item:nth-child(1),
.modern-search-grid .modern-product-item:nth-child(1) {
	animation-delay: 0.05s;
}

.app-products-archive .col-12:nth-child(2),
.modern-product-grid .modern-product-item:nth-child(2),
.modern-search-grid .modern-product-item:nth-child(2) {
	animation-delay: 0.1s;
}

.app-products-archive .col-12:nth-child(3),
.modern-product-grid .modern-product-item:nth-child(3),
.modern-search-grid .modern-product-item:nth-child(3) {
	animation-delay: 0.15s;
}

.app-products-archive .col-12:nth-child(4),
.modern-product-grid .modern-product-item:nth-child(4),
.modern-search-grid .modern-product-item:nth-child(4) {
	animation-delay: 0.2s;
}

.app-products-archive .col-12:nth-child(n+5),
.modern-product-grid .modern-product-item:nth-child(n+5),
.modern-search-grid .modern-product-item:nth-child(n+5) {
	animation-delay: 0.25s;
}

@keyframes fadeInUpStagger {
	from {
		opacity: 0;
		transform: translateY(20px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Skeleton Loading */
.mlm-skeleton-loading {
	padding: 20px 0;
}

.mlm-skeleton-item {
	background: white;
	border-radius: 8px;
	padding: 15px;
	margin-bottom: 20px;
	box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.mlm-skeleton-image {
	width: 100%;
	height: 200px;
	margin-bottom: 15px;
	border-radius: 6px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeletonLoading 1.5s ease-in-out infinite;
}

.mlm-skeleton-title {
	width: 70%;
	height: 20px;
	margin-bottom: 12px;
	border-radius: 4px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeletonLoading 1.5s ease-in-out infinite;
}

.mlm-skeleton-text {
	width: 90%;
	height: 16px;
	margin-bottom: 8px;
	border-radius: 4px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeletonLoading 1.5s ease-in-out infinite;
}

.mlm-skeleton-text.short {
	width: 50%;
}

.mlm-skeleton-price {
	width: 40%;
	height: 24px;
	margin-top: 15px;
	border-radius: 4px;
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: skeletonLoading 1.5s ease-in-out infinite;
}

@keyframes skeletonLoading {
	0% {
		background-position: 200% 0;
	}
	100% {
		background-position: -200% 0;
	}
}

/* Badge های فیلترهای فعال */
.mlm-active-filters-badges {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 15px;
	padding: 12px;
	background: #f8f9fa;
	border-radius: 8px;
	min-height: 50px;
}

.mlm-filter-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 12px;
	background: linear-gradient(135deg, #fea000 0%, #ffb733 100%);
	color: white;
	border-radius: 20px;
	font-size: 12px;
	font-weight: 600;
	animation: badgeAppear 0.3s ease-out;
	cursor: default;
}

.mlm-filter-badge .badge-label {
	display: flex;
	align-items: center;
	gap: 4px;
}

.mlm-filter-badge .badge-remove {
	cursor: pointer;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.3);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	font-size: 12px;
	line-height: 1;
}

.mlm-filter-badge .badge-remove:hover {
	background: rgba(255, 255, 255, 0.5);
	transform: scale(1.1);
}

@keyframes badgeAppear {
	from {
		opacity: 0;
		transform: scale(0.8);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* Empty State بهبود یافته */
.mlm-empty-state {
	text-align: center;
	padding: 60px 20px;
	animation: fadeInUp 0.5s ease-out;
}

.mlm-empty-state-icon {
	width: 120px;
	height: 120px;
	margin: 0 auto 30px;
	opacity: 0.3;
	animation: float 3s ease-in-out infinite;
}

.mlm-empty-state-title {
	font-size: 24px;
	font-weight: 700;
	color: #333;
	margin-bottom: 15px;
}

.mlm-empty-state-text {
	font-size: 16px;
	color: #666;
	margin-bottom: 30px;
	line-height: 1.6;
}

.mlm-empty-state-suggestions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px;
	margin-top: 30px;
}

.mlm-suggestion-tag {
	padding: 8px 16px;
	background: #f0f0f0;
	border-radius: 20px;
	font-size: 13px;
	color: #666;
	cursor: pointer;
	transition: all 0.2s ease;
	border: 1px solid transparent;
}

.mlm-suggestion-tag:hover {
	background: #fea000;
	color: white;
	border-color: #fea000;
	transform: translateY(-2px);
	box-shadow: 0 4px 12px rgba(254, 160, 0, 0.3);
}

@keyframes float {
	0%, 100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-15px);
	}
}

/* بهبود دسته‌بندی با نمایش تعداد */
.mlm-category-with-count {
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
}

.mlm-category-count {
	font-size: 11px;
	color: #999;
	background: #f0f0f0;
	padding: 2px 8px;
	border-radius: 10px;
	font-weight: 500;
}

.mlm-filters-widget .form-check-input:checked ~ .mlm-category-count {
	background: #fea000;
	color: white;
}

/* بهبود Select */
.mlm-filters-widget select {
	transition: all 0.3s ease;
	border: 1px solid #ddd;
	border-radius: 6px;
}

.mlm-filters-widget select:focus {
	border-color: #fea000;
	box-shadow: 0 0 0 3px rgba(254, 160, 0, 0.1);
}

.mlm-filters-widget select:hover {
	border-color: #fea000;
}

/* ========== فاز 3: Live Search و View Toggle ========== */

/* Live Search Suggestions */
.mlm-live-search-suggestions {
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	right: 0;
	background: white;
	border-radius: 12px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	z-index: 1000;
	max-height: 500px;
	overflow-y: auto;
	display: none;
	animation: fadeInDown 0.3s ease-out;
}

.mlm-suggestions-section {
	padding: 10px 0;
	border-bottom: 1px solid #f0f0f0;
}

.mlm-suggestions-section:last-child {
	border-bottom: none;
}

.mlm-suggestions-header {
	padding: 8px 16px;
	font-size: 12px;
	font-weight: 700;
	color: #666;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	background: #f8f9fa;
}

.mlm-suggestions-list {
	max-height: 300px;
	overflow-y: auto;
}

.mlm-suggestion-item {
	border-bottom: 1px solid #f8f9fa;
	transition: background 0.2s ease;
}

.mlm-suggestion-item:last-child {
	border-bottom: none;
}

.mlm-suggestion-item:hover,
.mlm-suggestion-item.active {
	background: #f8f9fa;
}

.mlm-suggestion-item a {
	display: flex;
	align-items: center;
	padding: 12px 16px;
	text-decoration: none;
	color: inherit;
}

.suggestion-image {
	width: 50px;
	height: 50px;
	object-fit: cover;
	border-radius: 6px;
	margin-left: 12px;
	flex-shrink: 0;
}

.suggestion-icon {
	font-size: 24px;
	margin-left: 12px;
	width: 40px;
	text-align: center;
}

.suggestion-content {
	flex: 1;
	min-width: 0;
}

.suggestion-title {
	font-size: 14px;
	font-weight: 600;
	color: #333;
	margin-bottom: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.suggestion-price {
	font-size: 13px;
	color: #fea000;
	font-weight: 600;
}

.mlm-search-suggestions-loading,
.mlm-search-suggestions-empty,
.mlm-search-suggestions-error {
	padding: 20px;
	text-align: center;
	color: #999;
	font-size: 14px;
}

.mlm-search-suggestions-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
}

.mlm-suggestions-footer {
	padding: 12px 16px;
	text-align: center;
	border-top: 2px solid #f0f0f0;
	background: #f8f9fa;
}

.mlm-suggestions-footer a {
	color: #fea000;
	font-weight: 600;
	text-decoration: none;
	font-size: 13px;
	transition: color 0.2s ease;
}

.mlm-suggestions-footer a:hover {
	color: #ffb733;
}

@keyframes fadeInDown {
	from {
		opacity: 0;
		transform: translateY(-10px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* View Toggle */
.mlm-view-toggle {
	display: inline-flex;
	gap: 8px;
	background: white;
	border: 1px solid #ddd;
	border-radius: 8px;
	padding: 4px;
	margin-right: 15px;
}

.mlm-view-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	border-radius: 6px;
	cursor: pointer;
	transition: all 0.2s ease;
	padding: 0;
	color: #666;
}

.mlm-view-btn svg {
	width: 18px;
	height: 18px;
}

.mlm-view-btn:hover {
	background: #f0f0f0;
	color: #fea000;
}

.mlm-view-btn.active {
	background: #fea000;
	color: white;
}

.mlm-view-btn.active:hover {
	background: #ffb733;
}

/* List View Mode */
.mlm-view-list-mode .col-12,
.mlm-view-list-mode .modern-product-item {
	width: 100% !important;
	max-width: 100% !important;
	flex: 0 0 100% !important;
}

.mlm-list-item {
	display: flex !important;
	flex-direction: row;
	gap: 20px;
	padding: 20px;
	background: white;
	border-radius: 8px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
	margin-bottom: 20px;
}

.mlm-list-item .product-image-wrapper,
.mlm-list-item img {
	width: 200px !important;
	max-width: 200px;
	flex-shrink: 0;
}

.mlm-list-item .product-content {
	flex: 1;
}

@media (max-width: 767px) {
	.mlm-list-item {
		flex-direction: column;
	}
	
	.mlm-list-item .product-image-wrapper,
	.mlm-list-item img {
		width: 100% !important;
		max-width: 100%;
	}
	
	.mlm-view-toggle {
		margin-right: 0;
		margin-top: 10px;
	}
}

