/**
 * MyPlug Sales Booster - Gift module
 * دکمه هدیه + مودال انتخاب جعبه و گیفت (موبایل‌محور)
 * myplug.ir
 */

/* ==========================================================
 *  دکمه باز کردن
 * ========================================================== */

.myplug-sb .myplug-gift-btn {
	display: flex !important;
	align-items: center;
	gap: 10px;
	width: 100%;
	margin: 0;
	padding: 11px 12px;
	border-radius: var(--sb-radius, 10px);
	font-family: inherit;
	font-size: var(--sb-fs, 14px);
	line-height: 1.6;
	text-align: right;
	cursor: pointer;
	position: relative;
	overflow: hidden;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	-webkit-tap-highlight-color: transparent;
	box-shadow: none;
	text-transform: none;
	text-decoration: none;
	letter-spacing: normal;
	min-height: 0;
	height: auto;
}

.myplug-sb .myplug-gift-btn:active {
	transform: scale(0.985);
}

.myplug-sb .myplug-gift-btn.mg-style-soft {
	background: #fdf2f6;
	border: 1px solid #f5c6d8;
	color: #9d174d;
}

.myplug-sb .myplug-gift-btn.mg-style-solid {
	background: linear-gradient(135deg, #db2777, #9d174d);
	border: 0;
	color: #fff;
}

.myplug-sb .myplug-gift-btn.mg-style-outline {
	background: transparent;
	border: 1.5px dashed #db2777;
	color: #9d174d;
}

.myplug-sb .myplug-gift-btn .mgb-ico {
	flex: 0 0 auto;
	font-size: calc(var(--sb-ico, 20px) + 2px);
	line-height: 1;
}

.myplug-sb .myplug-gift-btn .mgb-txt {
	flex: 1 1 auto;
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.myplug-sb .myplug-gift-btn .mgb-txt b {
	font-weight: 700;
	color: inherit;
}

.myplug-sb .myplug-gift-btn .mgb-txt small {
	font-size: calc(var(--sb-fs, 14px) - 3px);
	opacity: 0.75;
}

.myplug-sb .myplug-gift-btn .mgb-arrow {
	flex: 0 0 auto;
	font-size: 24px;
	line-height: 1;
	opacity: 0.45;
}

.myplug-sb .myplug-gift-btn .mgb-badge {
	flex: 0 0 auto;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 99px;
	background: #db2777;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.myplug-sb .myplug-gift-btn .mgb-badge[hidden] {
	display: none !important;
}

.myplug-sb .myplug-gift-btn.mg-style-solid .mgb-badge {
	background: rgba(255, 255, 255, 0.28);
}

/* ==========================================================
 *  مودال
 * ========================================================== */

.myplug-gift-modal {
	--mg-accent: #db2777;
	--mg-ink: #18181b;
	--mg-muted: #71717a;
	--mg-line: #e4e4e7;
	position: fixed;
	inset: 0;
	z-index: 999999;
	direction: rtl;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.8;
	color: var(--mg-ink);
}

.myplug-gift-modal[hidden] {
	display: none !important;
}

.myplug-gift-modal * {
	box-sizing: border-box;
}

.myplug-gift-modal .mg-overlay {
	position: absolute;
	inset: 0;
	background: rgba(9, 9, 11, 0.55);
	opacity: 0;
	transition: opacity 0.25s ease;
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.myplug-gift-modal.is-open .mg-overlay {
	opacity: 1;
}

.myplug-gift-modal .mg-sheet {
	position: absolute;
	right: 0;
	left: 0;
	bottom: 0;
	display: flex;
	flex-direction: column;
	max-height: 88vh;
	max-height: 88dvh;
	background: #fff;
	border-radius: 22px 22px 0 0;
	box-shadow: 0 -8px 40px rgba(9, 9, 11, 0.25);
	transform: translateY(100%);
	transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
	overflow: hidden;
}

.myplug-gift-modal.is-open .mg-sheet {
	transform: translateY(0);
}

.myplug-gift-modal .mg-sheet::before {
	content: "";
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	height: 3px;
	background: linear-gradient(90deg, #db2777, #f59e0b, #db2777);
}

/* دستگیره کشیدن */
.myplug-gift-modal .mg-grip {
	flex: 0 0 auto;
	display: block;
	width: 100%;
	height: 26px;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: grab;
	position: relative;
	touch-action: none;
}

.myplug-gift-modal .mg-grip::after {
	content: "";
	position: absolute;
	top: 11px;
	right: 50%;
	transform: translateX(50%);
	width: 44px;
	height: 5px;
	border-radius: 99px;
	background: #d4d4d8;
}

/* سربرگ */
.myplug-gift-modal .mg-head {
	flex: 0 0 auto;
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 2px 16px 12px;
	border-bottom: 1px solid var(--mg-line);
}

.myplug-gift-modal .mg-head-txt {
	flex: 1;
	min-width: 0;
}

.myplug-gift-modal .mg-head h3 {
	margin: 0;
	padding: 0;
	font-size: 16px;
	font-weight: 700;
	line-height: 1.6;
	color: var(--mg-ink);
}

.myplug-gift-modal .mg-head p {
	margin: 2px 0 0;
	padding: 0;
	font-size: 12px;
	color: var(--mg-muted);
	line-height: 1.7;
}

.myplug-gift-modal .mg-x {
	flex: 0 0 auto;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 50%;
	background: #f4f4f5;
	color: #52525b;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

/* تب‌ها */
.myplug-gift-modal .mg-tabs {
	flex: 0 0 auto;
	display: flex;
	gap: 8px;
	padding: 12px 16px;
	overflow-x: auto;
	overflow-y: hidden;
	scrollbar-width: none;
	-webkit-overflow-scrolling: touch;
	border-bottom: 1px solid var(--mg-line);
}

.myplug-gift-modal .mg-tabs::-webkit-scrollbar {
	display: none;
}

.myplug-gift-modal .mg-tab {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 8px 14px;
	border: 1px solid var(--mg-line);
	border-radius: 99px;
	background: #fafafa;
	color: #3f3f46;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	white-space: nowrap;
	transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.myplug-gift-modal .mg-tab.is-active {
	background: var(--mg-accent);
	border-color: var(--mg-accent);
	color: #fff;
}

.myplug-gift-modal .mg-tab-count {
	min-width: 18px;
	height: 18px;
	padding: 0 5px;
	border-radius: 99px;
	background: rgba(0, 0, 0, 0.12);
	font-size: 11px;
	font-style: normal;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.myplug-gift-modal .mg-tab.is-active .mg-tab-count {
	background: rgba(255, 255, 255, 0.3);
}

.myplug-gift-modal .mg-tab-count[hidden] {
	display: none !important;
}

/* بدنه */
.myplug-gift-modal .mg-body {
	flex: 1 1 auto;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
	padding: 14px 16px 4px;
}

.myplug-gift-modal .mg-panel {
	display: none;
}

.myplug-gift-modal .mg-panel.is-active {
	display: block;
	animation: mg-fade 0.22s ease both;
}

@keyframes mg-fade {
	from { opacity: 0; transform: translateY(5px); }
	to { opacity: 1; transform: translateY(0); }
}

.myplug-gift-modal .mg-help {
	margin: 0 0 12px;
	padding: 9px 11px;
	border-radius: 10px;
	background: #fffbeb;
	border: 1px solid #fde68a;
	color: #78350f;
	font-size: 12px;
	line-height: 1.8;
}

.myplug-gift-modal .mg-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
	gap: 10px;
}

/* کارت آیتم */
.myplug-gift-modal .mg-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 8px;
	border: 1.5px solid var(--mg-line);
	border-radius: 14px;
	background: #fff;
	cursor: pointer;
	transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.12s ease;
	-webkit-tap-highlight-color: transparent;
}

.myplug-gift-modal .mg-card:active {
	transform: scale(0.98);
}

.myplug-gift-modal .mg-card.is-selected {
	border-color: var(--mg-accent);
	box-shadow: 0 0 0 3px rgba(219, 39, 119, 0.12);
}

.myplug-gift-modal .mg-check {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	pointer-events: none;
}

.myplug-gift-modal .mg-check:focus-visible + .mg-thumb {
	outline: 2px solid var(--mg-accent);
	outline-offset: 2px;
}

.myplug-gift-modal .mg-thumb {
	display: block;
	width: 100%;
	aspect-ratio: 1 / 1;
	border-radius: 10px;
	overflow: hidden;
	background: #f4f4f5;
}

.myplug-gift-modal .mg-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	border-radius: 10px;
}

.myplug-gift-modal .mg-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	min-width: 0;
}

.myplug-gift-modal .mg-name {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.6;
	color: var(--mg-ink);
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.myplug-gift-modal .mg-desc {
	font-size: 11px;
	color: var(--mg-muted);
	line-height: 1.7;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.myplug-gift-modal .mg-price {
	margin-top: 2px;
	font-size: 13px;
	font-weight: 700;
	color: var(--mg-accent);
}

.myplug-gift-modal .mg-price del {
	display: none;
}

.myplug-gift-modal .mg-free {
	font-style: normal;
	color: #059669;
}

/* رنگ‌بندی / تنوع‌ها */
.myplug-gift-modal .mg-vars {
	display: flex;
	flex-wrap: wrap;
	gap: 5px;
	margin-top: -2px;
	max-height: 62px;
	overflow-y: auto;
	overscroll-behavior: contain;
}

.myplug-gift-modal .mg-var {
	flex: 0 0 auto;
	padding: 4px 9px;
	border: 1px solid var(--mg-line);
	border-radius: 8px;
	background: #fafafa;
	color: #52525b;
	font-family: inherit;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.6;
	cursor: pointer;
	white-space: nowrap;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
	transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.myplug-gift-modal .mg-var:hover {
	border-color: #a1a1aa;
}

.myplug-gift-modal .mg-var.is-on {
	background: rgba(219, 39, 119, 0.1);
	border-color: var(--mg-accent);
	color: var(--mg-accent);
}

.myplug-gift-modal .mg-card:not(.is-selected) .mg-var.is-on {
	background: #fafafa;
	border-color: var(--mg-line);
	color: #52525b;
}

.myplug-gift-modal .mg-tick {
	position: absolute;
	top: 14px;
	right: 14px;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: var(--mg-accent);
	color: #fff;
	font-size: 14px;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: scale(0.5);
	transition: opacity 0.18s ease, transform 0.18s ease;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.myplug-gift-modal .mg-card.is-selected .mg-tick {
	opacity: 1;
	transform: scale(1);
}

/* شمارنده تعداد */
.myplug-gift-modal .mg-qty {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 4px;
	padding: 3px;
	border-radius: 10px;
	background: #f4f4f5;
}

.myplug-gift-modal .mg-qty[hidden] {
	display: none !important;
}

.myplug-gift-modal .mg-qty button {
	width: 28px;
	height: 28px;
	border: 0;
	border-radius: 8px;
	background: #fff;
	color: var(--mg-ink);
	font-size: 16px;
	font-family: inherit;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.myplug-gift-modal .mg-qty button:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.myplug-gift-modal .mg-qty i {
	flex: 1;
	text-align: center;
	font-style: normal;
	font-weight: 700;
	font-size: 13px;
}

/* کارت تبریک */
.myplug-gift-modal .mg-note {
	position: relative;
	margin: 14px 0 6px;
	padding: 12px;
	border: 1px dashed var(--mg-line);
	border-radius: 12px;
	background: #fafafa;
}

.myplug-gift-modal .mg-note label {
	display: block;
	margin-bottom: 6px;
	font-size: 12px;
	font-weight: 700;
	color: #3f3f46;
}

.myplug-gift-modal .mg-note textarea {
	width: 100%;
	min-height: 58px;
	padding: 9px 10px;
	border: 1px solid var(--mg-line);
	border-radius: 9px;
	background: #fff;
	font-family: inherit;
	font-size: 13px;
	line-height: 1.9;
	color: var(--mg-ink);
	resize: vertical;
	box-shadow: none;
}

.myplug-gift-modal .mg-note textarea:focus {
	outline: none;
	border-color: var(--mg-accent);
}

.myplug-gift-modal .mg-note-count {
	position: absolute;
	left: 20px;
	bottom: 20px;
	font-size: 11px;
	color: #a1a1aa;
	direction: ltr;
}

.myplug-gift-modal .mg-foot-hint {
	margin: 10px 0 6px;
	font-size: 11px;
	color: #a1a1aa;
	text-align: center;
}

/* پاورقی */
.myplug-gift-modal .mg-foot {
	flex: 0 0 auto;
	padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
	border-top: 1px solid var(--mg-line);
	background: #fff;
	box-shadow: 0 -4px 16px rgba(9, 9, 11, 0.06);
}

.myplug-gift-modal .mg-sum {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 8px;
	margin-bottom: 10px;
	font-size: 13px;
}

.myplug-gift-modal .mg-sum-label {
	color: var(--mg-muted);
}

.myplug-gift-modal .mg-sum-label i {
	font-style: normal;
	font-weight: 700;
	color: var(--mg-ink);
}

.myplug-gift-modal .mg-sum-total {
	font-size: 15px;
	font-weight: 700;
	color: var(--mg-accent);
}

.myplug-gift-modal .mg-cta {
	display: block;
	width: 100%;
	min-height: 48px;
	border: 0;
	border-radius: 12px;
	background: var(--mg-accent);
	color: #fff;
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.12s ease, opacity 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.myplug-gift-modal .mg-cta:active {
	transform: scale(0.99);
}

.myplug-gift-modal .mg-cta.is-busy {
	opacity: 0.7;
	pointer-events: none;
}

.myplug-gift-modal .mg-skip {
	display: block;
	width: 100%;
	margin-top: 8px;
	padding: 6px;
	border: 0;
	background: transparent;
	color: var(--mg-muted);
	font-family: inherit;
	font-size: 13px;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

/* پیام کوتاه */
.myplug-gift-modal .mg-toast {
	position: absolute;
	bottom: 96px;
	right: 50%;
	transform: translateX(50%) translateY(8px);
	max-width: 88%;
	padding: 9px 16px;
	border-radius: 99px;
	background: rgba(24, 24, 27, 0.92);
	color: #fff;
	font-size: 13px;
	opacity: 0;
	transition: opacity 0.22s ease, transform 0.22s ease;
	pointer-events: none;
	z-index: 5;
}

.myplug-gift-modal .mg-toast.is-shown {
	opacity: 1;
	transform: translateX(50%) translateY(0);
}

.myplug-gift-modal .mg-toast[hidden] {
	display: none !important;
}

/* قفل اسکرول صفحه */
html.mg-locked,
body.mg-locked {
	overflow: hidden !important;
}

/* ==========================================================
 *  دسکتاپ
 * ========================================================== */

@media (min-width: 768px) {
	.myplug-gift-modal .mg-sheet {
		top: 50%;
		bottom: auto;
		right: 50%;
		left: auto;
		width: min(640px, calc(100% - 48px));
		max-height: 84vh;
		border-radius: 18px;
		transform: translate(50%, -46%) scale(0.97);
		opacity: 0;
		transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease;
	}

	.myplug-gift-modal.is-open .mg-sheet {
		transform: translate(50%, -50%) scale(1);
		opacity: 1;
	}

	.myplug-gift-modal .mg-grip {
		display: none;
	}

	.myplug-gift-modal .mg-head {
		padding-top: 16px;
	}

	.myplug-gift-modal .mg-grid {
		grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
	}

	.myplug-gift-modal .mg-foot {
		display: flex;
		align-items: center;
		gap: 14px;
	}

	.myplug-gift-modal .mg-sum {
		flex: 1;
		flex-direction: column;
		align-items: flex-start;
		gap: 0;
		margin-bottom: 0;
	}

	.myplug-gift-modal .mg-cta {
		width: auto;
		min-width: 220px;
		padding-inline: 26px;
		padding-left: 26px;
		padding-right: 26px;
	}

	.myplug-gift-modal .mg-skip {
		width: auto;
		margin-top: 0;
		order: -1;
	}
}

@media (prefers-reduced-motion: reduce) {
	.myplug-gift-modal .mg-sheet,
	.myplug-gift-modal .mg-overlay,
	.myplug-gift-modal .mg-panel.is-active,
	.myplug-gift-modal .mg-tick {
		transition: none !important;
		animation: none !important;
	}
}
