/**
 * SaralBook Popup Manager — Frontend styles.
 * All selectors are prefixed with .sbpm- to avoid collisions with
 * Elementor, Astra, and other theme/plugin CSS.
 */

:root {
	--sbpm-overlay-color: #000000;
	--sbpm-overlay-opacity: 0.55;
	--sbpm-blur: 6px;
	--sbpm-width: 480px;
	--sbpm-radius: 12px;
	--sbpm-padding: 32px;
	--sbpm-bg: #ffffff;
	--sbpm-close-size: 32px;
	--sbpm-close-color: #333333;
	--sbpm-anim-duration: 300ms;
}

#sbpm-root {
	position: relative;
	z-index: 999999;
}

.sbpm-overlay {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 2147483000;
	background-color: rgba(0, 0, 0, var(--sbpm-overlay-opacity));
	padding: 20px;
	box-sizing: border-box;
	opacity: 0;
	transition: opacity var(--sbpm-anim-duration) ease;
}

/* Blur is applied to a full-screen pseudo layer BEHIND the popup card,
   never to the popup card itself, so the popup content stays sharp. */
.sbpm-overlay::before {
	content: '';
	position: fixed;
	inset: 0;
	z-index: -1;
	backdrop-filter: blur(var(--sbpm-blur));
	-webkit-backdrop-filter: blur(var(--sbpm-blur));
}

/* Fallback for browsers without backdrop-filter support: darken more. */
@supports not (backdrop-filter: blur(1px)) {
	.sbpm-overlay {
		background-color: rgba(0, 0, 0, 0.75);
	}
}

.sbpm-overlay.sbpm-visible {
	opacity: 1;
}

.sbpm-popup {
	position: relative;
	width: 100%;
	max-width: var(--sbpm-width);
	max-height: 90vh;
	overflow-y: auto;
	background: var(--sbpm-bg);
	border-radius: var(--sbpm-radius);
	padding: var(--sbpm-padding);
	box-sizing: border-box;
	transform: scale(0.92);
	opacity: 0;
	transition: transform var(--sbpm-anim-duration) ease, opacity var(--sbpm-anim-duration) ease;
	-webkit-font-smoothing: antialiased;
}

.sbpm-popup.sbpm-shadow {
	box-shadow: 0 25px 70px rgba(0, 0, 0, 0.35);
}

.sbpm-overlay.sbpm-visible .sbpm-popup {
	transform: scale(1);
	opacity: 1;
}

/* Animation variants */
.sbpm-anim-fade .sbpm-popup {
	transform: none;
}

.sbpm-anim-slide-up .sbpm-popup {
	transform: translateY(40px);
}
.sbpm-anim-slide-up.sbpm-visible .sbpm-popup {
	transform: translateY(0);
}

.sbpm-anim-slide-down .sbpm-popup {
	transform: translateY(-40px);
}
.sbpm-anim-slide-down.sbpm-visible .sbpm-popup {
	transform: translateY(0);
}

.sbpm-close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: var(--sbpm-close-size);
	height: var(--sbpm-close-size);
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px solid rgba(0, 0, 0, 0.12);
	/* Intentionally hardcoded, not driven by --sbpm-close-color: a
	   solid white circle with a solid black glyph is the one
	   combination that is always readable, regardless of the popup
	   background, overlay color, or any image behind it. */
	background-color: #ffffff !important;
	color: #000000 !important;
	font-size: calc(var(--sbpm-close-size) * 0.6);
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	box-shadow: 0 1px 6px rgba(0, 0, 0, 0.3);
	z-index: 999999;
	opacity: 1 !important;
	transition: transform 150ms ease;
}

.sbpm-close:hover,
.sbpm-close:focus-visible {
	background-color: #f2f2f2 !important;
	transform: scale(1.08);
}

/* Guaranteed contrast fallback: if the close button color is ever too
   close to white (e.g. left unset against a white popup), the dark
   glyph + shadowed circle underneath still keeps it visible against
   images or colored backgrounds. */
.sbpm-close::after {
	content: '';
}

/* Ads-style "Skip in Xs" badge shown in place of the close button
   until the admin-configured skip delay elapses. */
.sbpm-skip-badge {
	position: absolute;
	top: 12px;
	right: 12px;
	min-width: var(--sbpm-close-size);
	height: var(--sbpm-close-size);
	padding: 0 10px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.65);
	color: #ffffff;
	font-size: 12px;
	font-weight: 600;
	border-radius: 999px;
	white-space: nowrap;
	z-index: 999999;
	pointer-events: none;
}

.sbpm-image {
	display: block;
	width: 100%;
	max-width: 100%;
	height: auto;
	border-radius: 8px;
	margin: 0 0 18px;
	object-fit: cover;
}

/* When the admin sets an explicit (non-100%) image width, alignment
   controls where it sits inside the popup. */
.sbpm-align-left .sbpm-image {
	margin-right: auto;
	margin-left: 0;
}
.sbpm-align-center .sbpm-image {
	margin-right: auto;
	margin-left: auto;
}
.sbpm-align-right .sbpm-image {
	margin-right: 0;
	margin-left: auto;
}

.sbpm-title {
	margin: 0 0 12px;
	font-size: 22px;
	line-height: 1.3;
	font-weight: 700;
	padding-right: calc(var(--sbpm-close-size) + 8px);
}

.sbpm-content {
	margin: 0 0 20px;
	font-size: 15px;
	line-height: 1.6;
}

.sbpm-html-content {
	margin: 0 0 12px;
}

.sbpm-button {
	display: inline-block;
	padding: 12px 24px;
	background: #2271b1;
	color: #ffffff !important;
	text-decoration: none;
	border-radius: 6px;
	font-weight: 600;
	font-size: 14px;
	border: none;
	cursor: pointer;
	transition: opacity 150ms ease;
}

.sbpm-button:hover {
	opacity: 0.9;
}

/* Body lock while popup is open (added/removed via JS) */
.sbpm-body-lock {
	overflow: hidden !important;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
	.sbpm-popup {
		width: var(--sbpm-mobile-width, 92%);
		padding: var(--sbpm-mobile-padding, 20px);
		max-height: var(--sbpm-mobile-max-height, 85vh);
	}

	.sbpm-title {
		font-size: 18px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.sbpm-overlay,
	.sbpm-popup {
		transition: none !important;
	}
}
