/**
 * Maxweb Demo Viewer — giao diện nút và cửa sổ xem demo.
 */

:root {
	--mdv-accent: #d3011b;      /* đỏ nhận diện Maxweb */
	--mdv-accent-ink: #ffffff;
	--mdv-price: #e81a05;       /* đỏ dùng cho giá, khớp .amount trên site */
	--mdv-radius: 14px;
}

/**
 * Chặn theme đè kích thước và lề.
 *
 * Flatsome áp cho MỌI <button>:
 *   - min-height ~38.8px  -> nút vuông 30x30 bị kéo thành bầu dục
 *   - margin-bottom 1em   -> trong thanh flex căn giữa, nút bị đẩy lệch lên trên
 * Các thuộc tính dưới đây phải thắng tuyệt đối.
 */
.mdv-btn,
.mdv-icon,
.mdv-dev,
.mdv-modal button,
.mdv-modal a.mdv-btn {
	min-width: 0 !important;
	min-height: 0 !important;
	max-width: none;
	line-height: 1 !important;
	letter-spacing: normal !important;
	text-transform: none !important;
	box-shadow: none;
	box-sizing: border-box !important;
	font-family: inherit;
	vertical-align: middle;
}

/* Mọi nút bên trong cửa sổ xem demo đều do flex tự căn, không cần lề nào. */
.mdv-icon,
.mdv-dev,
.mdv-modal .mdv-btn,
.mdv-modal button,
.mdv-modal a.mdv-btn,
.mdv-newtab {
	margin: 0 !important;
}

/* ------------------------------------------------------------------ */
/* Nút                                                                 */
/* ------------------------------------------------------------------ */

.mdv-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	padding: 9px 18px;
	border: 0;
	border-radius: 8px;
	background: var(--mdv-accent);
	color: #fff;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	transition: filter .18s ease, transform .18s ease, box-shadow .18s ease;
	-webkit-appearance: none;
	appearance: none;
}

.mdv-btn:hover,
.mdv-btn:focus-visible {
	color: #fff;
	filter: brightness(1.08);
	box-shadow: 0 6px 18px rgba(0, 0, 0, .16);
}

.mdv-btn:active {
	transform: translateY(1px);
}

.mdv-btn__icon {
	flex: 0 0 auto;
}

.mdv-btn--loop,
.mdv-btn--card {
	width: 100%;
	margin: 8px 0 0 !important;
}

/* Nút phụ để tông trung tính: cạnh nút chính màu đỏ, hai sắc đỏ đặt sát nhau
   sẽ tranh nhau và không còn điểm nhấn nào rõ ràng. */
.mdv-btn--ghost {
	background: #fff;
	color: #334155;
	border: 1px solid rgba(15, 23, 42, .18);
}

.mdv-btn--ghost:hover,
.mdv-btn--ghost:focus-visible {
	color: #0f172a;
	background: rgba(15, 23, 42, .05);
	border-color: rgba(15, 23, 42, .3);
	box-shadow: none;
}

.mdv-btn.is-busy {
	opacity: .65;
	pointer-events: none;
}

/* ------------------------------------------------------------------ */
/* Lưới sản phẩm mẫu (shortcode)                                       */
/* ------------------------------------------------------------------ */

.mdv-grid {
	display: grid;
	grid-template-columns: repeat(var(--mdv-cols, 4), minmax(0, 1fr));
	gap: 22px;
}

.mdv-card {
	display: flex;
	flex-direction: column;
	border: 1px solid rgba(15, 23, 42, .1);
	border-radius: var(--mdv-radius);
	overflow: hidden;
	background: #fff;
	transition: box-shadow .2s ease, transform .2s ease;
}

.mdv-card:hover {
	transform: translateY(-3px);
	box-shadow: 0 14px 34px rgba(15, 23, 42, .12);
}

.mdv-card__thumb {
	display: block;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #f1f3f6;
}

.mdv-card__thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top center;
	display: block;
}

.mdv-card__body {
	padding: 14px 16px 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	flex: 1;
}

.mdv-card__title {
	margin: 0;
	font-size: 15px;
	line-height: 1.4;
}

.mdv-card__title a {
	color: inherit;
	text-decoration: none;
}

.mdv-card__price {
	font-size: 14px;
	font-weight: 700;
	color: var(--mdv-price);
	margin-top: auto;
}

@media (max-width: 1024px) {
	.mdv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
	.mdv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}

@media (max-width: 420px) {
	.mdv-grid { grid-template-columns: 1fr; }
}

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

.mdv-modal[hidden] {
	display: none;
}

.mdv-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
}

.mdv-modal__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(6, 10, 20, .82);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	animation: mdv-fade .22s ease;
}

.mdv-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	/* Tỉ lệ khung hình đặt trong phần cài đặt, đổ vào đây bằng biến CSS. */
	width: var(--mdv-w, 92%);
	height: var(--mdv-h, 90%);
	max-width: var(--mdv-maxw, 1320px);
	background: #0e1116;
	border-radius: var(--mdv-radius);
	overflow: hidden;
	box-shadow: 0 30px 80px rgba(0, 0, 0, .6);
	animation: mdv-pop .24s cubic-bezier(.2, .9, .3, 1);
}

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

@keyframes mdv-pop {
	from { opacity: 0; transform: translateY(14px) scale(.985); }
	to   { opacity: 1; transform: none; }
}

body.mdv-open {
	overflow: hidden;
}

/* Thanh trình duyệt giả lập ------------------------------------------ */

.mdv-bar {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 12px;
	background: #fff;
	border-bottom: 1px solid rgba(15, 23, 42, .08);
	flex: 0 0 auto;
}

/* Mọi điều khiển trên thanh cùng một chiều cao thì hàng mới thẳng và cân. */
.mdv-bar .mdv-icon,
.mdv-bar .mdv-newtab,
.mdv-bar .mdv-devices {
	height: 30px;
}

.mdv-dots {
	display: flex;
	align-items: center;
	gap: 6px;
	flex: 0 0 auto;
	height: 30px;
	padding-right: 2px;
}

.mdv-dots i {
	width: 11px;
	height: 11px;
	border-radius: 50%;
	display: block;
}

.mdv-dots i:nth-child(1) { background: #ff5f57; }
.mdv-dots i:nth-child(2) { background: #febc2e; }
.mdv-dots i:nth-child(3) { background: #28c840; }

.mdv-url {
	flex: 1 1 auto;
	min-width: 0;
	height: 30px;
	line-height: 30px;
	background: rgba(15, 23, 42, .05);
	border-radius: 8px;
	padding: 0 12px;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	color: #64748b;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mdv-devices {
	display: flex;
	align-items: center;
	gap: 2px;
	background: rgba(15, 23, 42, .05);
	border-radius: 9px;
	padding: 3px;
	flex: 0 0 auto;
}

.mdv-dev {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 24px;
	flex: 0 0 30px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: #64748b;
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
	padding: 0;
}

.mdv-dev:hover { color: #0f172a; }

.mdv-dev.is-active {
	background: #fff;
	color: var(--mdv-accent);
	box-shadow: 0 1px 2px rgba(15, 23, 42, .16);
}

.mdv-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 30px;
	height: 30px;
	/* flex-basis cố định: thanh công cụ chật cũng không bóp méo hình tròn. */
	flex: 0 0 30px;
	aspect-ratio: 1 / 1;
	border: 0;
	border-radius: 50%;
	/* Để trống khi nghỉ, chỉ tô nền lúc rê chuột — thanh công cụ nhẹ mắt hơn
	   là bày một dãy nút xám lúc nào cũng hiện. */
	background: transparent;
	color: #64748b;
	cursor: pointer;
	padding: 0;
	transition: background .15s ease, color .15s ease;
}

.mdv-icon:hover {
	background: rgba(15, 23, 42, .07);
	color: #0f172a;
}

.mdv-icon--close:hover {
	background: var(--mdv-accent);
	color: var(--mdv-accent-ink);
}

/* Viền tiêu điểm rõ ràng và cùng tông, thay cho viền mặc định của theme. */
.mdv-icon:focus-visible,
.mdv-dev:focus-visible,
.mdv-newtab:focus-visible,
.mdv-btn:focus-visible {
	outline: 2px solid var(--mdv-accent);
	outline-offset: 2px;
}

.mdv-icon:focus:not(:focus-visible),
.mdv-dev:focus:not(:focus-visible),
.mdv-newtab:focus:not(:focus-visible) {
	outline: none;
}

.mdv-icon.is-spinning svg {
	animation: mdv-spin .7s linear infinite;
}

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

/* Nền nhạt cùng tông thay cho viền đỏ đậm — vẫn nổi bật nhưng không chọi
   với nút X và các icon xám bên cạnh. */
.mdv-newtab {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	padding: 0 12px;
	border: 0;
	border-radius: 8px;
	background: rgba(var(--mdv-accent-rgb, 211, 1, 27), .09);
	color: var(--mdv-accent);
	font-size: 12px;
	font-weight: 600;
	line-height: 1;
	white-space: nowrap;
	text-decoration: none;
	transition: background .15s ease;
}

.mdv-newtab:hover {
	background: rgba(var(--mdv-accent-rgb, 211, 1, 27), .16);
	color: var(--mdv-accent);
}

/* Thanh tiến trình mảnh: hiện khi trang demo đã bắt đầu dựng nhưng
   tài nguyên con còn đang tải (thường gặp ở chế độ proxy). */
.mdv-progress {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 3px;
	background: rgba(211, 1, 27, .15);
	overflow: hidden;
	z-index: 4;
}

.mdv-progress[hidden] { display: none; }

.mdv-progress span {
	position: absolute;
	inset: 0 auto 0 0;
	width: 35%;
	background: var(--mdv-accent);
	animation: mdv-slide 1.1s ease-in-out infinite;
}

@keyframes mdv-slide {
	0%   { left: -35%; }
	100% { left: 100%; }
}

/* Khung xem ---------------------------------------------------------- */

.mdv-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #12161d;
	overflow: hidden;
}

.mdv-frame {
	position: relative;
	width: 100%;
	height: 100%;
	background: #fff;
	transition: width .3s ease, height .3s ease, border-radius .3s ease;
}

.mdv-frame iframe {
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
	background: #fff;
}

.mdv-stage[data-device="tablet"] .mdv-frame {
	width: 834px;
	max-width: calc(100% - 40px);
	height: calc(100% - 32px);
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 0 0 8px #1f2430, 0 20px 50px rgba(0, 0, 0, .5);
}

.mdv-stage[data-device="mobile"] .mdv-frame {
	width: 390px;
	max-width: calc(100% - 40px);
	height: calc(100% - 32px);
	max-height: 844px;
	border-radius: 22px;
	overflow: hidden;
	box-shadow: 0 0 0 8px #1f2430, 0 20px 50px rgba(0, 0, 0, .5);
}

/* Trạng thái tải ----------------------------------------------------- */

.mdv-loading {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 14px;
	background: #12161d;
	color: #cbd5e1;
	font-size: 14px;
	z-index: 2;
}

.mdv-loading[hidden] { display: none; }

.mdv-loading p { margin: 0; }

.mdv-spinner {
	width: 34px;
	height: 34px;
	border: 3px solid rgba(255, 255, 255, .18);
	border-top-color: #fff;
	border-radius: 50%;
	animation: mdv-spin .8s linear infinite;
}

.mdv-error {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 10px;
	padding: 28px;
	text-align: center;
	background: #12161d;
	color: #e2e8f0;
	z-index: 3;
}

.mdv-error[hidden] { display: none; }

.mdv-error__icon { font-size: 38px; line-height: 1; }

.mdv-error h4 {
	margin: 0;
	font-size: 17px;
	color: #fff;
}

.mdv-error p {
	margin: 0;
	max-width: 460px;
	font-size: 13.5px;
	line-height: 1.65;
	color: #94a3b8;
}

.mdv-error__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	justify-content: center;
	margin-top: 6px;
}

/* Trên nền tối của khung báo lỗi thì đảo lại cho đọc được. */
.mdv-error .mdv-btn--ghost {
	color: #cbd5e1;
	background: transparent;
	border-color: rgba(255, 255, 255, .28);
}

.mdv-error .mdv-btn--ghost:hover {
	color: #fff;
	background: rgba(255, 255, 255, .08);
	border-color: rgba(255, 255, 255, .45);
}

/* Thanh chốt đơn ----------------------------------------------------- */

.mdv-cta {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 10px 14px;
	background: #fff;
	border-top: 1px solid rgba(15, 23, 42, .08);
	flex: 0 0 auto;
}

.mdv-cta[hidden] { display: none; }

.mdv-cta__thumb {
	width: 44px;
	height: 44px;
	border-radius: 8px;
	object-fit: cover;
	object-position: top center;
	flex: 0 0 auto;
	background: #f1f3f6;
}

.mdv-cta__thumb[src=""] { display: none; }

.mdv-cta__info {
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1 1 auto;
}

.mdv-cta__title {
	font-size: 14px;
	color: #0f172a;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.mdv-cta__price {
	font-size: 13px;
	font-weight: 700;
	color: var(--mdv-price);
}

.mdv-cta__actions {
	display: flex;
	gap: 8px;
	flex: 0 0 auto;
}

.mdv-cta__actions .mdv-btn {
	padding: 9px 16px;
	font-size: 13px;
}

/* Màn hình nhỏ ------------------------------------------------------- */

@media (max-width: 900px) {
	/* Vẫn giữ dạng cửa sổ nổi có bo góc, không chiếm trọn màn hình —
	   để người xem luôn thấy rõ đây là khung xem thử, thoát ra được ngay. */
	.mdv-modal__dialog {
		width: var(--mdv-mw, 96%);
		height: var(--mdv-mh, 96%);
		max-width: none;
		border-radius: 14px;
	}

	.mdv-bar {
		gap: 8px;
		padding: 9px 10px;
	}

	.mdv-devices {
		display: none;
	}

	.mdv-newtab {
		padding: 0 10px;
		font-size: 11px;
	}

	.mdv-icon {
		flex: 0 0 28px;
		width: 28px;
		height: 28px;
	}

	.mdv-bar .mdv-icon,
	.mdv-bar .mdv-newtab,
	.mdv-bar .mdv-devices,
	.mdv-dots {
		height: 28px;
	}

	.mdv-url {
		height: 28px;
		line-height: 28px;
	}

	.mdv-stage[data-device="tablet"] .mdv-frame,
	.mdv-stage[data-device="mobile"] .mdv-frame {
		width: 100%;
		max-width: none;
		height: 100%;
		max-height: none;
		border-radius: 0;
		box-shadow: none;
	}

	.mdv-cta {
		flex-wrap: wrap;
	}

	.mdv-cta__actions {
		width: 100%;
	}

	.mdv-cta__actions .mdv-btn {
		flex: 1 1 0;
	}
}

@media (max-width: 560px) {
	.mdv-url { font-size: 11px; padding: 5px 9px; }
	.mdv-cta__thumb { display: none; }
}

@media (max-width: 420px) {
	/* Thanh công cụ chật: bỏ ba chấm trang trí, ưu tiên URL và các nút bấm. */
	.mdv-dots { display: none; }
	.mdv-newtab { padding: 5px 8px; }
}

@media (prefers-reduced-motion: reduce) {
	.mdv-modal__backdrop,
	.mdv-modal__dialog,
	.mdv-frame,
	.mdv-btn,
	.mdv-card {
		animation: none !important;
		transition: none !important;
	}
}
