/**
 * SDG Checkout Popup – Modal styles.
 * Loaded by sdg-checkout-popup.php for non-logged-in users.
 *
 * Design tokens aligned with login_ux/sharafdg-mockup-v2.jsx (modal card, Btn, Input, SegmentedControl track).
 */

/* Screen-reader-only (OTP fieldset legend, etc.) */
.sdg-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.sdg-p-otp-fieldset {
	border: 0;
	margin: 0;
	padding: 0;
	min-width: 0;
}

/* ── Backdrop (z-index above typical sticky/mobile headers) ── */
.sdg-popup-backdrop {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.48);
	z-index: 9999998;
	opacity: 0;
	animation: sdgFade 0.2s ease-out forwards;
	-webkit-tap-highlight-color: transparent;
}

@keyframes sdgFade {
	to { opacity: 1; }
}

/* ── Container (mock: min(100%,420px), 16px radius, 0.5px border, soft shadow) ── */
.sdg-popup-box {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	max-width: 420px;
	width: calc(100% - 32px);
	max-height: min(92vh, 900px);
	background: #fff;
	border-radius: 16px;
	border: 0.5px solid #ddd;
	overflow-y: auto;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
	z-index: 9999999;
	opacity: 0;
	animation: sdgFade 0.2s ease-out forwards;
	box-sizing: border-box;
}

@media (max-width: 639px) {
	/* Full viewport cover: iOS 100vh vs toolbar; prefer dynamic viewport + legacy fill */
	.sdg-popup-backdrop {
		min-height: 100vh;
		min-height: 100dvh;
		min-height: -webkit-fill-available;
		touch-action: none;
		overscroll-behavior: none;
	}

	.sdg-popup-box {
		width: 100%;
		max-width: none;
		border-radius: 0;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		transform: none;
		/* Fill visible viewport (not clipped by mobile browser chrome) */
		height: 100vh;
		height: 100dvh;
		max-height: none;
		min-height: 100vh;
		min-height: 100dvh;
		min-height: -webkit-fill-available;
		padding-top: env(safe-area-inset-top, 0px);
		padding-bottom: env(safe-area-inset-bottom, 0px);
		padding-left: env(safe-area-inset-left, 0px);
		padding-right: env(safe-area-inset-right, 0px);
		overscroll-behavior: contain;
		-webkit-overflow-scrolling: touch;
	}
}

/* ── Gold header bar ── */
.sdg-popup-header {
	background: #F5A623;
	padding: 12px 14px;
	display: flex;
	align-items: center;
	gap: 10px;
}

.sdg-popup-header-close {
	color: #333;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	background: none;
	border: none;
	padding: 0;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-family: inherit;
	flex-shrink: 0;
}

.sdg-popup-header-close:hover {
	opacity: 0.7;
}

.sdg-popup-header-title {
	flex: 1;
	font-size: 15px;
	font-weight: 600;
	color: #333;
	text-align: center;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.sdg-popup-header-secure {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 12px;
	color: #333;
	flex-shrink: 0;
}

.sdg-popup-header-secure svg {
	display: inline-block;
	vertical-align: middle;
}

/* ── Inner padding (mock email: 16px 22px 24px; verify/OTP body: 24px 22px) ── */
.sdg-popup-inner {
	padding: 16px 22px 24px;
	min-height: 400px;
	box-sizing: border-box;
}

/*
 * OTP / password: mock uses SegmentedControl margin 12px 22px 16px, then inner div padding 24px 22px.
 * Content is inside #sdg-popup-content; emulate 12px below header + 40px below tabs (16 + 24).
 */
.sdg-popup-inner--verify {
	padding: 24px 22px 24px;
	min-height: 0;
}

.sdg-popup-inner--verify #sdg-popup-content > .sdg-p-tabs:first-child {
	margin-top: -12px;
	margin-bottom: 16px;
}

.sdg-popup-inner--verify #sdg-popup-content > .sdg-p-tabs + * {
	margin-top: 24px;
}

@media (max-width: 639px) {
	.sdg-popup-inner {
		min-height: 0;
	}

	.sdg-popup-inner--verify {
		padding: 24px 22px 20px;
	}
}

/* ── Initial loading skeleton (nonce fetch); aligns with login_ux/sharafdg-mockup-v2.jsx ── */
.sdg-popup-inner--skel {
	padding: 0;
}

.login-skel-wrap {
	padding: 20px 22px 28px;
	box-sizing: border-box;
}

.login-skel-block {
	display: block;
	background: linear-gradient(
		90deg,
		#ececec 0%,
		#f6f6f6 45%,
		#ececec 90%
	);
	background-size: 220% 100%;
	animation: loginSkelShimmer 1.15s ease-in-out infinite;
	border-radius: 8px;
}

@keyframes loginSkelShimmer {
	0% {
		background-position: 100% 0;
	}
	100% {
		background-position: -100% 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.login-skel-block {
		animation: none;
		background: #ececec;
	}
}

.login-skel-seg {
	height: 42px;
	border-radius: 10px;
	margin-bottom: 20px;
}

.login-skel-line {
	height: 12px;
	margin-bottom: 10px;
}

.login-skel-line-lg {
	width: 78%;
	margin-bottom: 14px;
}

.login-skel-line-sm {
	width: 52%;
	margin-bottom: 22px;
}

.login-skel-input {
	height: 44px;
	margin-bottom: 18px;
	border-radius: 8px;
}

.login-skel-btn {
	height: 48px;
	border-radius: 10px;
}

/* ── Segmented tabs (mock SegmentedControl variant="track") ── */
.sdg-p-tabs {
	display: flex;
	gap: 2px;
	padding: 5px;
	border-radius: 10px;
	border: 1px solid #e5e7eb;
	background: #f3f4f6;
	margin: 0 0 16px;
}

.sdg-popup-inner:not(.sdg-popup-inner--verify) .sdg-p-tabs:first-child {
	margin-top: 0;
}

.sdg-p-tab {
	flex: 1;
	border: 0;
	border-radius: 8px;
	padding: 9px 10px;
	font-size: 13px;
	font-weight: 500;
	color: #6B7280;
	cursor: pointer;
	font-family: inherit;
	line-height: 1.25;
	background: transparent;
	transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.sdg-p-tab.active {
	background: #fff;
	font-weight: 600;
	color: #111827;
	box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06),
	            0 1px 3px rgba(17, 24, 39, 0.08);
}

/* ── Email step body (below tabs) ── */
.sdg-p-email-block {
	padding-top: 0;
}

.sdg-p-input-wrap {
	position: relative;
}

.sdg-auth-email-form .sdg-p-btn,
.sdg-auth-pw-form .sdg-p-btn {
	margin-top: 12px;
}

/* ── Social login (Google / Apple) ── */
.sdg-p-social-divider {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 18px 0;
}

.sdg-p-social-divider-line {
	flex: 1;
	height: 1px;
	background: #eee;
}

.sdg-p-social-divider-text {
	font-size: 12px;
	color: #bbb;
	white-space: nowrap;
}

.sdg-p-social-row {
	display: flex;
	gap: 8px;
}

.sdg-p-social-btn {
	flex: 1;
	padding: 12px;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-size: 13px;
	font-weight: 500;
	font-family: inherit;
	text-decoration: none;
	box-sizing: border-box;
	transition: opacity 0.15s, border-color 0.15s, background 0.15s;
}

.sdg-p-social-btn:hover {
	opacity: 0.92;
}

.sdg-p-social-google {
	border: 1px solid #ddd;
	background: #fff;
	color: #333;
}

.sdg-p-social-apple {
	border: 1px solid #000;
	background: #000;
	color: #fff;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.sdg-p-social-svg {
	flex-shrink: 0;
	display: block;
}

.sdg-p-social-apple .sdg-p-social-svg {
	fill: #fff;
}

/* ── Typography (mock: welcome 22px/#222; verify titles 20px/#1A1A1A) ── */
.sdg-p-title {
	font-size: 22px;
	font-weight: 600;
	color: #222;
	margin: 0 0 6px;
	line-height: 1.25;
}

.sdg-popup-inner--verify .sdg-p-title {
	font-size: 20px;
	font-weight: 600;
	color: #1a1a1a;
	margin-bottom: 6px;
}

.sdg-p-sub {
	font-size: 13px;
	color: #757575;
	margin: 0 0 16px;
	line-height: 1.5;
}

.sdg-popup-inner--verify .sdg-p-sub {
	margin-top: 0;
	margin-bottom: 4px;
}

/* ── Label ── */
.sdg-p-label {
	display: block;
	font-size: 11px;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: 0.3px;
	color: #888;
	margin-bottom: 4px;
}

/* ── Input ── */
.sdg-p-input {
	width: 100%;
	padding: 10px 12px;
	font-size: 14px;
	border: 1px solid #ddd;
	border-radius: 8px;
	color: #333;
	font-family: inherit;
	box-sizing: border-box;
	outline: none;
	transition: border-color 0.15s;
}

.sdg-p-input::placeholder {
	color: #bbb;
}

.sdg-p-input:focus {
	border-color: #0277bd;
	box-shadow: 0 0 0 3px rgba(2, 119, 189, 0.08);
}

.sdg-p-input.sdg-p-input--invalid {
	border-width: 1.5px;
	border-color: #c62828;
}

/* ── Primary button (mock Btn: 13px padding, 8px radius, #0277BD, uppercase, loading opacity 0.9) ── */
.sdg-p-btn {
	width: 100%;
	padding: 13px;
	border: 0;
	border-radius: 8px;
	background: #0277bd;
	color: #fff;
	font-size: 15px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	cursor: pointer;
	font-family: inherit;
	line-height: 1.25;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.sdg-p-btn:hover:not(:disabled) {
	background: #01579b;
}

.sdg-p-btn:disabled {
	opacity: 0.4;
	cursor: default;
}

.sdg-p-btn:has(.sdg-p-spin) {
	opacity: 0.9;
	cursor: default;
}

/* ── OTP digit grid ── */
.sdg-p-otp {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin: 16px 0;
}

.sdg-p-otp input {
	width: 46px;
	height: 52px;
	text-align: center;
	font-size: 22px;
	font-weight: 600;
	border: 1.5px solid #ddd;
	border-radius: 8px;
	font-family: system-ui, -apple-system, sans-serif;
	line-height: 1;
	color: #333;
	outline: none;
	caret-color: #0277BD;
	transition: border-color 0.15s;
	-webkit-appearance: textfield;
	-moz-appearance: textfield;
	appearance: textfield;
}

body:lang(ar) .sdg-p-otp input,
body:lang(ar) .sdg-p-otp select,
body:lang(ar) .sdg-p-otp textarea {
	font-family: system-ui, -apple-system, sans-serif !important;
	line-height: 1 !important;
}

.sdg-p-otp input::-webkit-inner-spin-button,
.sdg-p-otp input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.sdg-p-otp input:focus {
	border-color: #0277BD;
	box-shadow: 0 0 0 2px rgba(2, 119, 189, 0.12);
}

.sdg-p-otp--error input {
	border-color: #c62828;
}

.sdg-p-success-banner {
	background: #e8f5e9;
	color: #2e7d32;
	border: 1px solid #a5d6a7;
	border-radius: 6px;
	padding: 8px 12px;
	font-size: 13px;
	line-height: 1.4;
	margin-bottom: 12px;
	text-align: start;
}
.sdg-p-success-banner-ic {
	font-weight: 700;
	margin-inline-end: 4px;
}

/* ── Timer / hint / resend (mock: 12px #888, flex wrap, gap 6) ── */
.sdg-p-timer {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-wrap: wrap;
	gap: 6px;
	font-size: 12px;
	color: #888;
	text-align: center;
	margin: 8px 0;
}

.sdg-p-hint {
	font-size: 11px;
	color: #888;
	text-align: center;
	margin-top: 6px;
}

[dir="rtl"] .sdg-popup-box .sdg-p-hint {
	text-align: start;
}

.sdg-p-resend {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-wrap: wrap;
	gap: 4px;
	width: 100%;
	font-size: 12px;
	color: #888;
	text-align: center;
	margin-top: 14px;
}

.sdg-p-resend button {
	background: none;
	border: 0;
	color: #0277BD;
	font-weight: 500;
	cursor: pointer;
	font-family: inherit;
	padding: 0;
	font-size: inherit;
}

.sdg-p-resend button:disabled {
	color: #aaa;
	cursor: default;
}

/* ── Text link ── */
.sdg-p-link {
	background: none;
	border: 0;
	color: #0277BD;
	font-weight: 500;
	cursor: pointer;
	font-family: inherit;
	padding: 0;
	font-size: 13px;
}

.sdg-p-link:hover {
	text-decoration: underline;
}

/* ── Email display (OTP / password steps) ── */
.sdg-p-email {
	font-size: 15px;
	font-weight: 600;
	color: #1A1A1A;
	margin: 0 0 20px;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	overflow-wrap: anywhere;
	word-break: break-word;
	min-width: 0;
}

.sdg-p-email .sdg-p-link {
	flex-shrink: 0;
}

/* ── Sign up + email already registered (info) — sharafdg-mockup-v2.jsx ── */
.sdg-p-info-banner {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	margin: 0 0 16px;
	border-radius: 10px;
	background: #E3F2FD;
	border: 1px solid #90CAF9;
	font-size: 13px;
	color: #01579B;
	line-height: 1.5;
	width: 100%;
	box-sizing: border-box;
}

.sdg-p-info-banner-ic {
	flex-shrink: 0;
	line-height: 0;
	margin-top: 1px;
}

.sdg-p-info-banner-text {
	text-align: start;
}

.sdg-p-info-banner-text strong {
	display: block;
	font-weight: 700;
	color: #01579B;
	margin-bottom: 4px;
}

.sdg-p-info-banner-body {
	font-weight: 400;
	color: #01579B;
}

.sdg-p-timer-dur {
	color: #0277BD;
}

.sdg-p-terms-line {
	font-size: 11px;
	color: #aaa;
	text-align: center;
	margin: 16px 0 0;
	line-height: 1.5;
}

.sdg-p-terms-line .sdg-p-terms-link {
	color: #0277BD;
	text-decoration: none;
	font-weight: 500;
}

.sdg-p-terms-line .sdg-p-terms-link:hover {
	text-decoration: underline;
}

/* ── Not-found banner (space below so title/subcopy never crowd the alert) ── */
.sdg-p-banner {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	margin: 16px 0 20px;
	border-radius: 10px;
	background: #fff3e0;
	font-size: 13px;
	color: #bf360c;
	line-height: 1.5;
	overflow-wrap: anywhere;
	word-break: break-word;
	min-width: 0;
}

.sdg-p-banner strong {
	font-weight: 600;
}

.sdg-p-banner-icon {
	flex-shrink: 0;
	margin-top: 1px;
	width: 14px;
	height: 14px;
	display: flex;
	align-items: center;
}
.sdg-p-banner-icon svg {
	width: 14px;
	height: 14px;
}

.sdg-p-banner-svg {
	stroke: #0277BD;
	flex-shrink: 0;
	margin-top: 2px;
}

.sdg-p-banner-svg circle:last-child {
	fill: #0277BD;
}

.sdg-p-banner .sdg-p-banner-svg {
	stroke: #D32F2F;
}

.sdg-p-banner .sdg-p-banner-svg circle:last-child {
	fill: #D32F2F;
}

/* ── Error message ── */
.sdg-p-err {
	font-size: 12px;
	color: #c62828;
	margin: 4px 0 0;
	line-height: 1.4;
	text-align: left;
}

/* ── Spinners ── */
.sdg-p-spin {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sdgSpin 0.6s linear infinite;
}

.sdg-p-redirect-spin {
	width: 40px;
	height: 40px;
	border: 3px solid #e5e7eb;
	border-top-color: #0277BD;
	border-radius: 50%;
	animation: sdgSpin 0.6s linear infinite;
}

@keyframes sdgSpin {
	to { transform: rotate(360deg); }
}

/* ── RTL overrides ── */
[dir="rtl"] .sdg-p-btn,
[dir="rtl"] .sdg-p-tab,
[dir="rtl"] .sdg-p-label {
	text-transform: none;
	letter-spacing: normal;
}

[dir="rtl"] .sdg-p-btn {
	font-size: 15px;
	font-weight: 600;
}

[dir="rtl"] .sdg-p-input {
	font-size: 16px;
	text-align: right;
}

[dir="rtl"] .sdg-p-label {
	font-size: 12px;
}

[dir="rtl"] .sdg-p-err {
	text-align: right;
}

[dir="rtl"] .sdg-p-title {
	font-size: 22px;
}

[dir="rtl"] .sdg-popup-inner--verify .sdg-p-title {
	font-size: 20px;
}

/* ── WooCommerce info notice ── */
.woocommerce-info {
	padding: 14px 18px;
	margin: 0 0 20px;
	background: #edf5ff;
	border: 1px solid #b3d4fc;
	border-radius: 8px;
	color: #1a3d5c;
	font-size: 14px;
	line-height: 1.5;
}
.grecaptcha-badge { visibility: hidden; }