/* ==========================================================
   بخش اصلی / بسته‌بندی ویجت
========================================================== */
.sa-wrapper {
	--sa-bg-start: #E4032E;
	--sa-bg-end: #C40126;
	max-width: 100%;
	margin: 0 auto;
	background: linear-gradient(135deg, var(--sa-bg-start), var(--sa-bg-end));
	padding: 16px 16px 20px;
	box-sizing: border-box;
	font-family: "Vazirmatn", "IRANSans", "Tahoma", inherit;
	box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
}
.sa-wrapper * {
	box-sizing: border-box;
}

.sa-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 14px;
}
.sa-see-all {
	display: flex;
	align-items: center;
	gap: 4px;
	color: #fff;
	text-decoration: none;
	font-size: 14px;
	opacity: .95;
	order: 3;
	transition: opacity .15s ease;
}
.sa-see-all:hover {
	opacity: 1;
	text-decoration: underline;
}
.sa-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 20px;
	font-weight: 800;
	order: 1;
	color: #fff;
}
/* آیکون کنار عنوان: هم برای آیکون‌های Font Awesome (تگ i) و هم SVG آپلودی (تگ img) */
.sa-title-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	font-size: 20px;
	line-height: 1;
	color: currentColor;
}
.sa-title-icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}
.sa-title-icon img {
	width: 20px;
	height: 20px;
	object-fit: contain;
}
.sa-timer {
	display: flex;
	align-items: center;
	gap: 6px;
	order: 2;
}
.sa-timer-box {
	background: rgba(255, 255, 255, .15);
	border: 1px solid rgba(255, 255, 255, .4);
	border-radius: 6px;
	min-width: 34px;
	text-align: center;
	padding: 4px 6px;
	font-weight: 700;
	font-size: 14px;
	color: #fff;
}
.sa-colon {
	font-weight: 700;
	color: #fff;
}

.sa-slider-track {
	display: flex;
	gap: 14px;
	overflow-x: auto;
	scroll-snap-type: x mandatory;
	padding: 6px 4px 10px;
	-webkit-overflow-scrolling: touch;
}
.sa-slider-track::-webkit-scrollbar {
	height: 6px;
}
.sa-slider-track::-webkit-scrollbar-thumb {
	background: rgba(255, 255, 255, .4);
	border-radius: 10px;
}

/* ==========================================================
   کارت محصول
========================================================== */
.sa-card {
	scroll-snap-align: start;
	flex: 0 0 228px;
	background: #fff;
	border-radius: 14px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	box-shadow: 0 3px 10px rgba(0, 0, 0, .12);
	transition: transform .25s ease, box-shadow .25s ease;
}
.sa-card:hover {
	transform: translateY(-6px);
	box-shadow: 0 16px 30px rgba(0, 0, 0, .22);
}

.sa-card-link {
	text-decoration: none;
	color: inherit;
	display: block;
}

/* --- تصویر + برچسب‌های شناور --- */
.sa-img-wrap {
	position: relative;
	width: 100%;
	height: 150px;
	background: #f7f7f8;
	overflow: hidden;
}
.sa-img-wrap img {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 10px;
	transition: transform .4s ease;
}
.sa-card:hover .sa-img-wrap img {
	transform: scale(1.1);
}

.sa-discount-ribbon {
	position: absolute;
	top: 10px;
	inset-inline-start: 10px;
	background: #E4032E;
	color: #fff;
	font-size: 12px;
	font-weight: 800;
	padding: 4px 9px;
	border-radius: 20px;
	z-index: 2;
	box-shadow: 0 0 0 0 rgba(228, 3, 46, .55);
	animation: sa-pulse-ring 2.2s ease-out infinite;
}
@keyframes sa-pulse-ring {
	0%   { box-shadow: 0 0 0 0 rgba(228, 3, 46, .5); }
	70%  { box-shadow: 0 0 0 8px rgba(228, 3, 46, 0); }
	100% { box-shadow: 0 0 0 0 rgba(228, 3, 46, 0); }
}

/* --- دکمه علاقه‌مندی‌ها (روی عکس) --- */
.sa-wishlist-btn {
	position: absolute;
	top: 10px;
	inset-inline-end: 10px;
	width: 30px;
	height: 30px;
	border: none;
	border-radius: 50%;
	background: #fff;
	color: #999;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	z-index: 2;
	box-shadow: 0 3px 8px rgba(0, 0, 0, .15);
	transition: transform .15s ease, color .2s ease;
}
.sa-wishlist-btn:hover {
	transform: scale(1.12);
}
.sa-wishlist-btn .sa-heart-filled {
	display: none;
}
.sa-wishlist-btn.active .sa-heart-outline {
	display: none;
}
.sa-wishlist-btn.active .sa-heart-filled {
	display: block;
	color: #E4032E;
}
.sa-wishlist-btn.sa-pop .sa-heart-filled,
.sa-wishlist-btn.sa-pop .sa-heart-outline {
	animation: sa-heart-pop .35s ease;
}
@keyframes sa-heart-pop {
	0%   { transform: scale(1); }
	40%  { transform: scale(1.35); }
	100% { transform: scale(1); }
}

/* --- ردیف دکمه‌های پایین کارت: خرید ۸۰٪ (راست) + پیش‌نمایش سریع ۲۰٪ آیکون‌تنها (چپ) --- */
.sa-card-actions {
	display: flex;
	align-items: stretch;
	gap: 8px;
	margin-top: auto;
}
.sa-action-btn {
	margin-top: 0 !important;
}
.sa-card-actions .sa-add-cart-btn {
	flex: 4 1 0%; /* حدود ۸۰٪ عرض */
	min-width: 0;
}
/* لینک «مشاهده سبد خرید» که ووکامرس به‌صورت خودکار بعد از افزودن موفق چاپ می‌کند
   داخل ردیف دکمه‌های ما جا نمی‌شود و چیدمان را به‌هم می‌ریزد؛ به همین دلیل مخفی می‌شود. */
.sa-card-actions .added_to_cart,
.sa-card-actions a.wc-forward {
	display: none !important;
}
.sa-quick-view-btn {
	flex: 1 1 0%; /* حدود ۲۰٪ عرض */
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	color: #E4032E;
	border: 1.5px solid #E4032E;
	border-radius: 8px;
	padding: 9px 6px;
	cursor: pointer;
	transition: background-color .2s ease, color .2s ease, transform .12s ease;
}
.sa-quick-view-btn:hover {
	background: #E4032E;
	color: #fff;
}
.sa-quick-view-btn:active {
	transform: scale(.96);
}
.sa-quick-view-btn svg {
	flex-shrink: 0;
	transition: transform .2s ease;
}
.sa-quick-view-btn:hover svg {
	transform: scale(1.1);
}

/* --- بدنه کارت --- */
.sa-card-body {
	padding: 12px 12px 14px;
	display: flex;
	flex-direction: column;
	flex-grow: 1;
	text-align: center;
}

.sa-card-body h3 {
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.6;
	margin: 0 0 8px;
	min-height: 42px;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	color: #222;
	transition: color .15s ease;
}
.sa-card-link:hover h3 {
	color: #E4032E;
}

.sa-price-row {
	display: flex;
	align-items: baseline;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
	margin-bottom: 8px;
}
.sa-old-price {
	font-size: 12px;
	color: #9b9b9b;
	text-decoration: line-through;
}
.sa-old-price .amount,
.sa-old-price bdi {
	font-size: 12px !important;
}
.sa-new-price {
	font-size: 16px;
	font-weight: 800;
	color: #111;
}
.sa-new-price .amount,
.sa-new-price bdi {
	font-size: 16px !important;
	font-weight: 800;
}

/* --- نوار موجودی --- */
.sa-stock-wrap {
	margin-bottom: 10px;
}
.sa-stock-bar {
	position: relative;
	width: 100%;
	height: 7px;
	border-radius: 20px;
	background: #efefef;
	overflow: hidden;
	margin-bottom: 5px;
}
.sa-stock-fill {
	position: relative;
	height: 100%;
	border-radius: 20px;
	transition: width .7s ease;
	overflow: hidden;
}
.sa-stock-fill.sa-stock-high { background: #2FB344; }
.sa-stock-fill.sa-stock-mid  { background: #F5A623; }
.sa-stock-fill.sa-stock-low  { background: #E4032E; }

.sa-stock-fill::after {
	content: "";
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .55), transparent);
	transform: translateX(-100%);
	animation: sa-shimmer 2.2s ease-in-out infinite;
}
@keyframes sa-shimmer {
	100% { transform: translateX(100%); }
}

.sa-stock-text {
	font-size: 11px;
	color: #666;
	display: block;
}

/* --- نشان تعداد کل فروش محصول --- */
.sa-sales-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	margin: 0 auto 9px;
	padding: 4px 11px;
	border-radius: 999px;
	background: #fff1de;
	color: #9a5b13;
	font-size: 11px;
	line-height: 1.5;
	width: fit-content;
	box-shadow: inset 0 0 0 1px rgba(154, 91, 19, .12);
}
.sa-sales-badge-icon {
	flex-shrink: 0;
	color: #f5a623;
}
.sa-sales-badge-text b {
	font-weight: 800;
}

/* --- دکمه افزودن به سبد --- */
.sa-add-cart-btn {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	width: 100%;
	overflow: hidden;
	text-align: center;
	background: #E4032E;
	color: #fff !important;
	border: 1px solid #E4032E;
	border-radius: 8px;
	padding: 9px 10px;
	font-size: 13px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	margin-top: auto;
	transition: background-color .2s ease, border-color .2s ease, transform .12s ease, box-shadow .2s ease;
}
.sa-add-cart-btn:hover {
	box-shadow: 0 6px 16px rgba(228, 3, 46, .35);
}
.sa-add-cart-btn:active {
	transform: scale(.96);
}
/* آیکون سبد خرید به‌صورت خالص CSS (نیازی به تغییر مارک‌آپ قالب نیست) */
.sa-add-cart-btn::before {
	content: "";
	flex-shrink: 0;
	width: 14px;
	height: 14px;
	display: inline-block;
	background-color: currentColor;
	-webkit-mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3h2l2.4 12.4a2 2 0 002 1.6h8.2a2 2 0 002-1.6L21 8H6'/%3E%3Ccircle cx='10' cy='21' r='1.3' fill='%23000'/%3E%3Ccircle cx='17' cy='21' r='1.3' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 3h2l2.4 12.4a2 2 0 002 1.6h8.2a2 2 0 002-1.6L21 8H6'/%3E%3Ccircle cx='10' cy='21' r='1.3' fill='%23000'/%3E%3Ccircle cx='17' cy='21' r='1.3' fill='%23000'/%3E%3C/svg%3E") center / contain no-repeat;
	transition: transform .3s ease;
}
.sa-add-cart-btn:hover::before {
	transform: translateY(-1px) rotate(-8deg);
}
.sa-add-cart-btn.loading {
	pointer-events: none;
	opacity: .75;
}
.sa-add-cart-btn.loading::before {
	animation: sa-icon-spin .7s linear infinite;
}
@keyframes sa-icon-spin {
	100% { transform: rotate(360deg); }
}
.sa-add-cart-btn.added {
	background: #2FB344 !important;
	border-color: #2FB344 !important;
}

/* افکت ریپل کلیک */
.sa-ripple {
	position: absolute;
	border-radius: 50%;
	background: rgba(255, 255, 255, .55);
	transform: scale(0);
	animation: sa-ripple-anim .55s ease-out;
	pointer-events: none;
}
@keyframes sa-ripple-anim {
	to {
		transform: scale(3.5);
		opacity: 0;
	}
}

.sa-no-products {
	color: #fff;
	text-align: center;
	padding: 20px;
	font-size: 14px;
}

/* ==========================================================
   مودال پیش‌نمایش سریع (Quick View)
========================================================== */
body.sa-qv-open {
	overflow: hidden;
}
.sa-qv-overlay {
	position: fixed;
	inset: 0;
	background: rgba(20, 20, 20, .55);
	backdrop-filter: blur(3px);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 999999;
	padding: 16px;
	opacity: 0;
	transition: opacity .25s ease;
	/* عمداً روی فونت پیش‌فرض قالب (body) تکیه می‌کنیم تا با بقیه سایت یکدست بماند */
	font-family: inherit;
}
.sa-qv-overlay.sa-qv-visible {
	opacity: 1;
}
.sa-qv-modal {
	background: #fff;
	border-radius: 16px;
	width: 100%;
	max-width: 780px;
	max-height: 88vh;
	overflow-y: auto;
	position: relative;
	transform: scale(.9) translateY(10px);
	transition: transform .28s cubic-bezier(.34, 1.56, .64, 1);
	box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.sa-qv-overlay.sa-qv-visible .sa-qv-modal {
	transform: scale(1) translateY(0);
}
.sa-qv-close {
	position: absolute;
	top: 12px;
	inset-inline-end: 12px;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	border: none;
	background: #f2f2f2;
	color: #333;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	z-index: 3;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color .15s ease, transform .15s ease;
}
.sa-qv-close:hover {
	background: #E4032E;
	color: #fff;
	transform: rotate(90deg);
}

.sa-qv-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 260px;
}
.sa-qv-spinner {
	width: 38px;
	height: 38px;
	border-radius: 50%;
	border: 4px solid #f0f0f0;
	border-top-color: #E4032E;
	animation: sa-spin .8s linear infinite;
}
@keyframes sa-spin {
	100% { transform: rotate(360deg); }
}

.sa-qv-inner {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 0;
}
.sa-qv-image {
	position: relative;
	background: #f7f7f8;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 30px;
	border-radius: 16px 0 0 16px;
	min-height: 320px;
}
.sa-qv-image img {
	max-width: 100%;
	max-height: 280px;
	object-fit: contain;
}
.sa-qv-discount-badge {
	position: absolute;
	top: 16px;
	inset-inline-start: 16px;
	background: #E4032E;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	padding: 5px 10px;
	border-radius: 20px;
}
.sa-qv-details {
	padding: 28px 26px;
	display: flex;
	flex-direction: column;
	text-align: right;
}
.sa-qv-title {
	font-size: 18px;
	font-weight: 800;
	margin: 4px 0 14px;
	color: #1a1a1a;
	line-height: 1.6;
}
.sa-qv-price-row {
	display: flex;
	align-items: baseline;
	gap: 10px;
	margin-bottom: 14px;
}
.sa-qv-old-price {
	font-size: 13px;
	color: #9b9b9b;
	text-decoration: line-through;
}
.sa-qv-new-price {
	font-size: 20px;
	font-weight: 800;
	color: #E4032E;
}
.sa-qv-desc {
	font-size: 13px;
	line-height: 1.9;
	color: #555;
	margin-bottom: 16px;
}
.sa-qv-desc p {
	margin: 0 0 8px;
}
.sa-qv-stock {
	margin-bottom: 18px;
	display: flex;
	align-items: center;
	gap: 10px;
	flex-wrap: wrap;
}
.sa-qv-stock-badge {
	display: inline-block;
	font-size: 12px;
	font-weight: 700;
	padding: 5px 12px;
	border-radius: 20px;
}
.sa-qv-stock-badge.sa-in-stock {
	background: #e6f7ea;
	color: #1e8a37;
}
.sa-qv-stock-badge.sa-out-stock {
	background: #fdeaec;
	color: #c40126;
}
.sa-qv-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: auto;
}
.sa-qv-actions .added_to_cart,
.sa-qv-actions a.wc-forward {
	display: none !important;
}
.sa-qv-add-btn {
	flex: 1 1 160px;
}
.sa-qv-full-link {
	flex: 1 1 160px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1.5px solid #E4032E;
	color: #E4032E;
	text-decoration: none;
	border-radius: 8px;
	font-size: 13px;
	font-weight: 600;
	padding: 9px 10px;
	transition: background-color .2s ease, color .2s ease;
}
.sa-qv-full-link:hover {
	background: #E4032E;
	color: #fff;
}

/* ==========================================================
   پنل بنر ویژه دسکتاپ (فقط زمانی که از تنظیمات فعال شود)
========================================================== */
.sa-banner-panel {
	display: none; /* در موبایل همیشه مخفی؛ فقط با مدیا-کوئری دسکتاپ نمایش داده می‌شود */
}

@media (min-width: 993px) {
	.sa-wrapper.sa-has-banner {
		display: flex;
		align-items: stretch;
		gap: 18px;
		background: transparent;
		box-shadow: none;
		padding: 0;
	}
	.sa-wrapper.sa-has-banner .sa-header {
		display: none;
	}
	.sa-wrapper.sa-has-banner .sa-banner-panel {
		display: flex;
		flex-direction: column;
		align-items: center;
		text-align: center;
		flex: 0 0 270px;
		gap: 12px;
		background: linear-gradient(160deg, var(--sa-bg-start), var(--sa-bg-end));
		border-radius: 16px;
		padding: 26px 20px;
		box-shadow: 0 6px 24px rgba(0, 0, 0, .12);
	}
	.sa-wrapper.sa-has-banner .sa-banner-panel .sa-title,
	.sa-wrapper.sa-has-banner .sa-banner-panel .sa-timer {
		order: initial; /* لغو ترتیب flex مخصوص هدر موبایل تا ترتیب طبیعی DOM حفظ شود */
	}
	.sa-banner-image {
		max-width: 130px;
		max-height: 130px;
		object-fit: contain;
	}
	.sa-banner-icon-wrap {
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 64px;
		line-height: 1;
		color: #fff;
	}
	.sa-banner-icon {
		display: inline-flex;
	}
	.sa-banner-icon svg {
		width: 1em;
		height: 1em;
		fill: currentColor;
	}
	.sa-banner-icon img {
		width: 64px;
		height: 64px;
		object-fit: contain;
	}
	.sa-banner-title {
		justify-content: center;
	}
	.sa-banner-btn {
		display: inline-block;
		background: #fff;
		color: #E4032E;
		font-weight: 700;
		font-size: 13.5px;
		padding: 10px 26px;
		border-radius: 8px;
		text-decoration: none;
		transition: transform .15s ease, box-shadow .15s ease;
	}
	.sa-banner-btn:hover {
		transform: translateY(-2px);
		box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
	}
	.sa-banner-nav {
		display: flex;
		gap: 10px;
		margin-top: 4px;
	}
	.sa-nav-btn {
		width: 34px;
		height: 34px;
		border-radius: 50%;
		border: none;
		background: rgba(255, 255, 255, .25);
		color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
		cursor: pointer;
		transition: background-color .2s ease, transform .15s ease;
	}
	.sa-nav-btn:hover {
		background: rgba(255, 255, 255, .45);
		transform: scale(1.08);
	}
	.sa-wrapper.sa-has-banner .sa-slider-track {
		flex: 1;
		min-width: 0; /* برای اجازه‌دادن به overflow صحیح داخل فلکس */
		background: linear-gradient(160deg, var(--sa-products-bg-start, #fff), var(--sa-products-bg-end, #fff));
		border-radius: var(--sa-products-radius, 16px);
		padding: 24px 20px;
		box-shadow: 0 3px 14px rgba(0, 0, 0, .06);
	}
}

/* ================= ریسپانسیو =================
   توجه: عرض کارت‌ها دیگر اینجا هاردکد نیست — از کنترل ریسپانسیو
   «تعداد کارت‌های قابل‌مشاهده» در پنل المنتور (تب محتوا) مدیریت می‌شود.
*/
@media (max-width: 767px) {
	.sa-wrapper {
		padding: 12px 10px 16px;
		border-radius: 10px !important;
	}
	.sa-title {
		font-size: 17px;
	}
	.sa-slider-track {
		gap: 12px;
	}
	.sa-card {
		border-radius: 14px;
	}
	.sa-img-wrap {
		height: 190px;
	}
	.sa-card-body {
		padding: 14px 14px 16px;
	}
	.sa-card-body h3 {
		font-size: 14px;
		min-height: 44px;
	}
	.sa-new-price {
		font-size: 17px;
	}
	.sa-add-cart-btn {
		font-size: 13px;
		padding: 10px 10px;
	}
	.sa-timer-box {
		min-width: 28px;
		font-size: 12px;
		padding: 3px 5px;
	}
	.sa-quick-view-btn {
		padding: 8px 5px;
	}
	.sa-wishlist-btn {
		width: 28px;
		height: 28px;
	}
	.sa-qv-inner {
		grid-template-columns: 1fr;
	}
	.sa-qv-image {
		border-radius: 16px 16px 0 0;
		min-height: 200px;
		padding: 18px;
	}
	.sa-qv-details {
		padding: 20px;
	}
}
