/* MYT Shipping Estimate — frontend
   همه‌ی مقادیر پیش‌فرض با متغیرهای CSS تعریف شده‌اند؛ از تب «استایل» ویجت المنتور قابل تغییرند. */

.mytse {
	--mytse-primary: #0a7d44;
	--mytse-surface: #fff;
	--mytse-border: #d5d5d5;
	--mytse-muted: #9a9a9a;
	--mytse-text: #222;
	--mytse-ctl-bg: #fff;
	--mytse-ctl-bg-off: #e6e6e6;
	--mytse-danger: #d33;
	direction: rtl;
	color: var(--mytse-text);
	font-size: 14px;
	line-height: 1.5;
}
.mytse *,
.mytse *::before,
.mytse *::after { box-sizing: border-box; }
.mytse [hidden] { display: none !important; }

/* ---------- شبکه (عرض هر فیلد با متغیر --w بر حسب درصد) ---------- */
.mytse-grid {
	--mytse-cg: 20px;
	--mytse-rg: 20px;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	column-gap: var(--mytse-cg);
	row-gap: var(--mytse-rg);
}
.mytse-field {
	--w: 50;
	position: relative;
	flex: 1 1 calc(var(--w) * 1% - var(--mytse-cg) * (100 - var(--w)) / 100); /* ردیف همیشه کامل پر می‌شود */
	min-width: min(100%, 230px); /* در کانتینر باریک، فیلدها به ردیف بعد می‌روند */
	max-width: 100%;
}
.mytse-field.mytse-t-location { min-width: min(100%, 330px); }
.mytse-field.mytse-t-radio { min-width: min(100%, 300px); }
.mytse-field.mytse-t-number { min-width: min(100%, 250px); }

/* ---------- فیلد: عنوان بالا، کنترل پایین ---------- */
.mytse-field {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	align-content: start;
	gap: 8px 0;
}
.mytse-head {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: 22px;
}
.mytse-label {
	font-size: 13px;
	font-weight: 700;
	line-height: 1.4;
	margin: 0;
	padding: 0;
}
.mytse-req { color: var(--mytse-danger); margin-inline-start: 3px; }
.mytse-control { min-width: 0; }

/* حالت اختیاری: عنوان کنار فیلد با عرض ثابت (همه‌ی کنترل‌ها هم‌تراز می‌شوند) */
.mytse-label-inline .mytse-field {
	grid-template-columns: var(--mytse-lw, 110px) minmax(0, 1fr);
	align-items: center;
	gap: 0 16px;
}
.mytse-label-inline .mytse-field > .mytse-error { grid-column: 2; }
.mytse-label-inline .mytse-label { min-width: 0; font-size: 14px; }
.mytse-label-inline .mytse-help-pop { top: 100%; }

.mytse-field.is-hidden { display: none; }

/* ---------- کادر کنترل‌ها ---------- */
.mytse-ctl {
	position: relative;
	display: flex;
	align-items: center;
	min-height: 52px;
	min-width: 0;
	background-color: var(--mytse-ctl-bg);
	border: 1px solid var(--mytse-border);
	border-radius: 6px;
	transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.mytse-ctl:focus-within { border-color: var(--mytse-primary); }

.mytse-loc {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 12px;
}

/* انتخاب‌گر (select) */
.mytse .mytse-ctl select {
	flex: 1 1 auto;
	align-self: stretch;
	width: 100%;
	min-width: 0;
	height: auto;
	margin: 0;
	padding: 0 14px;
	padding-inline-end: 38px;
	border: 0 !important;
	border-radius: inherit;
	background: transparent !important;
	box-shadow: none !important;
	outline: 0;
	font: inherit;
	color: #555;
	cursor: pointer;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	text-overflow: ellipsis;
}
.mytse-ctl-select::after {
	content: "";
	position: absolute;
	inset-inline-end: 16px;
	top: 50%;
	width: 8px;
	height: 8px;
	border: solid var(--mytse-muted);
	border-width: 0 1.5px 1.5px 0;
	transform: translateY(-70%) rotate(45deg);
	pointer-events: none;
}

/* عنوان شناور روی خط کادر */
.mytse-legend {
	position: absolute;
	top: 0;
	inset-inline-end: 14px;
	z-index: 1;
	padding: 0 6px;
	transform: translateY(-50%);
	font-size: 12px;
	line-height: 1;
	color: var(--mytse-muted);
	background: linear-gradient(to bottom, var(--mytse-surface) 50%, var(--mytse-ctl-bg) 50%);
	pointer-events: none;
}

/* عددی با واحد */
.mytse .mytse-ctl input[type="text"] {
	flex: 1 1 auto;
	align-self: stretch;
	min-width: 70px;
	width: 100%;
	height: auto;
	margin: 0;
	padding: 0 14px;
	border: 0 !important;
	border-radius: inherit;
	background: transparent !important;
	box-shadow: none !important;
	outline: 0;
	font: inherit;
	color: var(--mytse-text);
	text-align: start;
}
.mytse-unit {
	align-self: stretch;
	display: flex;
	align-items: center;
	flex: none;
	padding: 0 14px;
	background: rgba(0, 0, 0, .025);
	white-space: nowrap;
	color: var(--mytse-muted);
	border-inline-start: 1px solid var(--mytse-border);
}

/* رادیو و تیک (آیکن با mask تا رنگ‌شان از CSS/المنتور قابل تغییر باشد) */
.mytse-ctl-radio,
.mytse-ctl-check { padding: 5px; gap: 6px; flex-wrap: wrap; }
.mytse-radio,
.mytse-check {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0;
	cursor: pointer;
}
.mytse-radio {
	flex: 1 1 0;
	min-width: 0;
	min-height: 40px;
	padding: 0 8px;
	gap: 6px;
	border-radius: 4px;
	white-space: nowrap;
	transition: background-color .15s ease;
}
.mytse-check { min-height: 40px; padding: 0 12px; }
.mytse-radio:hover { background: rgba(0, 0, 0, .03); }
.mytse-radio:has(input:checked) { background: color-mix(in srgb, var(--mytse-primary) 10%, transparent); }
.mytse-radio input,
.mytse-check input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	pointer-events: none;
}
.mytse-radio-ui,
.mytse-check-ui {
	flex: none;
	width: 20px;
	height: 20px;
	background-color: var(--mytse-muted);
	-webkit-mask-repeat: no-repeat;
	mask-repeat: no-repeat;
	-webkit-mask-position: center;
	mask-position: center;
	-webkit-mask-size: contain;
	mask-size: contain;
	transition: background-color .15s ease;
}
.mytse-radio-ui {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='14' cy='14' r='12'/%3E%3Cpath d='M8 14h12'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='14' cy='14' r='12'/%3E%3Cpath d='M8 14h12'/%3E%3C/svg%3E");
}
.mytse-radio input:checked + .mytse-radio-ui {
	background-color: var(--mytse-primary);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='14' cy='14' r='12'/%3E%3Cpath d='M8 14.5l4 4 8-9'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='14' cy='14' r='12'/%3E%3Cpath d='M8 14.5l4 4 8-9'/%3E%3C/svg%3E");
}
.mytse-check-ui {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='22' height='22' rx='5'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2'%3E%3Crect x='3' y='3' width='22' height='22' rx='5'/%3E%3C/svg%3E");
}
.mytse-check input:checked + .mytse-check-ui {
	background-color: var(--mytse-primary);
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='22' height='22' rx='5'/%3E%3Cpath d='M8.5 14.5l4 4 7-9'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 28 28' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='22' height='22' rx='5'/%3E%3Cpath d='M8.5 14.5l4 4 7-9'/%3E%3C/svg%3E");
}
.mytse-radio input:focus-visible + .mytse-radio-ui,
.mytse-check input:focus-visible + .mytse-check-ui {
	outline: 2px solid var(--mytse-primary);
	outline-offset: 2px;
	border-radius: 50%;
}

/* دکمه‌ی راهنما (کنار عنوان) */
.mytse .mytse-help {
	flex: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: var(--mytse-primary);
	color: #fff;
	font: inherit;
	font-size: 12px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	box-shadow: none;
}
.mytse-help-pop {
	position: absolute;
	inset-inline-start: 0;
	top: 26px;
	z-index: 30;
	width: max-content;
	max-width: min(320px, 90vw);
	padding: 10px 14px;
	border-radius: 6px;
	background: #222;
	color: #fff;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.9;
	box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
}

/* ---------- حالت‌ها ---------- */
.mytse-field.is-disabled .mytse-ctl,
.mytse-ctl.is-disabled { background-color: var(--mytse-ctl-bg-off); }
.mytse-field.is-disabled .mytse-legend,
.mytse-ctl.is-disabled .mytse-legend {
	background: linear-gradient(to bottom, var(--mytse-surface) 50%, var(--mytse-ctl-bg-off) 50%);
}
.mytse-field.is-disabled .mytse-ctl select,
.mytse-ctl.is-disabled select { color: #b5b5b5; cursor: not-allowed; }
.mytse-field.is-disabled .mytse-radio,
.mytse-field.is-disabled .mytse-check { opacity: .5; pointer-events: none; }
.mytse-field.is-disabled .mytse-label { opacity: .6; }
.mytse .mytse-ctl.is-locked input[type="text"] {
	background: var(--mytse-ctl-bg-off) !important;
	cursor: not-allowed;
}
.mytse-field.has-error .mytse-ctl { border-color: var(--mytse-danger); }

.mytse-error {
	margin-top: 0;
	font-size: 12px;
	color: var(--mytse-danger);
}
.mytse-error:empty { display: none; }

/* ---------- دکمه ---------- */
.mytse-actions {
	display: flex;
	justify-content: flex-start;
	margin-top: 28px;
	padding-top: 24px;
	border-top: 1px solid rgba(0, 0, 0, .08);
}
.mytse .mytse-submit {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	min-height: 52px;
	padding: 0 36px;
	border: 0;
	border-radius: 6px;
	background-color: var(--mytse-primary);
	color: #fff;
	font: inherit;
	font-weight: 700;
	letter-spacing: normal;
	text-transform: none;
	box-shadow: none;
	cursor: pointer;
	transition: filter .15s ease, background-color .15s ease;
}
.mytse .mytse-submit:hover,
.mytse .mytse-submit:focus-visible { filter: brightness(1.08); }
.mytse .mytse-submit[disabled] { opacity: .75; cursor: progress; }
.mytse .mytse-submit.is-loading::before {
	content: "";
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, .5);
	border-top-color: #fff;
	border-radius: 50%;
	animation: mytse-spin .7s linear infinite;
}
@keyframes mytse-spin { to { transform: rotate(360deg); } }

/* ---------- نتیجه ---------- */
.mytse-result { margin-top: 28px; }
.mytse-res {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	gap: 12px 20px;
	padding: 20px;
	border: 1px solid var(--mytse-border);
	border-radius: 10px;
	background: rgba(0, 0, 0, .015);
}
.mytse-res-route {
	flex: 0 0 auto;
	margin-inline-end: 100%; /* چیپ را در ردیف جدا نگه می‌دارد، بدون کشیده شدن */
	padding: 5px 16px;
	border-radius: 999px;
	font-size: 14px;
	font-weight: 700;
	color: var(--mytse-primary);
	background: color-mix(in srgb, var(--mytse-primary) 10%, transparent);
	white-space: nowrap;
}
.mytse-res-title {
	margin: 0 0 8px;
	font-size: 13px;
	font-weight: 700;
	color: #555;
}
.mytse-res-box {
	display: flex;
	align-items: stretch;
	min-height: 52px;
	background: #fff;
	border: 1px solid var(--mytse-border);
	border-radius: 6px;
	overflow: hidden;
}
.mytse-res-val {
	flex: 1;
	display: flex;
	align-items: center;
	padding: 0 16px;
	font-size: 17px;
	font-weight: 700;
}
.mytse-res-unit {
	display: flex;
	align-items: center;
	padding: 0 14px;
	color: var(--mytse-muted);
	background: rgba(0, 0, 0, .025);
	border-inline-start: 1px solid var(--mytse-border);
}
.mytse-res-col { flex: 1 1 200px; min-width: 0; }
.mytse-res-actions {
	flex: 0 0 auto;
	margin-inline-start: auto; /* در راست‌به‌چپ یعنی سمت چپ، هم‌خط با باکس‌ها */
}
.mytse .mytse-res-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 52px;
	padding: 0 28px;
	border-radius: 6px;
	background-color: var(--mytse-primary);
	color: #fff;
	font-weight: 700;
	text-decoration: none;
	transition: filter .15s ease;
}
.mytse .mytse-res-btn:hover,
.mytse .mytse-res-btn:focus-visible { filter: brightness(1.08); color: #fff; }
.mytse-breakdown {
	width: 100%;
	margin-top: 22px;
	border-collapse: collapse;
	font-size: 14px;
}
.mytse-breakdown td {
	padding: 9px 4px;
	border: 0;
	border-bottom: 1px solid #ececec;
	background: transparent;
}
.mytse-breakdown td:last-child { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mytse-breakdown tr.is-total td { font-weight: 700; border-bottom: 0; }
.mytse-note { margin-top: 12px; font-size: 13px; color: #666; }
.mytse-notice {
	padding: 14px 18px;
	border: 1px solid #e8d49a;
	border-radius: 6px;
	background: #fff8e6;
	color: #6b5400;
}
.mytse-notice.is-error { border-color: #f1b5b5; background: #fdeeee; color: #8a1f1f; }
.mytse-empty {
	padding: 16px;
	border: 1px dashed #ccc;
	border-radius: 6px;
	text-align: center;
	color: #666;
}

/* ---------- موبایل ---------- */
@media (max-width: 767px) {
	.mytse-grid { --mytse-rg: 16px; }
	.mytse-field { --w: 100 !important; }
	.mytse-label-inline .mytse-field { grid-template-columns: minmax(0, 1fr); gap: 8px 0; }
	.mytse-label-inline .mytse-field > .mytse-error { grid-column: 1; }
	.mytse-loc { grid-template-columns: minmax(0, 1fr); }
	.mytse-actions { justify-content: stretch; }
	.mytse .mytse-submit { width: 100%; }
	.mytse-res { padding: 16px; }
	.mytse-res-col { flex-basis: 100%; }
	.mytse-res-actions { flex: 0 0 100%; }
	.mytse-res-actions .mytse-res-btn { width: 100%; }
}
