/**
 * MLabs Popup - Frontend Stylesheet
 * Ultra lightweight, non-blocking, isolated, responsive.
 */

/* 1. Root & Modal Lock */
.mlabs-popup-root {
	position: fixed;
	inset: 0;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

body.mlabs-popup-open {
	overflow: hidden !important;
}

/* 2. Container chung */
.mlabs-popup-container {
	position: fixed;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	box-sizing: border-box;
}

.mlabs-popup-container * {
	box-sizing: border-box;
}

/* 3. Backdrop Overlay (cho mẫu 1, 2, 3) */
.mlabs-popup-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.65);
	backdrop-filter: blur(4px);
	-webkit-backdrop-filter: blur(4px);
	opacity: 0;
	transition: opacity 0.28s ease;
}

.mlabs-is-active .mlabs-popup-backdrop {
	opacity: 1;
}

.mlabs-is-closing .mlabs-popup-backdrop {
	opacity: 0;
}

/* 4. Thẻ Popup Dialog */
.mlabs-popup-dialog {
	position: relative;
	width: 100%;
	max-width: 480px;
	background: #ffffff;
	border-radius: 14px;
	box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
	overflow: hidden;
	opacity: 0;
	transform: scale(0.94) translateY(12px);
	transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1), transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
	z-index: 2;
}

.mlabs-is-active .mlabs-popup-dialog,
.mlabs-popup-container.mlabs-is-active .mlabs-popup-dialog {
	opacity: 1 !important;
	transform: scale(1) translateY(0) !important;
}

.mlabs-is-closing .mlabs-popup-dialog,
.mlabs-popup-container.mlabs-is-closing .mlabs-popup-dialog {
	opacity: 0 !important;
	transform: scale(0.96) translateY(8px) !important;
}

/* 5. Nút Close [X] - Reset CSS chặt chẽ, kích thước chuẩn 36x36px, tương phản cao */
.mlabs-popup-close {
	position: absolute !important;
	top: 14px !important;
	right: 14px !important;
	width: 36px !important;
	height: 36px !important;
	min-width: 36px !important;
	min-height: 36px !important;
	padding: 0 !important;
	margin: 0 !important;
	border: 1px solid #e2e8f0 !important;
	background: #f8fafc !important;
	color: #475569 !important;
	border-radius: 50% !important;
	cursor: pointer !important;
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	line-height: 1 !important;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
	transition: all 0.2s ease !important;
	outline: none !important;
	z-index: 10 !important;
	-webkit-appearance: none !important;
	appearance: none !important;
}

.mlabs-popup-close:hover {
	background: #e2e8f0 !important;
	color: #0f172a !important;
	transform: scale(1.08) !important;
	border-color: #cbd5e1 !important;
}

.mlabs-popup-close:focus-visible {
	box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.35) !important;
}

.mlabs-popup-close svg {
	width: 18px !important;
	height: 18px !important;
	display: block !important;
	stroke: currentColor !important;
	fill: none !important;
}

/* 6. Nội dung Popup */
.mlabs-popup-content-wrap {
	padding: 28px 24px 24px;
}

.mlabs-popup-header {
	margin-bottom: 14px;
	padding-right: 32px; /* Chừa không gian tránh đè nút close */
}

.mlabs-popup-icon-badge {
	display: flex;
	align-items: center;
	gap: 10px;
	margin-bottom: 12px;
}

.mlabs-popup-icon-circle {
	width: 40px;
	height: 40px;
	border-radius: 10px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: #e0f2fe;
	color: #0284c7;
	flex-shrink: 0;
}

.mlabs-popup-icon-circle svg {
	width: 22px;
	height: 22px;
}

.mlabs-popup-badge {
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding: 4px 10px;
	border-radius: 9999px;
	background: #f1f5f9;
	color: #0369a1;
	border: 1px solid #e2e8f0;
}

.mlabs-popup-title {
	margin: 0;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.35;
	color: #1e293b;
}

.mlabs-popup-body {
	font-size: 14px;
	line-height: 1.6;
	color: #475569;
	margin-bottom: 22px;
	word-break: break-word;
}

.mlabs-popup-body p {
	margin: 0 0 10px;
}

.mlabs-popup-body p:last-child {
	margin-bottom: 0;
}

/* 7. Action Buttons */
.mlabs-popup-actions {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 12px;
}

.mlabs-popup-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-size: 14px;
	font-weight: 600;
	padding: 10px 18px;
	border-radius: 8px;
	text-decoration: none !important;
	cursor: pointer;
	transition: all 0.2s ease;
	line-height: 1.4;
	outline: none;
	border: none;
}

.mlabs-popup-btn-cta {
	background: #0078d4;
	color: #ffffff !important;
	box-shadow: 0 2px 4px rgba(0, 120, 212, 0.25);
}

.mlabs-popup-btn-cta:hover {
	background: #0284c7;
	color: #ffffff !important;
	transform: translateY(-1px);
	box-shadow: 0 4px 8px rgba(2, 132, 199, 0.3);
}

.mlabs-popup-btn-cta svg {
	width: 16px;
	height: 16px;
	stroke-width: 2.2;
}

.mlabs-popup-btn-dismiss {
	background: #f8fafc;
	color: #64748b;
	border: 1px solid #cbd5e1;
}

.mlabs-popup-btn-dismiss:hover {
	background: #e2e8f0;
	color: #1e293b;
	border-color: #94a3b8;
}

/* ========================================================
   8. Định dạng chi tiết từng Mẫu (Templates)
   ======================================================== */

/* Mẫu 2: Minimalist Card */
.mlabs-tpl-minimal_card .mlabs-popup-dialog {
	max-width: 440px;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
}

.mlabs-tpl-minimal_card .mlabs-icon-soft {
	background: #f1f5f9;
	color: #475569;
}

.mlabs-tpl-minimal_card .mlabs-popup-btn-dismiss {
	background: transparent;
	border: none;
	color: #64748b;
	padding: 8px 12px;
	text-decoration: underline !important;
}

.mlabs-tpl-minimal_card .mlabs-popup-btn-dismiss:hover {
	color: #0f172a;
	background: transparent;
}

/* Mẫu 3: Urgent Notice */
.mlabs-tpl-urgent_alert .mlabs-popup-dialog {
	max-width: 500px;
	border-top: none;
}

.mlabs-popup-accent-bar {
	height: 5px;
	width: 100%;
	background: linear-gradient(90deg, #0284c7 0%, #0369a1 100%);
}

.mlabs-icon-urgent {
	background: #fef3c7;
	color: #d97706;
}

.mlabs-badge-urgent {
	background: #fffbeb;
	color: #b45309;
	border-color: #fde68a;
}

/* ========================================================
   9. Mẫu 4: Corner Slide-in Toast (UX hoàn hảo)
   - Nằm ở góc dưới bên phải
   - pointer-events: none ở container bao ngoài
   - pointer-events: auto ở thẻ card
   - KHÔNG có backdrop che mờ màn hình
   - KHÔNG khóa cuộn trang
   ======================================================== */
.mlabs-popup-container.mlabs-is-toast {
	position: fixed !important;
	inset: auto !important;
	bottom: 24px !important;
	right: 24px !important;
	width: auto !important;
	height: auto !important;
	padding: 0 !important;
	pointer-events: none !important;
	background: transparent !important;
	z-index: 999999 !important;
}

.mlabs-is-toast .mlabs-popup-dialog {
	pointer-events: auto !important;
	width: 380px !important;
	max-width: calc(100vw - 32px) !important;
	border: 1px solid #e2e8f0;
	border-radius: 12px;
	box-shadow: 0 12px 28px -4px rgba(15, 23, 42, 0.18), 0 4px 8px -2px rgba(15, 23, 42, 0.08);
	transform: translateY(24px) scale(0.96);
}

.mlabs-is-active .mlabs-is-toast .mlabs-popup-dialog,
.mlabs-is-toast.mlabs-is-active .mlabs-popup-dialog {
	transform: translateY(0) scale(1) !important;
	opacity: 1 !important;
}

.mlabs-is-closing .mlabs-is-toast .mlabs-popup-dialog,
.mlabs-is-toast.mlabs-is-closing .mlabs-popup-dialog {
	transform: translateY(20px) scale(0.96) !important;
	opacity: 0 !important;
}

.mlabs-icon-toast {
	background: #f0fdf4;
	color: #16a34a;
}

/* ========================================================
   10. Responsive cho Thiết bị di động (< 640px)
   ======================================================== */
@media (max-width: 639px) {
	.mlabs-popup-container {
		padding: 12px;
	}

	.mlabs-popup-dialog {
		max-width: 100% !important;
	}

	.mlabs-popup-content-wrap {
		padding: 22px 18px 20px;
	}

	.mlabs-popup-title {
		font-size: 17px;
	}

	.mlabs-popup-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.mlabs-popup-btn {
		width: 100%;
		text-align: center;
	}

	.mlabs-popup-container.mlabs-is-toast {
		bottom: 12px !important;
		right: 12px !important;
		left: 12px !important;
	}

	.mlabs-is-toast .mlabs-popup-dialog {
		width: 100% !important;
		max-width: 100% !important;
	}
}
