/* DaruHast SMS — login card + popup. Uses the theme's --dh-* tokens, with fallbacks. */

.dsms {
	--dsms-primary: var(--dh-primary, #23cea9);
	--dsms-primary-dark: var(--dh-primary-dark, #1fb897);
	--dsms-text: var(--dh-text, #2a2a2a);
	--dsms-muted: #6b7280;
	--dsms-border: var(--dh-border, #d8d8d8);
	--dsms-bg: var(--dh-bg, #f1f5f9);
	--dsms-red: var(--dh-red, #e04848);
	--dsms-radius: var(--dh-radius, 12px);
	--dsms-font: var(--dh-font, "IranYekanX", Tahoma, sans-serif);

	direction: rtl;
	font-family: var(--dsms-font);
	color: var(--dsms-text);
	max-width: 400px;
	margin: 0 auto;
	text-align: right;
}

.dsms *,
.dsms *::before,
.dsms *::after { box-sizing: border-box; }

.dsms [hidden] { display: none !important; }

.dsms .dsms__step { display: flex; flex-direction: column; gap: 18px; margin: 0; }
.dsms .dsms__step > .dsms__title + .dsms__text { margin-top: -8px; }
.dsms [data-fields] { display: flex; flex-direction: column; gap: 16px; }

.dsms .dsms__title {
	font-size: 1.25rem;
	font-weight: 800;
	line-height: 1.5;
	margin: 0;
	color: var(--dsms-text);
}

.dsms .dsms__text {
	margin: 0;
	font-size: .92rem;
	line-height: 1.9;
	color: var(--dsms-muted);
}

.dsms .dsms__phone { color: var(--dsms-text); unicode-bidi: isolate; }

.dsms .dsms__label { display: flex; flex-direction: column; gap: 8px; font-size: .9rem; font-weight: 600; line-height: 1.6; }

.dsms .dsms__input {
	width: 100%;
	height: 52px;
	padding: 0 14px;
	font: inherit;
	font-size: 1.05rem;
	color: var(--dsms-text);
	background: #fff;
	border: 1.5px solid var(--dsms-border);
	border-radius: var(--dsms-radius);
	outline: none;
	transition: border-color .15s, box-shadow .15s;
}
.dsms .dsms__input:focus {
	border-color: var(--dsms-primary);
	box-shadow: 0 0 0 4px rgba(35, 206, 169, .18);
}
.dsms .dsms__input:-webkit-autofill,
.dsms .dsms__input:-webkit-autofill:focus {
	-webkit-box-shadow: 0 0 0 100px #fff inset;
	-webkit-text-fill-color: var(--dsms-text);
}
.dsms .dsms__input--ltr { direction: ltr; text-align: left; letter-spacing: .04em; }
.dsms .dsms__input--ltr::placeholder { text-align: right; }
.dsms .dsms__input--code {
	direction: ltr;
	text-align: center;
	font-size: 1.6rem;
	font-weight: 700;
	letter-spacing: .6em;
	padding-left: .6em; /* balances the last letter-spacing */
}

.dsms .dsms__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	width: 100%;
	height: 52px;
	border: 0;
	border-radius: var(--dsms-radius);
	background: linear-gradient(135deg, var(--dsms-primary) 0%, #1ec0a0 100%);
	color: #fff;
	font: inherit;
	font-size: 1rem;
	font-weight: 700;
	cursor: pointer;
	box-shadow: 0 10px 22px -10px rgba(35, 206, 169, .7);
	transition: transform .15s, box-shadow .15s, opacity .15s;
}
.dsms .dsms__btn:hover { transform: translateY(-1px); box-shadow: 0 14px 26px -10px rgba(35, 206, 169, .75); }
.dsms .dsms__btn:disabled { opacity: .7; cursor: wait; transform: none; }
.dsms .dsms__btn.is-loading span::after {
	content: "";
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-right: 8px;
	vertical-align: -2px;
	border: 2px solid rgba(255, 255, 255, .5);
	border-top-color: #fff;
	border-radius: 50%;
	animation: dsms-spin .7s linear infinite;
}
@keyframes dsms-spin { to { transform: rotate(360deg); } }

.dsms .dsms__link {
	background: none;
	border: 0;
	padding: 0;
	font: inherit;
	font-size: .88rem;
	font-weight: 700;
	color: var(--dh-blue, #2379ce);
	cursor: pointer;
}
.dsms .dsms__link:hover { text-decoration: underline; }

.dsms .dsms__resend { margin: 0; text-align: center; font-size: .88rem; color: var(--dsms-muted); min-height: 1.6em; }

.dsms .dsms__error {
	margin: 0;
	padding: 10px 12px;
	font-size: .88rem;
	line-height: 1.8;
	color: var(--dsms-red);
	background: rgba(224, 72, 72, .07);
	border-radius: 10px;
}
.dsms .dsms__field-error { color: var(--dsms-red); font-weight: 500; font-size: .8rem; min-height: 0; }
.dsms .dsms__field-error:empty { display: none; }

.dsms .dsms__done { align-items: center; text-align: center; padding: 24px 0; color: var(--dsms-primary); }

.dsms .dsms__legal { margin: 16px 0 0; font-size: .78rem; color: var(--dsms-muted); text-align: center; line-height: 1.8; }
.dsms .dsms__legal a { color: inherit; text-decoration: underline; }

.dsms .dsms__sr {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Popup ---------- */
html.dsms-lock { overflow: hidden; }

.dsms-modal {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
}
.dsms-modal[hidden] { display: none; }

.dsms-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(15, 23, 42, .55);
	backdrop-filter: blur(2px);
	animation: dsms-fade .2s ease-out;
}

.dsms-modal__box {
	position: relative;
	width: 100%;
	max-width: 420px;
	max-height: calc(100vh - 32px);
	overflow-y: auto;
	padding: 32px 26px 22px;
	background: #fff;
	border-radius: 18px;
	box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .45);
	animation: dsms-pop .22s ease-out;
}

.dsms-modal .dsms-modal__close {
	position: absolute;
	top: 12px;
	left: 12px;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0; /* the theme gives every button side padding */
	border: 0;
	border-radius: 50%;
	background: var(--dh-bg, #f1f5f9);
	color: #475569;
	cursor: pointer;
	z-index: 1;
}
.dsms-modal .dsms-modal__close svg { flex: none; }
.dsms-modal .dsms-modal__close:hover { background: #e2e8f0; color: #475569; }

@keyframes dsms-fade { from { opacity: 0; } }
@keyframes dsms-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* On phones the popup is a bottom sheet. */
@media (max-width: 560px) {
	.dsms-modal { align-items: flex-end; padding: 0; }
	.dsms-modal__box {
		max-width: none;
		border-radius: 20px 20px 0 0;
		padding: 28px 18px calc(18px + env(safe-area-inset-bottom));
		animation: dsms-sheet .25s ease-out;
	}
}
@keyframes dsms-sheet { from { transform: translateY(100%); } }

button.dsms-open-btn {
	padding: 10px 18px;
	border: 0;
	border-radius: var(--dh-radius, 12px);
	background: var(--dh-primary, #23cea9);
	color: #fff;
	font: inherit;
	font-weight: 700;
	cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
	.dsms-modal__backdrop, .dsms-modal__box, .dsms__btn { animation: none; transition: none; }
}

/* ---------- WooCommerce ---------- */

/* Checkout, guest: the shop's step bar, then login card + cart summary. */
.dsms-gate { direction: rtl; text-align: right; font-family: var(--dh-font, "IranYekanX", Tahoma, sans-serif); }
.dsms-gate .dh-checkout-hero { margin-bottom: 24px; }
.dsms-gate__grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 360px;
	gap: 24px;
	align-items: start;
	max-width: 960px;
	margin: 0 auto 48px;
}
.dsms-gate__login,
.dsms-gate__cart {
	background: #fff;
	border: 1px solid var(--dh-border-soft, #e8ecf1);
	border-radius: var(--dh-radius-card, 16px);
	box-shadow: var(--dh-shadow-card, 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -16px rgba(16, 24, 40, .1));
}
.dsms-gate__login { padding: 32px 32px 24px; }
.dsms-gate__login .dsms { max-width: 420px; }
.dsms-gate__cart { padding: 20px; position: sticky; top: 24px; }
.dsms-gate__cart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.dsms-gate__cart-head h2 { margin: 0; font-size: 1rem; font-weight: 800; color: var(--dh-rich, #1a1a1a); }
.dsms-gate__cart-head a { font-size: .85rem; font-weight: 700; color: var(--dh-blue, #2379ce); text-decoration: none; }
.dsms-gate__items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.dsms-gate__items li { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.dsms-gate__thumb { position: relative; width: 56px; height: 56px; }
.dsms-gate__thumb img { width: 56px; height: 56px; object-fit: contain; border: 1px solid var(--dh-border-soft, #e8ecf1); border-radius: 12px; background: #fff; }
.dsms-gate__thumb b {
	position: absolute; top: -6px; left: -6px;
	min-width: 20px; height: 20px; padding: 0 5px;
	display: flex; align-items: center; justify-content: center;
	font-size: .72rem; color: #fff; background: var(--dh-blue, #2379ce); border-radius: 999px;
}
.dsms-gate__name { font-size: .86rem; line-height: 1.7; color: var(--dh-text, #2a2a2a); }
.dsms-gate__price { font-size: .86rem; font-weight: 700; white-space: nowrap; }
.dsms-gate__total {
	display: flex; justify-content: space-between; align-items: center;
	margin-top: 18px; padding: 14px 16px;
	background: var(--dh-blue-softer, #f4f8fd); border-radius: var(--dh-radius-md, 12px);
}
.dsms-gate__total b { font-size: 1.05rem; color: var(--dh-primary, #23cea9); }
.dsms-gate__note { margin: 10px 0 0; font-size: .78rem; color: var(--dh-muted, #5f6b7a); }
@media (max-width: 860px) {
	.dsms-gate__grid { grid-template-columns: 1fr; }
	.dsms-gate__cart { position: static; }
}
@media (max-width: 600px) {
	.dsms-gate__login { padding: 24px 18px 18px; }
}

/* my-account login page: the card sits in the theme's .dh-auth box. */
.dsms-account .dsms { max-width: none; }
.dsms-account .dsms__legal { margin-bottom: 0; }

/* Checkout, logged in: the order phone, read only. */
.dsms-phone-line {
	margin: 0 0 16px;
	padding: 12px 14px;
	font-size: .92rem;
	line-height: 1.9;
	background: var(--dh-blue-softer, #f4f8fd);
	border: 1px solid var(--dh-blue-soft, #eaf2fb);
	border-radius: var(--dh-radius-md, 12px);
}
.dsms-phone-line b { font-size: 1rem; unicode-bidi: isolate; }
.dsms-phone-line small { color: var(--dh-muted, #5f6b7a); }

/* my-account order page: tracking code. */
.dsms-tracking {
	margin: 16px 0;
	padding: 12px 14px;
	background: var(--dh-primary-soft, rgba(35, 206, 169, .1));
	border-radius: var(--dh-radius-md, 12px);
	line-height: 1.9;
}
.dsms-tracking b { font-size: 1.05rem; letter-spacing: .03em; unicode-bidi: isolate; }
