/**
 * Nafouti Live Sales Notifications CSS
 * Luxury, high-performance styling for WordPress & Elementor
 * Full RTL & Arabic Polylang Support
 * Clean Cascade Architecture (Allows 100% Elementor Overrides)
 */

:root {
	--nsp-wine: #681021;
	--nsp-wine-dark: #440B16;
	--nsp-cream: #F8F3ED;
	--nsp-sand: #EEE5D9;
	--nsp-ink: #302823;
	--nsp-muted: #796A60;
	--nsp-line: #DED2C5;
}

.nafouti-sales-popup-wrapper {
	position: fixed;
	z-index: 99999;
	pointer-events: none;
	width: auto;
	box-sizing: border-box;
}

/* Positioning rules (Desktop) */
.nafouti-sales-popup-wrapper.nsp-pos-bottom-left {
	bottom: var(--nsp-offset-y, 24px);
	left: var(--nsp-offset-x, 24px);
	right: auto;
	top: auto;
}

.nafouti-sales-popup-wrapper.nsp-pos-bottom-right {
	bottom: var(--nsp-offset-y, 24px);
	right: var(--nsp-offset-x, 24px);
	left: auto;
	top: auto;
}

.nafouti-sales-popup-wrapper.nsp-pos-top-left {
	top: var(--nsp-offset-y, 24px);
	left: var(--nsp-offset-x, 24px);
	right: auto;
	bottom: auto;
}

.nafouti-sales-popup-wrapper.nsp-pos-top-right {
	top: var(--nsp-offset-y, 24px);
	right: var(--nsp-offset-x, 24px);
	left: auto;
	bottom: auto;
}

/* The Popup Card */
.nafouti-sales-popup {
	display: block;
	position: relative;
	background-color: var(--nsp-cream);
	border: 1px solid var(--nsp-line);
	border-radius: 12px;
	box-shadow: 0 10px 30px -5px rgba(48, 40, 35, 0.12), 0 4px 10px -2px rgba(48, 40, 35, 0.05);
	padding: 12px 16px 12px 14px;
	box-sizing: border-box;
	width: 100%;
	max-width: 360px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(20px) scale(0.97);
	transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
	            transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
	            visibility 0.35s;
	pointer-events: none;
	font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	overflow: hidden;
}

/* Active State (Shown) */
.nafouti-sales-popup.nsp-active {
	opacity: 1;
	visibility: visible;
	transform: translateY(0) scale(1);
	pointer-events: auto;
}

/* Exiting state */
.nafouti-sales-popup.nsp-leaving {
	opacity: 0;
	visibility: hidden;
	transform: translateY(12px) scale(0.96);
	transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

/* Inner Layout */
.nsp-body {
	display: flex;
	align-items: center;
	gap: 14px;
	text-decoration: none;
}

/* Product Thumbnail */
.nsp-image-link {
	display: block;
	flex-shrink: 0;
	line-height: 0;
}

.nsp-image {
	width: 64px;
	height: 64px;
	min-width: 64px;
	object-fit: cover;
	border-radius: 8px;
	background-color: #f0ebe4;
	border: 1px solid rgba(222, 210, 197, 0.5);
	transition: transform 0.25s ease;
}

.nsp-image-link:hover .nsp-image {
	transform: scale(1.04);
}

/* Details Section */
.nsp-details {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 3px;
}

/* Top Row: Buyer Name & Verified Badge */
.nsp-top-row {
	display: flex;
	align-items: center;
	justify-content: flex-start;
	gap: 8px;
	flex-wrap: wrap;
}

.nsp-buyer {
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--nsp-ink);
	line-height: 1.3;
	letter-spacing: -0.01em;
}

/* Verified Badge */
.nsp-badge {
	display: inline-flex;
	align-items: center;
	gap: 3px;
	background-color: var(--nsp-sand);
	color: var(--nsp-wine);
	font-size: 0.65rem;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 20px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	line-height: 1.2;
}

.nsp-badge svg {
	flex-shrink: 0;
}

/* Product Name Link */
.nsp-product-wrapper {
	margin-top: 1px;
}

.nsp-product-link {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--nsp-wine);
	text-decoration: none;
	line-height: 1.35;
	transition: color 0.2s ease;
}

.nsp-product-link:hover {
	color: var(--nsp-wine-dark);
	text-decoration: underline;
}

/* Time & Metadata */
.nsp-meta-row {
	margin-top: 1px;
}

.nsp-time {
	font-size: 0.6875rem;
	color: var(--nsp-muted);
	font-weight: 500;
}

/* Close Button (LTR default: top-right) */
.nsp-close-btn {
	position: absolute;
	top: 6px;
	right: 6px;
	background: transparent;
	border: none;
	padding: 6px;
	color: var(--nsp-muted);
	cursor: pointer;
	border-radius: 50%;
	line-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 0.2s, background-color 0.2s;
	z-index: 2;
	touch-action: manipulation;
}

.nsp-close-btn:hover,
.nsp-close-btn:active {
	color: var(--nsp-wine);
	background-color: rgba(104, 16, 33, 0.08);
}

/* ==================== RTL & ARABIC SUPPORT ==================== */
.nafouti-sales-popup-wrapper.nsp-rtl .nafouti-sales-popup,
[dir="rtl"] .nafouti-sales-popup {
	direction: rtl;
	text-align: right;
	font-family: 'Alexandria', 'Almarai', 'Cairo', 'Segoe UI', Tahoma, -apple-system, sans-serif;
}

.nafouti-sales-popup-wrapper.nsp-rtl .nsp-close-btn,
[dir="rtl"] .nsp-close-btn {
	right: auto;
	left: 6px;
}

.nafouti-sales-popup-wrapper.nsp-rtl .nsp-badge,
[dir="rtl"] .nsp-badge {
	letter-spacing: 0;
}

/* Elementor editor preview safety */
.elementor-editor-active .nafouti-sales-popup {
	opacity: 1;
	visibility: visible;
	transform: none;
	pointer-events: auto;
}

/* ==================== RESPONSIVE / MOBILE RULES ==================== */
@media (max-width: 767px) {
	.nafouti-sales-popup-wrapper.nsp-hide-mobile {
		display: none !important;
	}

	/* Bottom Positions on Mobile (Clear WoodMart Toolbar) */
	.nafouti-sales-popup-wrapper.nsp-pos-bottom-left,
	.nafouti-sales-popup-wrapper.nsp-pos-bottom-right {
		bottom: calc(var(--nsp-offset-y, 65px) + env(safe-area-inset-bottom, 0px));
		left: var(--nsp-offset-x, 12px);
		right: var(--nsp-offset-x, 12px);
		max-width: calc(100vw - 24px);
		margin: 0 auto;
	}

	/* Top Positions on Mobile (Clear Status Bar / Header) */
	.nafouti-sales-popup-wrapper.nsp-pos-top-left,
	.nafouti-sales-popup-wrapper.nsp-pos-top-right {
		top: calc(var(--nsp-offset-y, 16px) + env(safe-area-inset-top, 0px));
		left: var(--nsp-offset-x, 12px);
		right: var(--nsp-offset-x, 12px);
		max-width: calc(100vw - 24px);
		margin: 0 auto;
	}

	.nafouti-sales-popup {
		box-shadow: 0 8px 24px rgba(48, 40, 35, 0.15);
	}

	.nsp-close-btn {
		padding: 8px; /* Accessible touch target */
	}
}
