/* ویجت افزودن به سبد — افزونه سبد سریع الماسارا */

.amfc-atc {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/*
 * صفت hidden باید همیشه ببرد؛ بدون این قانون، هر عنصری که display از CSS
 * نویسنده می‌گیرد (مثل flex) با hidden مخفی نمی‌شود.
 */
.amfc-atc [hidden] {
	display: none !important;
}

.amfc-atc__variations {
	display: flex;
	flex-direction: column;
	gap: 16px;
	margin: 0;
}

/* نوار: اطلاعیه + بدنه (قیمت/ردیف افزودن/کنترل «در سبد») — در موبایلِ چسبان fixed می‌شود */
.amfc-atc__bar {
	display: flex;
	flex-direction: column;
	margin: 0;
}

.amfc-atc__bar-main {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.amfc-atc__notice {
	display: none;
}

/* ---------- واریانت‌ها ---------- */

.amfc-atc__attrs {
	display: grid;
	grid-template-columns: 1fr;
	gap: 12px;
}

.amfc-atc__attr {
	--amfc-arrow: #16265c;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.amfc-atc__attr-label {
	font-weight: 700;
	color: #16265c;
}

.amfc-atc__attr select {
	width: 100%;
	height: 52px;
	padding: 0 16px;
	border: 0;
	border-radius: 10px;
	background-color: #eef1f9;
	color: #16265c;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	/* فلش سفارشی سمت مقابل متن (RTL) */
	background-image: linear-gradient(45deg, transparent 50%, var(--amfc-arrow) 50%), linear-gradient(135deg, var(--amfc-arrow) 50%, transparent 50%);
	background-position: calc(0% + 18px) center, calc(0% + 18px + var(--amfc-arrow-s, 6px)) center;
	background-size: var(--amfc-arrow-s, 6px) var(--amfc-arrow-s, 6px), var(--amfc-arrow-s, 6px) var(--amfc-arrow-s, 6px);
	background-repeat: no-repeat;
	text-align: center;
	text-align-last: center;
}

/* نمایش/مخفی «حذف انتخاب» را خود WooCommerce با visibility مدیریت می‌کند */
.amfc-atc__reset {
	align-self: flex-start;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 6px 14px;
	border-radius: 8px;
	background-color: rgba(229, 72, 77, 0.1);
	color: #e5484d;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
}

/* دکمه افزودن تا انتخاب کامل واریانت غیرفعال (کلاس بومی WooCommerce) */
.amfc-atc .woocommerce-variation-add-to-cart-disabled .amfc-atc__btn {
	opacity: 0.45;
	pointer-events: none;
}

/* ----------------------------------------------------------------------
 * جعبه قیمت — ساختار دیوایدی:
 *   price-box (اصلی) › price-stack (۱، پیش‌فرض ستونی: قیمت پیشین روی فعلی)
 *     › price-old-group (۲: بج تخفیف + قیمت خط‌خورده، پیش‌فرض کنار هم)
 *     › price--now (قیمت فعلی)
 * جهت/توزیع/تراز/شکاف/wrap هرکدام از تب استایل → «چیدمان» می‌آید؛ مقادیر
 * زیر فقط fallback پیش از رندر کنترل‌های المنتور است.
 * ---------------------------------------------------------------------- */

.amfc-atc__price-box:empty {
	display: none;
}

.amfc-atc__price-stack {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 2px;
}

.amfc-atc__price-old-group {
	display: flex;
	align-items: center;
	gap: 6px;
}

.amfc-atc__discount {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	padding: 3px 8px;
	border-radius: 8px;
	background-color: #e6123d;
	color: #fff;
	font-size: 13px;
	font-weight: 800;
}

.amfc-atc__discount-icon {
	display: inline-flex;
	color: inherit;
}

.amfc-atc__discount-icon svg {
	width: var(--amfc-disc-icon, 0.9em);
	height: var(--amfc-disc-icon, 0.9em);
	display: block;
}

/* هر قیمت یک بلوک مستقل عدد+واحد است؛ استایل کادر (پدینگ/پس‌زمینه/حاشیه) از پنل می‌آید */
.amfc-atc__price {
	display: inline-flex;
	align-items: baseline;
	gap: 3px;
}

.amfc-atc__price--old {
	color: #9aa3b2;
	font-size: 15px;
	text-decoration: none; /* خط‌خوردگی با کنترل «خط‌خورده» پنل اعمال می‌شود */
}

.amfc-atc__price--now {
	color: #16265c;
	font-size: 28px;
	font-weight: 800;
}

.amfc-atc__price--now .amfc-atc__unit {
	font-size: 14px;
	font-weight: 600;
}

.amfc-atc__price--old .amfc-atc__unit {
	font-size: 12px;
}

/* ---------- ردیف افزودن ---------- */

.amfc-atc__addrow {
	display: flex;
	align-items: stretch;
	gap: 12px;
}

.amfc-atc__btn {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 16px 24px;
	border: 1px solid transparent;
	border-radius: 10px;
	background-color: #16265c;
	color: #fff;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	text-decoration: none;
	transition: all 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
}

.amfc-atc__btn-in {
	display: inline-flex;
	align-items: center;
	gap: var(--amfc-atc-icongap, 8px);
}

.amfc-atc__btn.is-loading {
	pointer-events: none;
}

.amfc-atc__btn-loader {
	width: var(--amfc-btn-loader-size, 1.3em);
	height: var(--amfc-btn-loader-size, 1.3em);
	border-radius: 50%;
	background: conic-gradient(currentColor 0deg, transparent 300deg);
	-webkit-mask: radial-gradient(closest-side, transparent 62%, #000 63%);
	mask: radial-gradient(closest-side, transparent 62%, #000 63%);
	animation: amfc-spin 0.7s linear infinite;
}

.amfc-atc__icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.amfc-atc__icon svg { width: var(--amfc-atc-icon, 20px); height: var(--amfc-atc-icon, 20px); display: block; }
.amfc-atc__icon img { width: var(--amfc-atc-icon, 20px); height: auto; display: block; }

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

/* ---------- انتخابگر تعداد (افزودن) ---------- */

.amfc-atc__qty {
	display: inline-flex;
	align-items: center;
	height: 52px;
	border: 1px solid #e4e7ee;
	border-radius: 10px;
	overflow: hidden;
	background: #fff;
	flex-shrink: 0;
}

.amfc-atc__step {
	width: 40px;
	height: 100%;
	border: 0;
	background: none;
	color: #16265c;
	font-size: 20px;
	cursor: pointer;
}

.amfc-atc__qty-input {
	width: 46px;
	height: 100%;
	border: 0;
	background: none;
	text-align: center;
	font: inherit;
	font-weight: 700;
	color: #16265c;
	-moz-appearance: textfield;
	appearance: textfield;
}

.amfc-atc__qty-input::-webkit-outer-spin-button,
.amfc-atc__qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- حالت «در سبد شما» ---------- */

.amfc-atc--incart .amfc-atc__addrow { display: none; }

.amfc-atc__incart {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.amfc-atc__incart-info {
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.amfc-atc__incart-title {
	color: #5b6b8c;
	font-size: 16px;
	font-weight: 700;
}

.amfc-atc__incart-link {
	color: #0077db;
	font-size: 14px;
	text-decoration: none;
}

.amfc-atc__control {
	display: inline-flex;
	align-items: center;
	height: 60px;
	padding: 0 6px;
	border: 1px solid #eef0f6;
	border-radius: 14px;
	background: #fff;
	box-shadow: 0 4px 20px rgba(16, 24, 40, 0.08);
}

.amfc-atc__ctl {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 100%;
	border: 0;
	background: none;
	cursor: pointer;
	font-size: 24px;
	line-height: 1;
	transition: opacity 0.2s ease;
}

.amfc-atc__ctl--inc { color: #e6123d; }
.amfc-atc__ctl-minus { color: #16265c; }
.amfc-atc__ctl-trash { color: #e6123d; display: none; }

/* تعداد ۱: دکمه کاهش → آیکون حذف */
.amfc-atc__control.is-single .amfc-atc__ctl-minus { display: none; }
.amfc-atc__control.is-single .amfc-atc__ctl-trash { display: inline-flex; }

/* حداکثر: دکمه + کم‌رنگ و غیرقابل کلیک */
.amfc-atc__control.is-max .amfc-atc__ctl--inc {
	opacity: 0.35;
	pointer-events: none;
}

.amfc-atc__ctl-num {
	display: inline-flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	gap: 2px;
}

.amfc-atc__ctl-value {
	font-size: 18px;
	font-weight: 800;
	color: #16265c;
	line-height: 1;
}

.amfc-atc__ctl-max {
	font-size: 10px;
	font-weight: 600;
	color: #9aa3b2;
	line-height: 1;
}

/* لودر دایره‌ای تغییر تعداد: رنگ پررنگ از انتها حول ۳۶۰ درجه تخلیه می‌شود.
   زاویه با @property نرم انیمیت می‌شود؛ مرورگر قدیمی fallback چرخش دارد. */
@property --amfc-ang {
	syntax: '<angle>';
	inherits: false;
	initial-value: 360deg;
}

.amfc-atc__ctl-loader {
	--amfc-ang: 360deg;
	width: 22px;
	height: 22px;
	border-radius: 50%;
	color: #16265c;
	background: conic-gradient(currentColor var(--amfc-ang), rgba(0, 0, 0, 0.08) 0deg);
	-webkit-mask: radial-gradient(closest-side, transparent 62%, #000 63%);
	mask: radial-gradient(closest-side, transparent 62%, #000 63%);
	animation: amfc-deplete 0.9s linear infinite, amfc-spin 0.9s linear infinite;
}

@keyframes amfc-deplete {
	from { --amfc-ang: 360deg; }
	to   { --amfc-ang: 0deg; }
}

/* پیام ادیتور */
.amfc-notice {
	padding: 16px;
	border: 1px dashed #c00;
	border-radius: 6px;
	color: #c00;
	font-size: 13px;
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	.amfc-atc__btn-loader,
	.amfc-atc__ctl-loader { animation-duration: 0.01ms; }
}

/* ---------- نوار چسبان موبایل ---------- */
/* کل نوار (قیمت + اکشن + اطلاعیه) fixed می‌شود؛ انتخابگرهای واریانت داخل
   جریان صفحه می‌مانند. ظاهر از متغیرهای CSS پنل می‌آید و دسکتاپ اثری نمی‌گیرد. */
@media (max-width: 767px) {
	.amfc-atc--stickym .amfc-atc__bar {
		position: fixed;
		left: var(--amfc-bar-x, 0px);
		right: var(--amfc-bar-x, 0px);
		bottom: var(--amfc-bar-b, 0px);
		z-index: var(--amfc-bar-z, 990);
		background: var(--amfc-bar-bg, #fff);
		border-top: 1px solid var(--amfc-bar-border, transparent);
		border-radius: var(--amfc-bar-radius, 0px);
		box-shadow: var(--amfc-bar-shadow, 0 -8px 28px rgba(0, 0, 0, 0.12));
		padding: var(--amfc-bar-pt, 10px) var(--amfc-bar-pr, 14px)
			calc(var(--amfc-bar-pb, 10px) + env(safe-area-inset-bottom, 0px))
			var(--amfc-bar-pl, 14px);
	}

	/* بدنه نوار: قیمت سمت راست، اکشن سمت چپ (RTL) */
	.amfc-atc--stickym .amfc-atc__bar-main {
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		gap: 12px;
	}

	.amfc-atc--stickym .amfc-atc__bar-main .amfc-atc__addrow,
	.amfc-atc--stickym .amfc-atc__bar-main .amfc-atc__incart {
		flex: 1;
		justify-content: flex-end;
		margin: 0;
	}

	/* در نوار، متن «در سبد شما / مشاهده سبد» جایی ندارد؛ اطلاعیه جایگزین است */
	.amfc-atc--stickym .amfc-atc__bar-main .amfc-atc__incart-info {
		display: none;
	}

	/* دو طبقه فشرده مثل دیزاین (بج+قیمت قدیم بالا، قیمت نهایی پایین) به‌صورت
	   پیش‌فرض از چیدمان ستونیِ price-stack می‌آید؛ اینجا فقط جمع‌نشدنش را تضمین می‌کنیم */
	.amfc-atc--stickym .amfc-atc__bar-main .amfc-atc__price-box {
		flex-shrink: 0;
	}

	/* اطلاعیه «کالا اضافه شده»: ورود از پایین به بالا، خروج برعکس */
	.amfc-atc--stickym .amfc-atc__notice {
		display: block;
		overflow: hidden;
		max-height: 0;
		opacity: 0;
		transform: translateY(16px);
		border-bottom: 1px solid transparent;
		transition: max-height 0.35s ease, opacity 0.3s ease, transform 0.35s ease,
			padding 0.35s ease, margin 0.35s ease, border-color 0.35s ease;
	}

	.amfc-atc--stickym .amfc-atc__notice.is-open {
		max-height: 120px;
		opacity: 1;
		transform: translateY(0);
		padding-bottom: 12px;
		margin-bottom: 12px;
		border-bottom-color: #eceef3;
	}

	.amfc-atc--stickym .amfc-atc__notice-in {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 10px;
		padding: 10px 14px;
		border-radius: var(--amfc-ntc-radius, 18px);
		background: var(--amfc-ntc-bg, #dcebd9);
		color: var(--amfc-ntc-color, #2f7d33);
		font-weight: 800;
	}

	.amfc-atc__notice-msg {
		display: inline-flex;
		align-items: center;
		gap: 8px;
	}

	.amfc-atc__notice-link {
		display: inline-flex;
		align-items: center;
		gap: 6px;
		padding: 8px 16px;
		border-radius: 999px;
		background: var(--amfc-ntc-link-bg, #fff);
		color: var(--amfc-ntc-link, #1c1c1c);
		font-size: 13px;
		font-weight: 700;
		text-decoration: none;
		box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
	}

	/* جای خالی انتهای صفحه تا محتوا زیر نوار دفن نشود؛ JS مقدارش را ست می‌کند */
	body.amfc-stickym-pad {
		padding-bottom: var(--amfc-sticky-pad, 0px) !important;
	}
}
