/**
 * BNSG Barcode Scanner — giao diện quét mã vạch.
 * Nhận diện: hồng #FF5698, kem #FDF6EE, Nunito + Roboto.
 */

.bbs-scanner {
	--bbs-pink: #ff5698;
	--bbs-pink-dark: #e03d7e;
	--bbs-cream: #fdf6ee;
	--bbs-ink: #2f2a2c;
	--bbs-muted: #7d7378;

	max-width: 560px;
	margin: 0 auto;
	padding: 20px;
	background: var(--bbs-cream);
	border-radius: 20px;
	box-sizing: border-box;
	font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
	color: var(--bbs-ink);
}

.bbs-scanner *,
.bbs-scanner *::before,
.bbs-scanner *::after {
	box-sizing: border-box;
}

/* Các rule display bên dưới có độ ưu tiên cao hơn UA stylesheet của [hidden]. */
.bbs-scanner [hidden] {
	display: none !important;
}

.bbs-title {
	margin: 0 0 6px;
	font-family: 'Nunito', 'Roboto', sans-serif;
	font-size: 22px;
	font-weight: 800;
	line-height: 1.3;
	color: var(--bbs-ink);
	text-align: center;
}

.bbs-intro {
	margin: 0 0 16px;
	font-size: 15px;
	line-height: 1.5;
	color: var(--bbs-muted);
	text-align: center;
}

/* ---------------------------------------------------------------- */
/*  Khung camera                                                     */
/* ---------------------------------------------------------------- */

.bbs-stage {
	position: relative;
	width: 100%;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	background: #171516;
	border-radius: 16px;
}

/* Trình duyệt cũ không hiểu aspect-ratio. */
@supports not ( aspect-ratio: 4 / 3 ) {
	.bbs-stage {
		height: 0;
		padding-bottom: 75%;
	}
}

.bbs-video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	background: #171516;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.bbs-scanner.is-live .bbs-video {
	opacity: 1;
}

.bbs-idle {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 20px;
	color: rgba( 255, 255, 255, 0.72 );
	font-size: 14px;
	text-align: center;
}

.bbs-scanner.is-live .bbs-idle {
	display: none;
}

.bbs-frame {
	position: absolute;
	top: 20%;
	right: 5%;
	bottom: 20%;
	left: 5%;
	display: none;
	border: 2px solid rgba( 255, 255, 255, 0.9 );
	border-radius: 12px;
	box-shadow: 0 0 0 100vmax rgba( 0, 0, 0, 0.32 );
}

.bbs-scanner.is-live .bbs-frame {
	display: block;
}

.bbs-laser {
	position: absolute;
	right: 8px;
	left: 8px;
	height: 2px;
	background: var(--bbs-pink);
	border-radius: 2px;
	box-shadow: 0 0 12px 2px rgba( 255, 86, 152, 0.9 );
	animation: bbs-scan 2s ease-in-out infinite;
}

@keyframes bbs-scan {
	0%, 100% { top: 10%; }
	50% { top: 90%; }
}

@media ( prefers-reduced-motion: reduce ) {
	.bbs-laser {
		top: 50%;
		animation: none;
	}
}

.bbs-torch {
	position: absolute;
	top: 10px;
	right: 10px;
	width: 42px;
	height: 42px;
	padding: 0;
	background: rgba( 0, 0, 0, 0.45 );
	border: 0;
	border-radius: 50%;
	color: #fff;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
}

.bbs-torch.is-on {
	background: var(--bbs-pink);
}

/* ---------------------------------------------------------------- */
/*  Trạng thái + nút                                                 */
/* ---------------------------------------------------------------- */

.bbs-status {
	min-height: 22px;
	margin: 12px 0 0;
	font-size: 14px;
	line-height: 1.45;
	color: var(--bbs-muted);
	text-align: center;
}

.bbs-status.is-error {
	color: #c62828;
	font-weight: 500;
}

.bbs-actions {
	display: flex;
	flex-wrap: wrap; /* Chữ nút bị theme viết hoa → dài ra thì xuống dòng, không bóp nhau. */
	gap: 10px;
	justify-content: center;
	margin-top: 12px;
}

.bbs-actions .bbs-btn {
	flex: 1 1 auto;
	max-width: 320px;
}

.bbs-btn {
	display: inline-block;
	padding: 13px 22px;
	background: #fff;
	border: 1.5px solid rgba( 47, 42, 44, 0.16 );
	border-radius: 999px;
	color: var(--bbs-ink);
	font-family: 'Nunito', 'Roboto', sans-serif;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: transform 0.15s ease, background 0.15s ease;
}

.bbs-btn:hover {
	transform: translateY( -1px );
}

.bbs-btn:disabled {
	opacity: 0.6;
	cursor: default;
	transform: none;
}

.bbs-btn-primary {
	background: var(--bbs-pink);
	border-color: var(--bbs-pink);
	color: #fff;
}

.bbs-btn-primary:hover {
	background: var(--bbs-pink-dark);
	border-color: var(--bbs-pink-dark);
	color: #fff;
}

.bbs-btn-ghost {
	padding: 9px 16px;
	font-size: 14px;
}

/* ---------------------------------------------------------------- */
/*  Kết quả                                                          */
/* ---------------------------------------------------------------- */

.bbs-result {
	margin-top: 16px;
}

.bbs-card {
	display: flex;
	gap: 14px;
	padding: 16px;
	background: #fff;
	border-radius: 16px;
	box-shadow: 0 6px 20px rgba( 47, 42, 44, 0.08 );
}

.bbs-result.is-empty .bbs-card {
	flex-direction: column;
	text-align: center;
}

.bbs-card-img {
	flex: 0 0 96px;
	width: 96px;
	height: 96px;
	object-fit: cover;
	border-radius: 12px;
}

.bbs-card-body {
	flex: 1;
	min-width: 0;
}

.bbs-badge {
	display: inline-block;
	margin-bottom: 6px;
	padding: 3px 10px;
	background: rgba( 255, 86, 152, 0.12 );
	border-radius: 999px;
	color: var(--bbs-pink-dark);
	font-size: 12px;
	font-weight: 700;
}

.bbs-card-title {
	margin: 0 0 6px;
	font-family: 'Nunito', 'Roboto', sans-serif;
	font-size: 17px;
	font-weight: 800;
	line-height: 1.35;
	overflow-wrap: break-word;
}

.bbs-price {
	margin-bottom: 4px;
	color: var(--bbs-pink-dark);
	font-size: 16px;
	font-weight: 700;
}

.bbs-sku {
	margin-bottom: 12px;
	color: var(--bbs-muted);
	font-size: 13px;
}

.bbs-card-note {
	margin: 0 0 12px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--bbs-muted);
	overflow-wrap: break-word;
}

.bbs-card .bbs-btn {
	width: 100%;
	margin-top: 8px;
}

/* Xếp DỌC ở mọi bề ngang — không phụ thuộc breakpoint.
   Để link và nút cùng hàng là hỏng: theme viết hoa chữ nút nên nút rất rộng,
   phần link (flex:1 + min-width:0) co được về gần 0 → xuống dòng từng ký tự. */
.bbs-linkbox {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	gap: 8px;
	margin-top: 12px;
	padding: 10px 12px;
	background: var(--bbs-cream);
	border-radius: 12px;
}

.bbs-linktext {
	color: var(--bbs-muted);
	font-size: 12px;
	line-height: 1.45;
	overflow-wrap: anywhere; /* Chỉ cắt khi thật sự cần, không cắt bừa từng ký tự. */
}

.bbs-linkbox .bbs-btn {
	width: 100%;
	margin-top: 0;
}

/* ---------------------------------------------------------------- */
/*  Nhập tay / chụp ảnh                                              */
/* ---------------------------------------------------------------- */

.bbs-alt {
	margin-top: 16px;
	padding: 12px 14px;
	background: #fff;
	border-radius: 14px;
}

.bbs-alt > summary {
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	color: var(--bbs-pink-dark);
	list-style: none;
}

.bbs-alt > summary::-webkit-details-marker {
	display: none;
}

.bbs-alt > summary::before {
	content: '▸ ';
}

.bbs-alt[open] > summary::before {
	content: '▾ ';
}

.bbs-manual-form {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: 12px;
}

.bbs-manual-input {
	/* Cơ sở 190px + cho xuống dòng: chật thì nút "Tra cứu" tụt xuống hàng dưới,
	   thay vì bóp ô nhập lại còn vài ký tự. */
	flex: 1 1 190px;
	min-width: 0;
	padding: 12px 14px;
	background: var(--bbs-cream);
	border: 1.5px solid rgba( 47, 42, 44, 0.14 );
	border-radius: 999px;
	font-size: 16px; /* >=16px để iOS không tự phóng to. */
	color: var(--bbs-ink);
}

.bbs-manual-input:focus {
	border-color: var(--bbs-pink);
	outline: none;
}

.bbs-manual-form .bbs-btn {
	flex: 1 0 auto;
	padding: 12px 18px;
}

.bbs-photo {
	position: relative;
	display: block;
	margin-top: 10px;
	padding: 12px;
	border: 1.5px dashed rgba( 255, 86, 152, 0.5 );
	border-radius: 12px;
	color: var(--bbs-pink-dark);
	font-size: 14px;
	font-weight: 600;
	text-align: center;
	cursor: pointer;
}

.bbs-photo input[type="file"] {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}

/* 480px: iPhone đời mới ngang 390–430px vẫn phải dùng bố cục dọc,
   để 420px thì máy 430px rơi ra ngoài → thẻ bị chật. */
@media ( max-width: 480px ) {
	.bbs-scanner {
		padding: 14px;
		border-radius: 16px;
	}

	.bbs-card {
		flex-direction: column;
	}

	.bbs-card-img {
		width: 100%;
		height: 160px;
		flex-basis: auto;
	}
}
