/**
 * تعدد عناوين الشحن — تنسيقات الواجهة الأمامية.
 * الأزرق = اللون الأساسي، البرتقالي = لون التمرير (Hover).
 */

:root {
	--sma-primary: #1e3a8a;
	--sma-primary-rgb: 30, 58, 138;
	--sma-hover: #f97316;
	--sma-hover-rgb: 249, 115, 22;

	--sma-ink: #14181f;
	--sma-muted: #6b7280;
	--sma-line: #e3e7ee;
	--sma-bg: #ffffff;
	--sma-soft: #f6f8fc;
	--sma-danger: #dc2626;
	--sma-radius: 16px;
	--sma-shadow: 0 2px 10px rgba(16, 24, 40, .05);
	--sma-shadow-lg: 0 24px 60px rgba(16, 24, 40, .18);
}

/* ---------------------------------------------------------------
   الحاوية العامة
   --------------------------------------------------------------- */

.sma-wrap {
	direction: rtl;
	text-align: right;
	font-family: inherit;
	color: var(--sma-ink);
	margin: 0 0 28px;
}

.sma-wrap *,
.sma-modal * {
	box-sizing: border-box;
}

.sma-head {
	margin-bottom: 14px;
}

.sma-wrap .sma-title {
	margin: 0 0 4px;
	font-size: 20px;
	line-height: 1.4;
	font-weight: 700;
	color: var(--sma-ink);
}

.sma-wrap .sma-sub {
	margin: 0;
	font-size: 13.5px;
	line-height: 1.7;
	color: var(--sma-muted);
}

/* ---------------------------------------------------------------
   زر إضافة عنوان جديد
   --------------------------------------------------------------- */

.sma-wrap .sma-add-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	width: 100%;
	min-height: 56px;
	margin: 0 0 16px;
	padding: 14px 20px;
	border: 2px dashed rgba(var(--sma-primary-rgb), .45);
	border-radius: var(--sma-radius);
	background: linear-gradient(180deg, rgba(var(--sma-primary-rgb), .045), rgba(var(--sma-primary-rgb), .02));
	color: var(--sma-primary);
	font-family: inherit;
	font-size: 15.5px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition: border-color .2s ease, color .2s ease, background .2s ease, transform .12s ease, box-shadow .2s ease;
	-webkit-appearance: none;
	appearance: none;
	text-decoration: none;
	box-shadow: none;
}

.sma-wrap .sma-add-btn:hover,
.sma-wrap .sma-add-btn:focus-visible {
	border-color: var(--sma-hover);
	border-style: solid;
	color: var(--sma-hover);
	background: rgba(var(--sma-hover-rgb), .07);
	box-shadow: 0 6px 18px rgba(var(--sma-hover-rgb), .16);
	outline: none;
}

.sma-wrap .sma-add-btn:active {
	transform: translateY(1px);
}

.sma-add-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	border-radius: 50%;
	background: currentColor;
	flex: 0 0 auto;
}

.sma-add-icon svg {
	color: #fff;
	stroke: #fff;
	width: 18px;
	height: 18px;
}

/* ---------------------------------------------------------------
   قائمة الكروت
   --------------------------------------------------------------- */

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

.sma-context-checkout .sma-list {
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.sma-card {
	position: relative;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 16px 16px 14px 14px;
	border: 2px solid var(--sma-line);
	border-radius: var(--sma-radius);
	background: var(--sma-bg);
	box-shadow: var(--sma-shadow);
	cursor: pointer;
	transition: border-color .2s ease, box-shadow .2s ease, transform .15s ease, background .2s ease;
}

.sma-card:hover {
	border-color: var(--sma-hover);
	box-shadow: 0 10px 26px rgba(var(--sma-hover-rgb), .14);
	transform: translateY(-2px);
}

.sma-card:focus-visible {
	outline: 2px solid var(--sma-hover);
	outline-offset: 2px;
}

.sma-card.is-selected {
	border-color: var(--sma-primary);
	background: linear-gradient(180deg, rgba(var(--sma-primary-rgb), .05), rgba(var(--sma-primary-rgb), .015));
	box-shadow: 0 10px 26px rgba(var(--sma-primary-rgb), .14);
}

.sma-card.is-busy {
	opacity: .55;
	pointer-events: none;
}

.sma-card-input {
	position: absolute;
	opacity: 0;
	width: 1px;
	height: 1px;
	margin: 0;
	pointer-events: none;
}

/* دائرة الاختيار */
.sma-card-mark {
	position: relative;
	flex: 0 0 auto;
	width: 20px;
	height: 20px;
	margin-top: 3px;
	border: 2px solid #c9d1de;
	border-radius: 50%;
	background: #fff;
	transition: border-color .2s ease, box-shadow .2s ease;
}

.sma-card-mark::after {
	content: "";
	position: absolute;
	inset: 3px;
	border-radius: 50%;
	background: var(--sma-primary);
	transform: scale(0);
	transition: transform .18s cubic-bezier(.34, 1.56, .64, 1);
}

.sma-card:hover .sma-card-mark {
	border-color: var(--sma-hover);
}

.sma-card.is-selected .sma-card-mark {
	border-color: var(--sma-primary);
	box-shadow: 0 0 0 4px rgba(var(--sma-primary-rgb), .12);
}

.sma-card.is-selected .sma-card-mark::after {
	transform: scale(1);
}

.sma-card-body {
	flex: 1 1 auto;
	min-width: 0;
}

.sma-card-top {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 6px;
}

.sma-card-label {
	font-size: 15.5px;
	font-weight: 700;
	color: var(--sma-primary);
	word-break: break-word;
}

.sma-card-badge {
	display: inline-block;
	padding: 3px 9px;
	border-radius: 999px;
	background: var(--sma-primary);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1.6;
	white-space: nowrap;
}

.sma-wrap .sma-card-name {
	margin: 0 0 3px;
	font-size: 14px;
	font-weight: 600;
	color: var(--sma-ink);
	word-break: break-word;
}

.sma-wrap .sma-card-line {
	margin: 0 0 6px;
	font-size: 13px;
	line-height: 1.65;
	color: var(--sma-muted);
	word-break: break-word;
}

.sma-wrap .sma-card-meta {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin: 0;
	font-size: 12.5px;
}

.sma-card-phone {
	display: inline-block;
	padding: 2px 8px;
	border-radius: 8px;
	background: var(--sma-soft);
	color: #3d4757;
	font-weight: 600;
	unicode-bidi: embed;
}

.sma-card-phone-alt {
	opacity: .8;
}

/* أزرار التعديل والحذف */
.sma-card-actions {
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 0 0 auto;
}

.sma-wrap .sma-icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	border: 1px solid var(--sma-line);
	border-radius: 10px;
	background: #fff;
	color: var(--sma-muted);
	cursor: pointer;
	line-height: 0;
	box-shadow: none;
	transition: color .18s ease, border-color .18s ease, background .18s ease;
}

.sma-wrap .sma-icon-btn:hover {
	color: var(--sma-hover);
	border-color: var(--sma-hover);
	background: rgba(var(--sma-hover-rgb), .08);
}

.sma-wrap .sma-icon-btn.sma-delete:hover {
	color: var(--sma-danger);
	border-color: var(--sma-danger);
	background: rgba(220, 38, 38, .07);
}

.sma-wrap .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	white-space: nowrap;
}

/* الحالة الفارغة */
.sma-empty {
	grid-column: 1 / -1;
	padding: 28px 20px;
	border: 2px dashed var(--sma-line);
	border-radius: var(--sma-radius);
	background: var(--sma-soft);
	text-align: center;
	color: var(--sma-muted);
}

.sma-empty-icon {
	display: inline-flex;
	color: var(--sma-primary);
	opacity: .6;
	margin-bottom: 8px;
}

.sma-wrap .sma-empty-text {
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 600;
	color: var(--sma-ink);
}

.sma-wrap .sma-empty-hint {
	margin: 0;
	font-size: 13px;
}

/* الحقول المخفية الخاصة بووكومرس */
.sma-hidden-fields {
	display: none !important;
}

/* ---------------------------------------------------------------
   النافذة المنبثقة
   --------------------------------------------------------------- */

.sma-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	direction: rtl;
	text-align: right;
}

.sma-modal[hidden] {
	display: none;
}

.sma-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(12, 17, 29, .58);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	opacity: 0;
	transition: opacity .22s ease;
}

.sma-modal.is-open .sma-modal-overlay {
	opacity: 1;
}

.sma-modal-dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 620px;
	max-height: calc(100vh - 40px);
	border-radius: 20px;
	background: #fff;
	box-shadow: var(--sma-shadow-lg);
	overflow: hidden;
	opacity: 0;
	transform: translateY(18px) scale(.98);
	transition: opacity .24s ease, transform .28s cubic-bezier(.22, 1, .36, 1);
}

.sma-modal.is-open .sma-modal-dialog {
	opacity: 1;
	transform: none;
}

.sma-modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 22px;
	background: var(--sma-primary);
	color: #fff;
	flex: 0 0 auto;
}

.sma-modal .sma-modal-title {
	margin: 0;
	font-size: 17.5px;
	font-weight: 700;
	line-height: 1.4;
	color: #fff;
}

.sma-modal .sma-modal-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: rgba(255, 255, 255, .14);
	color: #fff;
	cursor: pointer;
	line-height: 0;
	box-shadow: none;
	transition: background .18s ease, color .18s ease;
}

.sma-modal .sma-modal-close:hover {
	background: var(--sma-hover);
	color: #fff;
}

/* الفورم هو الابن المرن للنافذة، ومنه يرث الجسم قابلية التمرير. */
.sma-modal .sma-form {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
	min-height: 0;
	margin: 0;
	padding: 0;
}

.sma-modal-body {
	padding: 20px 22px 6px;
	overflow-y: auto;
	/* min-height:0 ضروري حتى ينكمش داخل الـ flex ويظهر شريط التمرير بدل دفع الأزرار خارج النافذة. */
	flex: 1 1 auto;
	min-height: 0;
	-webkit-overflow-scrolling: touch;
}

.sma-grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 14px 16px;
}

.sma-field-full {
	grid-column: 1 / -1;
}

.sma-modal .sma-label {
	display: block;
	margin: 0 0 6px;
	font-size: 13.5px;
	font-weight: 600;
	color: #2c3442;
}

.sma-req {
	color: var(--sma-hover);
	font-weight: 700;
}

.sma-opt {
	color: #9aa3b2;
	font-size: 11.5px;
	font-weight: 400;
}

.sma-modal .sma-input {
	display: block;
	width: 100%;
	min-height: 46px;
	margin: 0;
	padding: 11px 14px;
	border: 1.5px solid var(--sma-line);
	border-radius: 12px;
	background: #fff;
	color: var(--sma-ink);
	font-family: inherit;
	font-size: 14.5px;
	line-height: 1.5;
	box-shadow: none;
	transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sma-modal .sma-select {
	background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: left 12px center;
	background-size: 18px 18px;
	padding-left: 38px;
}

.sma-modal .sma-textarea {
	min-height: 80px;
	resize: vertical;
	line-height: 1.7;
}

.sma-modal .sma-input:hover {
	border-color: rgba(var(--sma-hover-rgb), .5);
}

.sma-modal .sma-input:focus {
	border-color: var(--sma-primary);
	box-shadow: 0 0 0 4px rgba(var(--sma-primary-rgb), .12);
	outline: none;
}

.sma-field.has-error .sma-input {
	border-color: var(--sma-danger);
	background: rgba(220, 38, 38, .03);
}

.sma-field.has-error .sma-input:focus {
	box-shadow: 0 0 0 4px rgba(220, 38, 38, .12);
}

.sma-error {
	display: none;
	margin-top: 5px;
	font-size: 12px;
	line-height: 1.5;
	color: var(--sma-danger);
}

.sma-field.has-error .sma-error {
	display: block;
}

.sma-alert {
	margin: 0 22px 0;
	padding: 11px 14px;
	border-radius: 12px;
	background: rgba(220, 38, 38, .08);
	border: 1px solid rgba(220, 38, 38, .25);
	color: #a51d1d;
	font-size: 13.5px;
	line-height: 1.6;
	flex: 0 0 auto;
}

.sma-alert[hidden] {
	display: none;
}

.sma-alert.is-success {
	background: rgba(22, 163, 74, .08);
	border-color: rgba(22, 163, 74, .3);
	color: #14713a;
}

.sma-modal-foot {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 10px;
	padding: 16px 22px;
	border-top: 1px solid var(--sma-line);
	background: var(--sma-soft);
	flex: 0 0 auto;
}

.sma-modal .sma-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	min-height: 46px;
	padding: 12px 26px;
	border: 2px solid transparent;
	border-radius: 12px;
	font-family: inherit;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	cursor: pointer;
	box-shadow: none;
	transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .12s ease;
	-webkit-appearance: none;
	appearance: none;
}

.sma-modal .sma-btn-primary {
	background: var(--sma-primary);
	border-color: var(--sma-primary);
	color: #fff;
	flex: 1 1 auto;
}

.sma-modal .sma-btn-primary:hover:not(:disabled) {
	background: var(--sma-hover);
	border-color: var(--sma-hover);
	color: #fff;
	box-shadow: 0 10px 24px rgba(var(--sma-hover-rgb), .3);
}

.sma-modal .sma-btn-primary:active:not(:disabled) {
	transform: translateY(1px);
}

.sma-modal .sma-btn-ghost {
	background: #fff;
	border-color: var(--sma-line);
	color: #566070;
}

.sma-modal .sma-btn-ghost:hover {
	border-color: var(--sma-hover);
	color: var(--sma-hover);
}

.sma-modal .sma-btn:disabled {
	opacity: .65;
	cursor: not-allowed;
}

/* مؤشر التحميل */
.sma-spinner {
	display: none;
	width: 17px;
	height: 17px;
	border: 2px solid rgba(255, 255, 255, .4);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sma-spin .7s linear infinite;
}

.sma-btn.is-loading .sma-spinner {
	display: inline-block;
}

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

/* منع تمرير الصفحة خلف النافذة */
body.sma-modal-open {
	overflow: hidden;
}

/* ---------------------------------------------------------------
   تعديلات تخطيط صفحة الدفع
   --------------------------------------------------------------- */

.sma-checkout-active #customer_details {
	display: block;
}

.sma-checkout-active #customer_details > .col-1,
.sma-checkout-active #customer_details > .col-2 {
	width: 100%;
	max-width: 100%;
	float: none;
	padding-right: 0;
	padding-left: 0;
}

.sma-checkout-active #customer_details > .col-2 {
	min-height: 0;
}

.sma-checkout-active #customer_details > .col-2:empty {
	display: none;
}

/* في حال تعذّرت إزالة الفورم الأصلي (قالب يستدعيه مباشرة) نخفيه */
.sma-hide-native-fields .woocommerce-billing-fields,
.sma-hide-native-fields .woocommerce-shipping-fields,
.sma-hide-native-fields .woocommerce-additional-fields {
	display: none !important;
}

/* ---------------------------------------------------------------
   الشاشات الصغيرة
   --------------------------------------------------------------- */

@media (max-width: 767px) {
	.sma-list,
	.sma-context-checkout .sma-list {
		grid-template-columns: 1fr;
	}

	.sma-grid {
		grid-template-columns: 1fr;
	}

	.sma-modal {
		padding: 0;
		align-items: flex-end;
	}

	.sma-modal-dialog {
		max-width: 100%;
		max-height: 94vh;
		border-radius: 20px 20px 0 0;
		transform: translateY(30px);
	}

	.sma-modal-head {
		padding: 16px 18px;
	}

	.sma-modal-body {
		padding: 18px 18px 6px;
	}

	.sma-alert {
		margin: 0 18px;
	}

	.sma-modal-foot {
		padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
	}

	.sma-wrap .sma-title {
		font-size: 18px;
	}

	.sma-card {
		padding: 14px;
	}

	.sma-card-actions {
		flex-direction: row;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sma-card,
	.sma-modal-dialog,
	.sma-modal-overlay,
	.sma-card-mark::after,
	.sma-wrap .sma-add-btn {
		transition: none !important;
	}

	.sma-spinner {
		animation-duration: 2s;
	}
}
