/**
 * Bốc Số VTG — style cho dashboard frontend.
 *
 * MOBILE-FIRST: mọi style mặc định (không media query) là giao diện mobile;
 * @media (min-width: ...) chỉ MỞ RỘNG thêm cho tablet/desktop.
 * Xem chuẩn: docs/DASHBOARD_STANDARDS.md §5.
 *
 * KHÔNG khai báo font-family — kế thừa Inter Tight từ Flatsome (CLAUDE.md §1).
 * Mọi class có tiền tố .bsv- nên không đụng độ theme.
 */

/* ── Full-width: trang plugin chiếm 100% bề rộng trên desktop ─────────
   Router thêm class bsv-page vào <body> ở mọi trang chứa shortcode plugin;
   ghi đè max-width container của Flatsome chỉ trong phạm vi các trang đó. */
body.bsv-page .container,
body.bsv-page .row.row-main {
	max-width: 100% !important;
}

/* ── Header theo vai trò thay cho header Flatsome trên TOÀN BỘ trang ──────
   Router::bodyClass() gắn class bsv-no-theme-header cho mọi trang front-end;
   header plugin được in ngay sau <body> (wp_body_open, xem
   Router::renderGlobalHeader()/render()) rồi ẩn header theme ở đây.
   Liệt kê nhiều selector Flatsome hay dùng — nếu site vẫn còn sót 1 header
   theme nào đó, F12 kiểm tra ID/class thật rồi bổ sung thêm vào đây. */
body.bsv-no-theme-header #header,
body.bsv-no-theme-header .header-wrapper,
body.bsv-no-theme-header #wrapper-navigation,
body.bsv-no-theme-header .top-bar-wrapper,
body.bsv-no-theme-header .stuck-nav-helper {
	display: none !important;
}

/* Chừa khoảng cách nhỏ quanh header plugin — CHỈ ở trang header được chèn
   trực tiếp sau <body> (bài viết, trang tĩnh...), không phải trang dashboard/
   shortcode (đã nằm sẵn trong khung nội dung có lề đúng, thêm margin ở đây
   sẽ làm header bị lệch/thụt vào so với nội dung bên dưới). Chỉ set
   margin-top/trái/phải riêng lẻ — không dùng shorthand để không đè mất
   margin-bottom mặc định của .bsv-header (16px, xem trên). */
body.bsv-header-injected .bsv-header {
	margin-left: 10px;
	margin-right: 10px;
	margin-top: 10px;
}

.bsv {
	/* Xanh y tế (teal) — đổi thương hiệu chỉ cần sửa 2 biến này. */
	--bsv-primary: #0d9488;
	--bsv-primary-dark: #0f766e;
	--bsv-bg: #f6f8fb;
	--bsv-surface: #fff;
	--bsv-border: #e2e8f0;
	--bsv-text: #1e293b;
	--bsv-muted: #64748b;
	--bsv-success: #16a34a;
	--bsv-warning: #d97706;
	--bsv-danger: #dc2626;
	--bsv-radius: 10px;

	color: var(--bsv-text);
	font-size: 15px;
	line-height: 1.55;
}

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

/* ── Header chung mọi trang plugin ──────────────────────────────────── */
.bsv-header {
	align-items: center;
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: var(--bsv-radius);
	display: flex;
	justify-content: space-between;
	margin-bottom: 8px;
	padding: 6px;
}

@media (min-width: 768px) {
	.bsv-header { margin-bottom: 16px; padding: 8px 14px; }
}

.bsv-header__logo { color: var(--bsv-text); display: flex; align-items: center; text-decoration: none; }
.bsv-header__logo img { display: block; height: 36px !important; max-width: 160px; object-fit: contain; width: auto !important; }

.bsv-header__nav { display: flex; gap: 4px; }

.bsv-header__link {
	/* appearance:none — nút "Thêm vào Màn hình chính" là <button>, các mục
	   còn lại là <a>. Thiếu dòng này, Safari/Chrome tự vẽ THÊM khung nút hệ
	   điều hành (-webkit-appearance mặc định của button) chồng lên box đã
	   canh giữa bằng flex, đẩy icon lệch lên trên dù CSS flex đã đúng. Đây
	   mới là nguyên nhân thật, không phải do font/line-height hay path SVG. */
	appearance: none;
	-webkit-appearance: none;
	align-items: center;
	background: none;
	border: 0;
	border-radius: 8px;
	color: var(--bsv-text);
	cursor: pointer;
	display: inline-flex;
	font: inherit;
	font-size: 14px;
	font-weight: 600;
	gap: 6px;
	line-height: 1;
	margin: 0;
	min-height: 40px;
	padding: 6px 10px;
	text-decoration: none;
}

.bsv-header__link:hover { background: var(--bsv-bg); color: var(--bsv-primary); }

/*
 * display:flex (không phải inline mặc định) để trung hoà `vertical-align:
 * -3px` khai báo chung cho .bsv-icon (dùng để canh icon với CHỮ đứng cạnh ở
 * nơi khác) — vertical-align chỉ có tác dụng trong ngữ cảnh inline, còn
 * trong flex container thì bị bỏ qua nên icon luôn nằm giữa tuyệt đối, không
 * còn bị đẩy xuống tạo khoảng trống thừa phía dưới như trước.
 */
.bsv-header__icon {
	align-items: center;
	display: inline-flex;
	font-size: 18px;
	justify-content: center;
	line-height: 1;
	position: relative;
}

.bsv-header__avatar {
	border-radius: 50%;
	display: block;
	height: 24px !important;
	object-fit: cover;
	width: 24px !important;
}

/* Chấm đỏ số thông báo chưa đọc. */
.bsv-header__badge {
	background: var(--bsv-danger);
	border-radius: 999px;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 1;
	padding: 2px 5px;
	position: absolute;
	right: -8px;
	top: -6px;
}

/*
 * Nút quét QR tự check-in — chỉ bệnh nhân/khách chưa đăng ký mới thấy
 * (.bsv-header--has-qr, xem header.php). Mobile-first: mặc định (mobile)
 * THAY hẳn vị trí logo, phóng to + bo tròn; từ 768px quay lại hiện logo,
 * ẩn nút QR (nhân viên/bác sĩ/quản lý luôn thấy logo bình thường vì header
 * của họ không có class --has-qr nên không bị 2 quy tắc dưới đây tác động).
 */
.bsv-header__qr {
	/* !important trên các thuộc tính hộp: đây là thẻ <button> thật, Flatsome/
	   UX Builder thường có CSS toàn cục cho mọi button (border-radius, padding
	   riêng của theme) có thể đè specificity thường — khoá cứng để chắc chắn
	   ra đúng hình tròn 55x55 bất kể theme can thiệp gì. */
	appearance: none !important;
	-webkit-appearance: none !important;
	align-items: center;
	background: var(--bsv-primary) !important;
	background-image: none !important;
	border: 0 !important;
	border-radius: 50% !important;
	box-shadow: none !important;
	box-sizing: border-box !important;
	color: #fff;
	cursor: pointer;
	display: none;
	flex-shrink: 0;
	height: 48px !important;
	justify-content: center;
	line-height: 1 !important;
	margin: 0 !important;
	min-height: 0 !important;
	min-width: 0 !important;
	padding: 0 !important;
	width: 48px !important;
}

.bsv-header__qr:hover { opacity: 0.9; }

.bsv-header--has-qr .bsv-header__logo { display: none; }
.bsv-header--has-qr .bsv-header__qr { display: inline-flex; }

@media (min-width: 768px) {
	.bsv-header__qr { display: none !important; }
	.bsv-header--has-qr .bsv-header__logo { display: flex; }
}

/* Modal quét/xác nhận check-in QR — JS thuần (assets/js/qr-checkin.js), dựng
   DOM trực tiếp vì header hiện ở cả trang chưa nạp Alpine. */
.bsv-qr-modal {
	align-items: flex-end;
	background: rgba(0, 0, 0, 0.5);
	bottom: 0;
	display: flex;
	justify-content: center;
	left: 0;
	/* transform ép Safari vẽ lớp này trên GPU compositing layer riêng —
	   không có dòng này, Safari đôi khi vẽ lệch ngang phần tử fixed đúng lúc
	   thanh địa chỉ thu/giãn khi cuộn (lỗi hiển thị đặc trưng của Safari). */
	overscroll-behavior: contain;
	position: fixed;
	right: 0;
	top: 0;
	transform: translateZ(0);
	z-index: 9999;
}

.bsv-qr-modal__box {
	background: var(--bsv-surface);
	border-radius: var(--bsv-radius) var(--bsv-radius) 0 0;
	max-height: 90vh;
	max-height: 90dvh;
	overflow-y: auto;
	padding: 16px;
	width: 100%;
}

@media (min-width: 768px) {
	.bsv-qr-modal { align-items: center; justify-content: center; }
	.bsv-qr-modal__box { border-radius: var(--bsv-radius); max-width: 420px; }
}

.bsv-qr-modal video { background: #000; border-radius: 8px; width: 100%; }

/* Mobile-first: chỉ icon; từ 768px hiện thêm chữ. */
.bsv-header__text { display: none; }

@media (min-width: 768px) {
	.bsv-header__text { display: inline; }

	/* Tên người dùng có thể dài — cắt gọn thay vì đẩy vỡ layout header. */
	.bsv-header__link .bsv-header__text {
		display: inline-block;
		max-width: 140px;
		overflow: hidden;
		text-overflow: ellipsis;
		vertical-align: middle;
		white-space: nowrap;
	}
}

/* ── Bố cục: 1 cột trên mobile, nở ra từ 768px ──────────────────────── */
.bsv-grid {
	display: grid;
	gap: 12px;
	grid-template-columns: 1fr;
}

@media (min-width: 768px) {
	.bsv-grid { gap: 16px; }
	.bsv-grid--2 { grid-template-columns: repeat(2, 1fr); }
	.bsv-grid--3 { grid-template-columns: repeat(3, 1fr); }
	.bsv-grid--4 { grid-template-columns: repeat(4, 1fr); }
	.bsv-grid--span-2 { grid-column: span 2; }
}

/* ── Trang profile thương hiệu công khai (bác sĩ / phòng khám) ───────── */
.bsv-profile__cover {
	border-radius: var(--bsv-radius);
	margin-bottom: 14px;
	overflow: hidden;
}

.bsv-profile__cover img {
	display: block;
	height: 160px !important;
	object-fit: cover;
	width: 100% !important;
}

@media (min-width: 768px) {
	.bsv-profile__cover img { height: 260px !important; }
}

.bsv-profile__head {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
}

.bsv-profile__avatar {
	border: 1px solid var(--bsv-border);
	border-radius: 50%;
	display: block;
	height: 96px !important;
	object-fit: cover;
	width: 96px !important;
}

.bsv-profile__name {
	font-size: 20px;
	font-weight: 700;
	margin: 0 0 4px;
}

.bsv-profile__links {
	display: grid;
	gap: 8px;
	list-style: none;
	margin: 0;
	padding: 0;
}

.bsv-card {
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: var(--bsv-radius);
	padding: 14px;
}

@media (min-width: 768px) {
	.bsv-card { padding: 16px; }
}

.bsv-card__title {
	font-size: 15px;
	font-weight: 600;
	margin: 0 0 12px;
}

.bsv-toolbar {
	align-items: center;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: 14px;
}

/* Tiêu đề giãn hết chỗ trống → nút hành động luôn CÙNG HÀNG bên phải. */
.bsv-toolbar__title {
	flex: 1 1 auto;
	font-size: 20px;
	margin: 0;
	min-width: 0;
}

@media (min-width: 768px) {
	.bsv-toolbar { margin-bottom: 16px; }
	.bsv-toolbar__title { font-size: 24px; }
}

.bsv-toolbar__spacer { flex: 1 1 auto; }

/* Toolbar có nút hành động ngắn (VD: "Xem tất cả" ở box Tin tức trang chủ) —
   ép luôn cùng hàng bên phải, tiêu đề tự cắt gọn nếu chật thay vì rớt dòng. */
.bsv-toolbar--tight .bsv-toolbar { flex-wrap: nowrap; margin-bottom: 14px; }
.bsv-toolbar--tight .bsv-toolbar__title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Thẻ chỉ số ─────────────────────────────────────────────────────── */
.bsv-stat {
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: var(--bsv-radius);
	padding: 12px 14px;
}

.bsv-stat__label {
	color: var(--bsv-muted);
	font-size: 13px;
}

.bsv-stat__value {
	font-size: 24px;
	font-weight: 700;
	line-height: 1.2;
}

@media (min-width: 768px) {
	.bsv-stat { padding: 14px 16px; }
	.bsv-stat__value { font-size: 26px; }
}

/* Biến thể màu cho thẻ chỉ số: tô viền + số cho dễ phân biệt. */
.bsv-stat--info { border-color: #3b82f6; }
.bsv-stat--info .bsv-stat__value { color: #2563eb; }

.bsv-stat--primary { border-color: var(--bsv-primary); }
.bsv-stat--primary .bsv-stat__value { color: var(--bsv-primary); }

.bsv-stat--warning { border-color: var(--bsv-warning); }
.bsv-stat--warning .bsv-stat__value { color: var(--bsv-warning); }

.bsv-stat--danger { border-color: var(--bsv-danger); }
.bsv-stat--danger .bsv-stat__value { color: var(--bsv-danger); }

/* Số bốc đang gọi — to, rõ, nhìn được từ xa (màn hình chờ / điện thoại lễ tân). */
.bsv-now-serving {
	background: linear-gradient(135deg, var(--bsv-primary), var(--bsv-primary-dark));
	border-radius: var(--bsv-radius);
	color: #fff;
	padding: 18px;
	text-align: center;
}

.bsv-now-serving__number {
	font-size: 48px;
	font-weight: 800;
	line-height: 1;
}

@media (min-width: 768px) {
	.bsv-now-serving { padding: 20px; }
	.bsv-now-serving__number { font-size: 56px; }
}

/* ── Bảng dữ liệu: MẶC ĐỊNH là danh sách thẻ (mobile) ────────────────
   Mỗi <td> cần data-label để hiện nhãn cột. Từ 640px chuyển thành bảng. */
.bsv-table-wrap {
	-webkit-overflow-scrolling: touch;
	overflow-x: auto;
}

.bsv-table {
	border-collapse: collapse;
	width: 100%;
}

.bsv-table,
.bsv-table tbody,
.bsv-table tr,
.bsv-table td {
	display: block;
	width: 100%;
}

.bsv-table thead { display: none; }

.bsv-table tr {
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: var(--bsv-radius);
	margin-bottom: 10px;
	padding: 6px 4px;
}

.bsv-table td {
	display: flex;
	gap: 12px;
	justify-content: space-between;
	padding: 7px 12px;
}

.bsv-table td::before {
	color: var(--bsv-muted);
	content: attr(data-label);
	flex-shrink: 0;
	font-size: 13px;
	font-weight: 600;
}

.bsv-table td:empty { display: none; }

.bsv-table__queue {
	font-size: 18px;
	font-weight: 700;
}

@media (min-width: 640px) {
	.bsv-table { display: table; min-width: 640px; }
	.bsv-table thead { display: table-header-group; }
	.bsv-table tbody { display: table-row-group; }

	.bsv-table tr {
		background: none;
		border: 0;
		border-radius: 0;
		display: table-row;
		margin: 0;
		padding: 0;
	}

	.bsv-table td,
	.bsv-table th {
		border-bottom: 1px solid var(--bsv-border);
		display: table-cell;
		padding: 10px 12px;
		text-align: left;
		vertical-align: middle;
		width: auto;
	}

	.bsv-table td::before { content: none; }
	.bsv-table td:empty { display: table-cell; }

	.bsv-table th {
		color: var(--bsv-muted);
		font-size: 13px;
		font-weight: 600;
		white-space: nowrap;
	}

	.bsv-table tbody tr:hover { background: var(--bsv-bg); }

	.bsv-table__queue {
		text-align: center;
		width: 64px;
	}
}

/* ── Thẻ danh sách: grid 3 cột cố định [ảnh | nội dung | icon hành động] ── */
.bsv .bsv-item {
	align-items: center;
	display: grid;
	gap: 12px;
	grid-template-columns: 48px 1fr auto;
}

/* !important để thắng mọi rule img của theme (Flatsome hay ép ảnh 100%). */
.bsv .bsv-item__img,
.bsv .bsv-item__placeholder {
	border: 1px solid var(--bsv-border);
	border-radius: 10px;
	display: block;
	height: 48px !important;
	max-width: none;
	object-fit: cover;
	width: 48px !important;
}

/* Chưa có ảnh: ô chữ cái đầu thay thế. */
.bsv .bsv-item__placeholder {
	align-items: center;
	background: var(--bsv-bg);
	color: var(--bsv-muted);
	display: flex;
	font-size: 18px;
	font-weight: 700;
	justify-content: center;
}

/* Biến thể ảnh tròn (bác sĩ). */
.bsv-item--round .bsv-item__img,
.bsv-item--round .bsv-item__placeholder { border-radius: 50%; }

.bsv-item__body { min-width: 0; }

/* Biến thể .bsv-item dùng làm link (trỏ về trang profile bác sĩ/phòng khám) —
   .bsv-item vốn là <div>, khi render bằng <a> phải reset màu/underline mặc định. */
.bsv-item--link {
	color: inherit;
	text-decoration: none;
}

.bsv-item--link:hover .bsv-item__title { color: var(--bsv-primary); }

.bsv-item__title { font-weight: 600; }

.bsv-item__sub {
	color: var(--bsv-muted);
	font-size: 13px;
	margin-top: 2px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.bsv-item__count {
	background: var(--bsv-bg);
	border: 1px solid var(--bsv-border);
	border-radius: 999px;
	color: var(--bsv-muted);
	font-size: 12px;
	font-weight: 600;
	margin-left: 6px;
	padding: 1px 8px;
	white-space: nowrap;
}

/* ── Danh sách checkbox trong form (chuyên khoa, bác sĩ...) ─────────── */
.bsv-checklist {
	border: 1px solid var(--bsv-border);
	border-radius: 8px;
	max-height: 170px;
	overflow-y: auto;
	padding: 6px 12px;
}

/* Luôn 2 cột cho gọn (nhãn danh mục ngắn nên mobile vẫn vừa). */
.bsv-checklist--2 {
	column-gap: 16px;
	display: grid;
	grid-template-columns: 1fr 1fr;
}

.bsv-checklist--3 {
	column-gap: 16px;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
}

/* Biến thể responsive cho thanh lọc: mobile 2 cột → desktop 3 cột. */
.bsv-checklist--2-3 {
	column-gap: 16px;
	display: grid;
	grid-template-columns: repeat(2, 1fr);
}

/* Mobile 3 cột → desktop 4 cột. */
.bsv-checklist--3-4 {
	column-gap: 16px;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
}

/* Thanh lọc trên danh sách phòng khám/bác sĩ:
   mobile xếp dọc trên-dưới; desktop 2 box theo tỷ lệ 3:4. */
.bsv-filterbar {
	display: grid;
	gap: 12px;
	grid-template-columns: 1fr;
	margin-bottom: 14px;
}

@media (min-width: 768px) {
	.bsv-filterbar { grid-template-columns: 3fr 4fr; }
	.bsv-checklist--2-3 { grid-template-columns: repeat(3, 1fr); }
	.bsv-checklist--3-4 { grid-template-columns: repeat(4, 1fr); }
}

.bsv .bsv-checklist label {
	align-items: center;
	cursor: pointer;
	display: flex;
	font-size: 14px;
	gap: 8px;
	line-height: 1.3;
	margin: 0;
	padding: 4px 0;
}

.bsv .bsv-checklist input[type="checkbox"] {
	flex-shrink: 0;
	height: 16px;
	margin: 0;
	width: 16px;
}

/* Nút icon trần: không viền, không nền, chỉ đổi màu nền nhẹ khi hover. */
.bsv .bsv-icon-btn {
	align-items: center;
	background: none;
	border: 0;
	border-radius: 6px;
	box-shadow: none;
	color: var(--bsv-muted);
	cursor: pointer;
	display: inline-flex;
	font-size: 16px;
	height: 32px;
	justify-content: center;
	line-height: 1;
	margin: 0;
	padding: 0;
	width: 32px;
}

.bsv .bsv-icon-btn:hover { background: var(--bsv-bg); color: var(--bsv-text); }
.bsv .bsv-icon-btn--danger:hover { background: #fee2e2; color: var(--bsv-danger); }

/* ── Nhãn trạng thái ────────────────────────────────────────────────── */
.bsv-badge {
	border-radius: 999px;
	display: inline-block;
	font-size: 12px;
	font-weight: 600;
	padding: 3px 10px;
	white-space: nowrap;
}

.bsv-badge--pending { background: #fef3c7; color: #92400e; }
.bsv-badge--confirmed { background: #ccfbf1; color: #115e59; }
.bsv-badge--checked_in { background: #e0e7ff; color: #3730a3; }
.bsv-badge--in_progress { background: #cffafe; color: #155e75; }
.bsv-badge--completed { background: #dcfce7; color: #166534; }
.bsv-badge--no_show { background: #fee2e2; color: #991b1b; }
.bsv-badge--cancelled { background: #f1f5f9; color: #475569; }
.bsv-badge--active { background: #dcfce7; color: #166534; }
.bsv-badge--inactive { background: #f1f5f9; color: #475569; }

/* ── Form & nút — vùng chạm >= 44px trên mobile ─────────────────────── */
.bsv-field { margin-bottom: 10px; }

.bsv-label {
	display: block;
	font-size: 13px;
	font-weight: 600;
	margin-bottom: 4px;
}

/* Selector kép .bsv .bsv-input để THẮNG style form của Flatsome
   (input[type="text"] có specificity ngang class — thiếu prefix là bị
   theme đè, ô nhập lệch chiều cao so với nút như lỗi ở form OTP). */
.bsv .bsv-input,
.bsv .bsv-select,
.bsv .bsv-textarea {
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: 8px;
	box-shadow: none;
	font-size: 15px; /* >=15px để iOS Safari không tự zoom khi focus */
	/* height:auto + line-height ghi đè height cố định của Flatsome cho
	   select — thiếu 2 dòng này chữ trong dropdown bị cắt chân. */
	height: auto;
	line-height: 1.4;
	margin: 0;
	min-height: 40px;
	padding: 8px 12px;
	width: 100%;
}

.bsv .bsv-input:focus,
.bsv .bsv-select:focus,
.bsv .bsv-textarea:focus {
	border-color: var(--bsv-primary);
	box-shadow: none;
	outline: 2px solid rgba(13, 148, 136, 0.15);
}

.bsv .bsv-textarea { min-height: 90px; resize: vertical; }

.bsv .bsv-input:disabled,
.bsv .bsv-select:disabled,
.bsv .bsv-textarea:disabled {
	background: var(--bsv-bg);
	color: var(--bsv-muted);
	cursor: not-allowed;
	opacity: 0.7;
}

.bsv-btn {
	align-items: center;
	background: var(--bsv-primary);
	border: 1px solid transparent;
	border-radius: 8px;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	font-size: 14px;
	font-weight: 600;
	gap: 6px;
	justify-content: center;
	/* line-height + margin ghi đè style button của Flatsome — thiếu là nút
	   cao hơn ô nhập (lỗi lệch hàng ở ô OTP). */
	line-height: 1.4;
	margin: 0;
	min-height: 40px;
	padding: 8px 14px;
	text-decoration: none;
	white-space: nowrap;
}

.bsv-btn:hover { background: var(--bsv-primary-dark); color: #fff; }
.bsv-btn:disabled { cursor: not-allowed; opacity: 0.55; }

/* Desktop có chuột: gọn hơn nữa; mobile giữ 40px cho vùng chạm. */
@media (min-width: 768px) {
	.bsv-btn { min-height: 36px; padding: 6px 14px; }
	.bsv-btn--sm { min-height: 30px; padding: 4px 10px; }
	.bsv .bsv-input,
	.bsv .bsv-select { min-height: 36px; padding: 6px 12px; }
}

.bsv-btn--ghost {
	background: transparent;
	border-color: var(--bsv-border);
	color: var(--bsv-text);
}

.bsv-btn--ghost:hover { background: var(--bsv-bg); color: var(--bsv-text); }
.bsv-btn--danger { background: var(--bsv-danger); }
.bsv-btn--success { background: var(--bsv-success); }
.bsv-btn--sm { font-size: 13px; min-height: 36px; padding: 5px 11px; }
.bsv-btn--block { width: 100%; }

/* Cụm nút thao tác trong bảng/thẻ. */
.bsv-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

/* Hàng đợi dạng thẻ kéo/thả — đổi thứ tự khám (VD: khách bận việc đúng lúc tới lượt). */
.bsv-queue-cards {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.bsv-queue-card {
	display: flex;
	align-items: center;
	gap: 12px;
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: 10px;
	padding: 10px 12px;
	cursor: grab;
}

.bsv-queue-card.is-dragging { opacity: 0.4; }

.bsv-queue-card__number {
	flex-shrink: 0;
	min-width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--bsv-primary);
	color: #fff;
	border-radius: 8px;
	font-weight: 700;
	font-size: 16px;
}

.bsv-queue-card__body {
	flex: 1;
	min-width: 0;
}

.bsv-queue-card__name {
	font-weight: 600;
}

@media (min-width: 768px) {
	.bsv-queue-card { padding: 8px 12px; }
	.bsv-queue-card__number { min-width: 36px; height: 36px; font-size: 14px; }
}

/* Ảnh QR khổ lớn để in treo tại quầy (kiểu QR chuyển khoản ngân hàng). */
.bsv-qr-poster {
	background: #fff;
	border: 1px solid var(--bsv-border);
	border-radius: var(--bsv-radius);
	padding: 24px;
	text-align: center;
}

.bsv-qr-poster img { border-radius: 8px; height: auto; margin: 14px auto; max-width: 100%; }

.bsv-qr-poster__name { font-size: 20px; font-weight: 700; }
.bsv-qr-poster__hint { color: var(--bsv-text); font-weight: 600; margin-bottom: 10px; }
.bsv-qr-poster__contact { color: var(--bsv-muted); font-size: 14px; }

/* In: chỉ in đúng tấm poster, ẩn toàn bộ phần còn lại của trang. */
@media print {
	body * { visibility: hidden; }
	.bsv-qr-poster, .bsv-qr-poster * { visibility: visible; }
	.bsv-qr-poster { border: 0; left: 0; position: absolute; top: 0; width: 100%; }
}

/* Lưới chọn khung giờ. */
.bsv-slots {
	display: grid;
	gap: 8px;
	grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
}

.bsv-slot {
	background: var(--bsv-surface);
	border: 1px solid var(--bsv-border);
	border-radius: 8px;
	cursor: pointer;
	font-weight: 600;
	min-height: 44px;
	padding: 10px 4px;
	text-align: center;
}

.bsv-slot:disabled {
	background: var(--bsv-bg);
	color: var(--bsv-muted);
	cursor: not-allowed;
	text-decoration: line-through;
}

.bsv-slot.is-active {
	background: var(--bsv-primary);
	border-color: var(--bsv-primary);
	color: #fff;
}

/* ── Tabs ───────────────────────────────────────────────────────────── */
.bsv-tabs {
	-webkit-overflow-scrolling: touch;
	border-bottom: 1px solid var(--bsv-border);
	display: flex;
	gap: 4px;
	margin-bottom: 14px;
	overflow-x: auto;
}

.bsv-tab {
	background: none;
	border: 0;
	border-bottom: 2px solid transparent;
	color: var(--bsv-muted);
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	min-height: 44px;
	padding: 10px 14px;
	white-space: nowrap;
}

.bsv-tab.is-active {
	border-bottom-color: var(--bsv-primary);
	color: var(--bsv-primary);
}

/* ── Modal: toàn màn hình trên mobile, hộp giữa màn hình từ 640px ─────
   height dùng cả vh (fallback) lẫn dvh (viewport thực đang hiển thị) —
   trình duyệt mobile (Safari/Chrome) tính "100vh" theo viewport LỚN NHẤT
   (kể cả phần bị thanh địa chỉ che), khiến mép trên modal (tiêu đề + nút
   đóng) bị khuất sau thanh địa chỉ khi nó đang xoè ra. dvh tính đúng phần
   đang thấy được nên không còn bị che. */
.bsv-modal {
	align-items: flex-end;
	background: rgba(15, 23, 42, 0.5);
	display: flex;
	height: 100vh;
	height: 100dvh;
	inset: 0;
	justify-content: center;
	padding-top: env(safe-area-inset-top);
	position: fixed;
	z-index: 9999;
}

.bsv-modal__box {
	background: var(--bsv-surface);
	border-radius: 14px 14px 0 0;
	max-height: 92vh;
	max-height: 92dvh;
	overflow-y: auto;
	padding: 18px 16px;
	width: 100%;
}

@media (min-width: 640px) {
	.bsv-modal { align-items: center; padding: 16px; }

	.bsv-modal__box {
		border-radius: 12px;
		max-height: 90vh;
		max-height: 90dvh;
		max-width: 560px;
		padding: 20px;
	}

	/* Form nhiều trường (hồ sơ thương hiệu bác sĩ/phòng khám, lịch làm việc...)
	   — ép đúng 90% chiều rộng màn hình, không chỉ giới hạn tối đa. */
	.bsv-modal__box--wide { max-width: 90vw; width: 90vw; }
}

.bsv-modal__head {
	align-items: center;
	display: flex;
	justify-content: space-between;
	margin-bottom: 14px;
}

/* ── Trạng thái & thông báo ─────────────────────────────────────────── */
.bsv-empty,
.bsv-loading {
	color: var(--bsv-muted);
	padding: 28px 12px;
	text-align: center;
}

.bsv-alert {
	border-radius: 8px;
	font-size: 14px;
	margin-bottom: 14px;
	padding: 10px 14px;
}

.bsv-alert--error { background: #fee2e2; color: #991b1b; }
.bsv-alert--info { background: #ccfbf1; color: #115e59; }
.bsv-alert--warning { background: #fef3c7; color: #92400e; }

.bsv-toast {
	background: #1e293b;
	border-radius: 8px;
	bottom: 20px;
	color: #fff;
	font-size: 14px;
	left: 50%;
	max-width: calc(100vw - 32px);
	opacity: 1;
	padding: 11px 18px;
	position: fixed;
	transform: translateX(-50%);
	transition: opacity 0.4s;
	z-index: 10000;
}

.bsv-toast--success { background: var(--bsv-success); }
.bsv-toast--error { background: var(--bsv-danger); }
.bsv-toast.is-out { opacity: 0; }

/* ── Máy quét QR ────────────────────────────────────────────────────── */
.bsv-scanner video {
	background: #000;
	border-radius: var(--bsv-radius);
	max-height: 320px;
	width: 100%;
}

/* Vùng bốc số trên trang chủ khi CHƯA đăng nhập: mờ đi, bấm vào để được
   nhắc đăng nhập (lockGuard xử lý click). */
.bsv .bsv-locked {
	cursor: pointer;
	filter: grayscale(0.4);
	opacity: 0.45;
	user-select: none;
}

/* Mọi phần tử BÊN TRONG vùng khoá không nhận chuột — click luôn rơi vào
   chính wrapper (nơi gắn lockGuard), không cách nào bấm trúng nút bên trong. */
.bsv .bsv-locked > * { pointer-events: none; }

/* ── Card tin tức (trang chủ, trang Tin tức, box nhúng) ───────────────
   Ảnh phủ toàn card; chân card (34% chiều cao) nền xanh y tế đè lên đáy
   ảnh, viền card cùng màu — dùng chung cho mọi nơi hiển thị bài viết.
   10% chiều cao đầu chân (~30% chiều cao chân) là dải gradient mờ dần
   từ ảnh sang nền xanh; phần còn lại đặc màu để chữ nằm hẳn trong nền. */
.bsv .bsv-news {
	aspect-ratio: 16 / 11;
	background: var(--bsv-bg);
	border: 1px solid var(--bsv-primary);
	border-radius: var(--bsv-radius);
	display: block;
	overflow: hidden;
	position: relative;
	text-decoration: none;
}

.bsv .bsv-news__media {
	inset: 0;
	position: absolute;
}

.bsv .bsv-news__img {
	display: block;
	height: 100% !important;
	object-fit: cover;
	width: 100% !important;
}

.bsv .bsv-news__body {
	background: linear-gradient(to bottom, transparent 0%, var(--bsv-primary) 30%, var(--bsv-primary) 100%);
	bottom: 0;
	color: #fff;
	display: flex;
	flex-direction: column;
	height: 34%;
	justify-content: flex-end;
	left: 0;
	padding: 10px 14px;
	position: absolute;
	right: 0;
}

.bsv .bsv-news__title {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	font-size: 15px;
	font-weight: 700;
	line-height: 1.35;
	margin-bottom: 8px;
	overflow: hidden;
}

.bsv .bsv-news:hover .bsv-news__title { text-decoration: underline; }

.bsv .bsv-news__meta {
	align-items: center;
	color: rgba(255, 255, 255, 0.85);
	display: flex;
	flex-wrap: wrap;
	font-size: 12px;
	gap: 6px 8px;
}

.bsv .bsv-news__cat {
	font-weight: 600;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

/* Chấm phân cách chuyên mục/ngày — chỉ hiện khi có cả hai. */
.bsv .bsv-news__cat:not(:empty) + .bsv-news__date::before {
	content: '•';
	margin-right: 8px;
}

.bsv-icon { display: inline-block; flex-shrink: 0; vertical-align: -3px; }

.bsv-muted { color: var(--bsv-muted); font-size: 13px; }
.bsv-mb-0 { margin-bottom: 0; margin-top: 0; }
[x-cloak] { display: none !important; }
