/* ==========================================================================
   WP Service Leads — public styles
   Premium popup UI, RTL by default (Persian), theme-color adaptive.
   ========================================================================== */

/*
 * Theme color adaptation.
 * --wpsl-primary is set inline via wp_add_inline_style() ONLY when the
 * admin has manually chosen a color in Settings → General. When it is
 * NOT set, the chain below falls through to whichever "primary color"
 * custom property the active theme/page-builder already defines
 * (Elementor, Blocksy, Astra, GeneratePress, Woodmart, Hello Elementor,
 * or the core block editor palette), and only if none of those exist
 * does it fall back to the plugin's own default color. This keeps the
 * popup visually consistent with the site without hardcoding a color
 * that could clash with the active theme.
 */
.wpsl-trigger-wrap,
.wpsl-modal {
	--wpsl-primary-resolved: var(
		--wpsl-primary,
		var(--e-global-color-primary,
		var(--theme-palette-color-1,
		var(--ast-global-color-3,
		var(--wp--preset--color--primary,
		#6c63ff)))));
	--wpsl-primary-rgb: 108, 99, 255;
	--wpsl-radius: 16px;
	--wpsl-font: 'Vazirmatn', Tahoma, Arial, sans-serif;
}

.wpsl-trigger-wrap,
.wpsl-modal,
.wpsl-modal * {
	font-family: var(--wpsl-font);
	box-sizing: border-box;
}

/* --------------------------------------------------------------------
   Trigger button
   -------------------------------------------------------------------- */

.wpsl-trigger-wrap {
	display: inline-block;
	position: relative;
	z-index: 1;
	isolation: isolate;
}

.wpsl-trigger-button {
	position: relative;
	pointer-events: auto !important;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 46px;
	padding: 12px 28px;
	background-color: var(--wpsl-primary-resolved);
	color: #ffffff;
	border: none;
	border-radius: 999px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	box-shadow: 0 4px 14px rgba(var(--wpsl-primary-rgb), 0.35);
}

.wpsl-trigger-button:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(var(--wpsl-primary-rgb), 0.42);
}

.wpsl-trigger-button:active {
	transform: translateY(0);
}

/* --------------------------------------------------------------------
   Modal shell
   -------------------------------------------------------------------- */

.wpsl-modal {
	display: none;
	position: fixed;
	inset: 0;
	z-index: 2147483000; /* sit above theme headers, Elementor sticky bars, mobile nav overlays */
	pointer-events: auto !important;
}

.wpsl-modal.wpsl-modal--open {
	display: block !important;
}

.wpsl-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(20, 18, 35, 0.55);
	backdrop-filter: blur(3px);
	-webkit-backdrop-filter: blur(3px);
	opacity: 0;
	pointer-events: auto;
	animation: wpsl-fade-in 0.2s ease forwards;
}

.wpsl-modal-dialog {
	position: relative;
	pointer-events: auto;
	max-width: 460px;
	width: calc(100% - 32px);
	margin: 6vh auto;
	background-color: #ffffff;
	background-image: linear-gradient(145deg, #ffffff 0%, #f7f6fd 100%); /* default plugin background when no custom image is set */
	background-size: cover;
	background-position: center;
	border-radius: var(--wpsl-radius);
	box-shadow: 0 20px 60px rgba(20, 18, 35, 0.25), 0 2px 8px rgba(20, 18, 35, 0.08);
	max-height: 88vh;
	overflow-y: auto;
	overflow-x: hidden;
	-webkit-overflow-scrolling: touch;
	opacity: 0;
	transform: translateY(16px) scale(0.98);
	animation: wpsl-pop-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* A custom background image was selected in Settings → General. */
.wpsl-modal-dialog.wpsl-has-bg {
	background-color: #201c33;
}

.wpsl-modal-bg-overlay {
	position: absolute;
	inset: 0;
	background: rgba(10, 8, 20, 0.4); /* ~40% dark overlay, keeps text readable over the photo */
	z-index: 0;
}

.wpsl-modal-inner {
	position: relative;
	z-index: 1;
	padding: 32px 28px 28px;
}

@keyframes wpsl-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes wpsl-pop-in {
	from {
		opacity: 0;
		transform: translateY(16px) scale(0.98);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.wpsl-modal-close {
	position: absolute;
	top: 16px;
	left: 16px; /* RTL: close button sits at the visual top-left */
	width: 34px;
	height: 34px;
	pointer-events: auto !important;
	touch-action: manipulation;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #f4f3f9;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	color: #6b6880;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.wpsl-modal-close:hover {
	background: #ece9f7;
	color: #2d2b40;
	transform: rotate(90deg);
}

.wpsl-modal-title {
	margin: 0 0 22px;
	padding-left: 40px; /* keep clear of the close button in RTL */
	font-size: 21px;
	font-weight: 700;
	color: #1d1b2e;
}

.wpsl-has-bg .wpsl-modal-title {
	color: #ffffff;
	text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.wpsl-has-bg .wpsl-field label {
	color: #f2f1fb;
}

.wpsl-has-bg .wpsl-field input[type="text"],
.wpsl-has-bg .wpsl-field input[type="tel"] {
	background: rgba(255, 255, 255, 0.14);
	border-color: rgba(255, 255, 255, 0.35);
	color: #ffffff;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
}

.wpsl-has-bg .wpsl-field input[type="text"]::placeholder,
.wpsl-has-bg .wpsl-field input[type="tel"]::placeholder {
	color: rgba(255, 255, 255, 0.65);
}

.wpsl-has-bg .wpsl-field input[type="text"]:focus,
.wpsl-has-bg .wpsl-field input[type="tel"]:focus {
	background: rgba(255, 255, 255, 0.22);
	border-color: #ffffff;
	box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18);
}

.wpsl-has-bg .wpsl-modal-close {
	background: rgba(255, 255, 255, 0.18);
	color: #ffffff;
}

.wpsl-has-bg .wpsl-modal-close:hover {
	background: rgba(255, 255, 255, 0.3);
	color: #ffffff;
}

/* --------------------------------------------------------------------
   Form fields
   -------------------------------------------------------------------- */

.wpsl-honeypot {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

.wpsl-field {
	margin: 0 0 16px;
}

.wpsl-field label {
	display: block;
	margin-bottom: 7px;
	font-weight: 600;
	font-size: 13px;
	color: #423f57;
}

.wpsl-field input[type="text"],
.wpsl-field input[type="tel"],
.wpsl-field textarea {
	width: 100%;
	padding: 12px 16px;
	border: 1.5px solid #e4e2ef;
	border-radius: 12px;
	font-size: 15px;
	font-family: var(--wpsl-font);
	color: #1d1b2e;
	background: #fbfbfd;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.wpsl-field input.wpsl-input-ltr {
	direction: ltr;
	text-align: right;
}

.wpsl-field input[type="text"]::placeholder,
.wpsl-field input[type="tel"]::placeholder,
.wpsl-field textarea::placeholder {
	color: #a5a2b8;
}

.wpsl-field input[type="text"]:focus,
.wpsl-field input[type="tel"]:focus,
.wpsl-field textarea:focus {
	outline: none;
	border-color: var(--wpsl-primary-resolved);
	background: #ffffff;
	box-shadow: 0 0 0 4px rgba(var(--wpsl-primary-rgb), 0.14);
}

.wpsl-field textarea {
	resize: vertical;
	min-height: 90px;
}

.wpsl-field-error {
	color: #e0384c;
	font-size: 12px;
	display: block;
	margin-top: 6px;
}

/* --------------------------------------------------------------------
   Submit button + loading state
   -------------------------------------------------------------------- */

.wpsl-field--submit {
	margin-top: 22px;
}

.wpsl-submit-button {
	position: relative;
	width: 100%;
	min-height: 50px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 14px 24px;
	background-color: var(--wpsl-primary-resolved);
	color: #ffffff;
	border: none;
	border-radius: 12px;
	font-size: 15px;
	font-weight: 700;
	font-family: var(--wpsl-font);
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	box-shadow: 0 6px 18px rgba(var(--wpsl-primary-rgb), 0.32);
}

.wpsl-submit-button:hover {
	transform: translateY(-1px);
	box-shadow: 0 8px 22px rgba(var(--wpsl-primary-rgb), 0.4);
}

.wpsl-submit-button:active {
	transform: translateY(0);
}

.wpsl-submit-button[disabled] {
	opacity: 0.75;
	cursor: not-allowed;
	transform: none;
}

.wpsl-btn-spinner {
	display: none;
	width: 17px;
	height: 17px;
	border: 2.5px solid rgba(255, 255, 255, 0.4);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: wpsl-spin 0.7s linear infinite;
}

.wpsl-submit-button.wpsl-is-loading .wpsl-btn-spinner {
	display: inline-block;
}

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

/* --------------------------------------------------------------------
   Status messages (success / error), with icon + subtle entrance
   -------------------------------------------------------------------- */

.wpsl-form-messages {
	display: none;
	align-items: center;
	gap: 8px;
	min-height: 1.4em;
	margin: 4px 0 0;
	padding: 10px 14px;
	border-radius: 10px;
	font-size: 13px;
	animation: wpsl-msg-in 0.2s ease forwards;
}

.wpsl-form-messages--success,
.wpsl-form-messages--error {
	display: flex;
}

.wpsl-form-messages--success {
	background: #ecfbf1;
	color: #1a7a42;
}

.wpsl-form-messages--error {
	background: #fdecee;
	color: #c0293f;
}

.wpsl-form-messages-icon {
	flex: 0 0 auto;
	width: 18px;
	height: 18px;
	display: none;
	align-items: center;
	justify-content: center;
}

.wpsl-form-messages--success .wpsl-form-messages-icon,
.wpsl-form-messages--error .wpsl-form-messages-icon {
	display: inline-flex;
}

.wpsl-form-messages--success .wpsl-form-messages-icon::before {
	content: "";
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #1a7a42;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M20 6L9 17l-5-5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 11px no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M20 6L9 17l-5-5' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/></svg>") center / 11px no-repeat;
	animation: wpsl-pop-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.wpsl-form-messages--error .wpsl-form-messages-icon::before {
	content: "";
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: #c0293f;
	-webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M18 6L6 18M6 6l12 12' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'/></svg>") center / 11px no-repeat;
	mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M18 6L6 18M6 6l12 12' fill='none' stroke='white' stroke-width='3' stroke-linecap='round'/></svg>") center / 11px no-repeat;
	animation: wpsl-shake 0.35s ease;
}

@keyframes wpsl-msg-in {
	from { opacity: 0; transform: translateY(-4px); }
	to { opacity: 1; transform: translateY(0); }
}

@keyframes wpsl-shake {
	10%, 90% { transform: translateX(-1px); }
	20%, 80% { transform: translateX(2px); }
	30%, 50%, 70% { transform: translateX(-3px); }
	40%, 60% { transform: translateX(3px); }
}

/* --------------------------------------------------------------------
   Body scroll lock (applied by JS while the modal is open)
   -------------------------------------------------------------------- */

body.wpsl-scroll-lock {
	overflow: hidden;
	touch-action: none;
}

/* --------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------- */

@media (max-width: 600px) {
	.wpsl-modal-dialog {
		width: calc(100% - 20px);
		margin: 4vh auto;
		max-height: 92vh;
		border-radius: 14px;
	}

	.wpsl-modal-inner {
		padding: 26px 20px 22px;
	}

	.wpsl-modal-title {
		font-size: 18px;
	}

	.wpsl-trigger-button,
	.wpsl-submit-button {
		width: 100%;
	}

	.wpsl-field input[type="text"],
	.wpsl-field input[type="tel"],
	.wpsl-field textarea {
		font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
	}
}

@media (max-width: 360px) {
	.wpsl-modal-dialog {
		width: calc(100% - 12px);
	}

	.wpsl-modal-inner {
		padding: 22px 16px 18px;
	}
}
