/**
 * Smart Popup Builder - Public Frontend Styles
 * Lightweight, hardware-accelerated, accessible.
 */

:root {
	--spb-z-index-base: 999990;
}

/* Base Root Container */
.spb-popup-root {
	position: fixed;
	inset: 0;
	z-index: var(--spb-z-index-base);
	display: none;
	align-items: center;
	justify-content: center;
	font-family: inherit;
	box-sizing: border-box;
}

.spb-popup-root *,
.spb-popup-root *::before,
.spb-popup-root *::after {
	box-sizing: border-box;
}

.spb-popup-root.spb-open {
	display: flex;
}

/* Backdrop Overlay */
.spb-popup-overlay {
	position: fixed;
	inset: 0;
	z-index: 1;
	cursor: pointer;
	transition: opacity 0.3s ease;
}

/* Dialog Box */
.spb-popup-dialog {
	position: relative;
	z-index: 2;
	width: var(--spb-width-desktop, 540px);
	max-width: calc(100vw - 32px);
	max-height: var(--spb-max-height, 85vh);
	background-color: var(--spb-bg-color, #ffffff);
	color: var(--spb-text-color, #1e293b);
	border-radius: var(--spb-radius, 12px);
	box-shadow: var(--spb-shadow, 0 20px 25px -5px rgba(0, 0, 0, 0.25));
	border-width: var(--spb-border-width, 0);
	border-style: var(--spb-border-style, solid);
	border-color: var(--spb-border-color, #e2e8f0);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	will-change: transform, opacity;
}

/* Inner Body */
.spb-popup-body {
	padding: var(--spb-padding, 32px);
}

/* Typography & Headings */
.spb-title {
	margin: 0 0 12px 0;
	font-size: 24px;
	font-weight: 700;
	color: inherit;
	line-height: 1.25;
}

.spb-content {
	font-size: 15px;
	line-height: 1.6;
	color: inherit;
	opacity: 0.95;
	margin-bottom: 20px;
}
.spb-content p {
	margin: 0 0 10px 0;
}
.spb-content p:last-child {
	margin-bottom: 0;
}

/* Close Button */
.spb-close-btn {
	position: absolute;
	z-index: 10;
	background: transparent;
	border: none;
	padding: 8px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
	transition: transform 0.2s ease, opacity 0.2s ease;
	border-radius: 50%;
}
.spb-close-btn:hover {
	opacity: 0.75;
	transform: scale(1.1);
}
.spb-close-btn:focus-visible {
	outline: 2px solid var(--spb-primary, #3b82f6);
	outline-offset: 2px;
}
.spb-close-top_right_inside { top: 12px; right: 12px; }
.spb-close-top_left_inside { top: 12px; left: 12px; }
.spb-close-top_right_outside { top: -36px; right: 0; color: #fff !important; }
.spb-close-top_left_outside { top: -36px; left: 0; color: #fff !important; }

/* Images & Media */
.spb-img-fluid {
	max-width: 100%;
	height: auto;
	display: block;
	border-radius: calc(var(--spb-radius, 12px) / 2);
}
.spb-header-image {
	margin: calc(var(--spb-padding, 32px) * -1) calc(var(--spb-padding, 32px) * -1) 20px calc(var(--spb-padding, 32px) * -1);
}
.spb-header-image img {
	width: 100%;
	border-radius: var(--spb-radius, 12px) var(--spb-radius, 12px) 0 0;
}
.spb-image-link {
	display: block;
	text-decoration: none;
}

/* Pure Clickable Image Popup */
.spb-type-image_popup .spb-popup-dialog {
	overflow: visible;
	background-color: transparent !important;
	border: none !important;
	box-shadow: none !important;
}
.spb-type-image_popup .spb-popup-body {
	padding: 0 !important;
	margin: 0 !important;
	line-height: 0;
	overflow: hidden;
	border-radius: var(--spb-radius, 12px);
	box-shadow: var(--spb-shadow, 0 20px 25px -5px rgba(0, 0, 0, 0.35));
}
.spb-type-image_popup .spb-image-wrap {
	position: relative;
	width: 100%;
	line-height: 0;
	overflow: hidden;
	border-radius: inherit;
}
.spb-type-image_popup .spb-image-link {
	display: block;
	line-height: 0;
	outline: none;
	cursor: pointer;
	text-decoration: none;
	border-radius: inherit;
}
.spb-type-image_popup .spb-img-fluid {
	width: 100%;
	height: auto;
	display: block;
	border-radius: inherit;
	transition: opacity 0.2s ease, transform 0.25s ease;
}
.spb-type-image_popup .spb-image-link:hover .spb-img-fluid {
	opacity: 0.96;
	transform: scale(1.01);
}
.spb-type-image_popup .spb-close-btn {
	position: absolute !important;
	top: 10px !important;
	right: 10px !important;
	left: auto !important;
	bottom: auto !important;
	width: 26px !important;
	height: 26px !important;
	min-width: 26px !important;
	min-height: 26px !important;
	max-width: 26px !important;
	max-height: 26px !important;
	border-radius: 50% !important;
	background: rgba(0, 0, 0, 0.35) !important;
	border: 1px solid rgba(255, 255, 255, 0.45) !important;
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
	backdrop-filter: blur(4px) !important;
	-webkit-backdrop-filter: blur(4px) !important;
	color: #ffffff !important;
	opacity: 0.85 !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	padding: 0 !important;
	margin: 0 !important;
	cursor: pointer !important;
	z-index: 99999 !important;
	transition: all 0.2s ease !important;
	line-height: 1 !important;
	outline: none !important;
}
.spb-type-image_popup .spb-close-btn:hover {
	background: rgba(0, 0, 0, 0.65) !important;
	border-color: rgba(255, 255, 255, 0.8) !important;
	color: #ffffff !important;
	opacity: 1 !important;
	transform: scale(1.08) !important;
}
.spb-type-image_popup .spb-close-btn svg {
	width: 13px !important;
	height: 13px !important;
	stroke: #ffffff !important;
	stroke-width: 2.4 !important;
	display: block !important;
	pointer-events: none !important;
}
.spb-type-image_popup .spb-close-top_right_inside,
.spb-type-image_popup .spb-close-top_right_outside {
	top: 10px !important;
	right: 10px !important;
}
.spb-type-image_popup .spb-close-top_left_inside,
.spb-type-image_popup .spb-close-top_left_outside {
	top: 10px !important;
	left: 10px !important;
	right: auto !important;
}

/* Video Wrapper (16:9 Responsive) */
.spb-video-wrap {
	position: relative;
	padding-bottom: 56.25%;
	height: 0;
	overflow: hidden;
	border-radius: calc(var(--spb-radius, 12px) / 2);
	margin-bottom: 18px;
	background: #000;
}
.spb-video-wrap iframe,
.spb-video-wrap video {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* Coupon Box */
.spb-coupon-box {
	background: rgba(0, 0, 0, 0.04);
	border: 2px dashed rgba(0, 0, 0, 0.15);
	border-radius: 8px;
	padding: 14px 16px;
	margin: 18px 0;
	text-align: center;
}
.spb-coupon-label {
	display: block;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.05em;
	opacity: 0.8;
	margin-bottom: 8px;
	font-weight: 600;
}
.spb-coupon-display {
	display: inline-flex;
	align-items: center;
	background: #fff;
	border-radius: 6px;
	padding: 4px 6px 4px 12px;
	border: 1px solid rgba(0, 0, 0, 0.12);
	gap: 12px;
}
.spb-coupon-code {
	font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
	font-size: 16px;
	font-weight: 700;
	color: #0f172a;
	letter-spacing: 0.05em;
}
.spb-coupon-copy-btn {
	background: #0f172a;
	color: #fff;
	border: none;
	padding: 6px 12px;
	border-radius: 4px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease;
}
.spb-coupon-copy-btn:hover {
	background: #334155;
}
.spb-coupon-copy-btn.spb-copied {
	background: #10b981;
}

/* Lead Capture Form */
.spb-form {
	margin-top: 18px;
}
.spb-form-fields {
	display: flex;
	flex-direction: column;
	gap: 10px;
}
.spb-field-group .spb-input {
	width: 100%;
	padding: 12px 14px;
	font-size: 14px;
	border: 1px solid rgba(0, 0, 0, 0.2);
	border-radius: 6px;
	background: #fff;
	color: #1e293b;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.spb-field-group .spb-input:focus {
	border-color: #3b82f6;
	outline: none;
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.spb-consent-group {
	font-size: 12px;
	opacity: 0.85;
	margin: 4px 0;
}
.spb-checkbox-label {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	cursor: pointer;
}
.spb-submit-btn {
	padding: 12px 20px;
	font-size: 15px;
	font-weight: 600;
	border: none;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	transition: opacity 0.15s ease, transform 0.1s ease;
}
.spb-submit-btn:hover {
	opacity: 0.9;
}
.spb-submit-btn:active {
	transform: scale(0.99);
}
.spb-submit-btn:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* Form Notice */
.spb-form-notice {
	margin-top: 12px;
	padding: 10px 14px;
	border-radius: 6px;
	font-size: 13px;
	text-align: center;
}
.spb-notice-success {
	background: #ecfdf5;
	color: #065f46;
	border: 1px solid #a7f3d0;
}
.spb-notice-error {
	background: #fef2f2;
	color: #991b1b;
	border: 1px solid #fecaca;
}

/* Spinner */
.spb-spinner {
	display: none;
	width: 16px;
	height: 16px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: spb-spin 0.6s linear infinite;
}
.spb-submitting .spb-spinner {
	display: inline-block;
}

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

/* Action Buttons */
.spb-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 20px;
}
.spb-btn {
	display: inline-block;
	padding: 12px 22px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	text-align: center;
	cursor: pointer;
	transition: opacity 0.15s ease, transform 0.1s ease;
}
.spb-btn:hover {
	opacity: 0.9;
}
.spb-btn-secondary {
	background: rgba(0, 0, 0, 0.08);
	color: inherit;
	border-radius: 6px;
}

/* ==================== POPUP TYPES ==================== */

/* Fullscreen */
.spb-type-fullscreen .spb-popup-dialog {
	width: 100vw !important;
	max-width: 100vw !important;
	height: 100vh !important;
	max-height: 100vh !important;
	border-radius: 0 !important;
	display: flex;
	align-items: center;
	justify-content: center;
}
.spb-type-fullscreen .spb-popup-body {
	max-width: 720px;
	width: 100%;
	text-align: center;
}

/* Slide-In */
.spb-type-slide_in {
	inset: auto;
	padding: 20px;
}
.spb-type-slide_in .spb-popup-overlay {
	display: none; /* No full backdrop for corner slide-ins */
}
.spb-type-slide_in.spb-slide-right {
	bottom: 0;
	right: 0;
	align-items: flex-end;
	justify-content: flex-end;
}
.spb-type-slide_in.spb-slide-left {
	bottom: 0;
	left: 0;
	align-items: flex-end;
	justify-content: flex-start;
}
.spb-type-slide_in.spb-slide-bottom {
	bottom: 0;
	left: 50%;
	transform: translateX(-50%);
	align-items: flex-end;
	justify-content: center;
}
.spb-type-slide_in.spb-slide-top {
	top: 0;
	left: 50%;
	transform: translateX(-50%);
	align-items: flex-start;
	justify-content: center;
}

/* Top Announcement Bar */
.spb-type-top_bar {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	width: 100%;
	inset: 0 0 auto 0;
	align-items: flex-start;
}
.spb-type-top_bar .spb-popup-dialog {
	width: 100% !important;
	max-width: 100% !important;
	border-radius: 0 !important;
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}
.spb-type-top_bar .spb-popup-body {
	padding: 12px 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	text-align: center;
}
.spb-type-top_bar .spb-title {
	font-size: 16px;
	margin: 0;
}
.spb-type-top_bar .spb-content {
	margin: 0;
	font-size: 14px;
}
.spb-type-top_bar .spb-actions {
	margin: 0;
}
.spb-type-top_bar .spb-btn {
	padding: 6px 14px;
	font-size: 13px;
}

/* Bottom Sticky Bar */
.spb-type-bottom_bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	width: 100%;
	inset: auto 0 0 0;
	align-items: flex-end;
}
.spb-type-bottom_bar .spb-popup-dialog {
	width: 100% !important;
	max-width: 100% !important;
	border-radius: 0 !important;
	box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
}
.spb-type-bottom_bar .spb-popup-body {
	padding: 12px 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 16px;
	text-align: center;
}
.spb-type-bottom_bar .spb-title {
	font-size: 16px;
	margin: 0;
}
.spb-type-bottom_bar .spb-content {
	margin: 0;
	font-size: 14px;
}
.spb-type-bottom_bar .spb-actions {
	margin: 0;
}
.spb-type-bottom_bar .spb-btn {
	padding: 6px 14px;
	font-size: 13px;
}

/* ==================== ANIMATIONS ==================== */
@keyframes spbFadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}
@keyframes spbFadeOut {
	from { opacity: 1; }
	to { opacity: 0; }
}
@keyframes spbZoomIn {
	from { opacity: 0; transform: scale(0.85); }
	to { opacity: 1; transform: scale(1); }
}
@keyframes spbZoomOut {
	from { opacity: 1; transform: scale(1); }
	to { opacity: 0; transform: scale(0.85); }
}
@keyframes spbSlideDown {
	from { opacity: 0; transform: translateY(-40px); }
	to { opacity: 1; transform: translateY(0); }
}
@keyframes spbSlideUp {
	from { opacity: 0; transform: translateY(40px); }
	to { opacity: 1; transform: translateY(0); }
}
@keyframes spbSlideLeft {
	from { opacity: 0; transform: translateX(60px); }
	to { opacity: 1; transform: translateX(0); }
}
@keyframes spbSlideRight {
	from { opacity: 0; transform: translateX(-60px); }
	to { opacity: 1; transform: translateX(0); }
}
@keyframes spbBounceIn {
	0% { opacity: 0; transform: scale(0.3); }
	50% { opacity: 0.9; transform: scale(1.05); }
	70% { transform: scale(0.9); }
	100% { opacity: 1; transform: scale(1); }
}

.spb-anim-fadeIn { animation-name: spbFadeIn; }
.spb-anim-fadeOut { animation-name: spbFadeOut; }
.spb-anim-zoomIn { animation-name: spbZoomIn; }
.spb-anim-zoomOut { animation-name: spbZoomOut; }
.spb-anim-slideDown { animation-name: spbSlideDown; }
.spb-anim-slideUp { animation-name: spbSlideUp; }
.spb-anim-slideLeft { animation-name: spbSlideLeft; }
.spb-anim-slideRight { animation-name: spbSlideRight; }
.spb-anim-bounceIn { animation-name: spbBounceIn; }

/* Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
	.spb-popup-dialog,
	.spb-popup-overlay {
		animation: none !important;
		transition: none !important;
	}
}

/* ==================== RESPONSIVE VIEWPORTS ==================== */
@media (max-width: 768px) {
	.spb-popup-dialog {
		width: var(--spb-width-tablet, 480px);
	}
	.spb-type-top_bar .spb-popup-body,
	.spb-type-bottom_bar .spb-popup-body {
		flex-direction: column;
		gap: 8px;
	}
}

@media (max-width: 480px) {
	.spb-popup-dialog {
		width: var(--spb-width-mobile, 330px);
		max-width: calc(100vw - 20px);
	}
	.spb-popup-body {
		padding: 22px 18px;
	}
	.spb-title {
		font-size: 20px;
	}
	.spb-actions {
		flex-direction: column;
	}
	.spb-btn {
		width: 100%;
	}
}
