/* =========================================================
   FSC Tables — frontend
   Mọi màu lấy từ CSS variables đặt inline trên .fsc-wrap:
   --fsc-head-bg  nền header
   --fsc-head-tx  chữ header
   --fsc-row-bg   nền hàng
   --fsc-row-alt  nền hàng xen kẽ
   --fsc-tx       màu chữ
   --fsc-bd       màu viền
   --fsc-ac       màu nhấn (hover, badge, link, highlight)
   ========================================================= */

.fsc-wrap {
	margin: 1.25em 0;
	color: var(--fsc-tx, #1f2937);
	font-size: 15px;
	line-height: 1.55;
	-webkit-font-smoothing: antialiased;
}

.fsc-size-sm { font-size: 13px; }
.fsc-size-md { font-size: 15px; }
.fsc-size-lg { font-size: 17px; }

.fsc-title {
	display: flex;
	align-items: center;
	gap: 10px;
	font-weight: 800;
	font-size: 1.18em;
	margin-bottom: 12px;
	letter-spacing: .01em;
}

.fsc-title::before {
	content: '';
	width: 4px;
	height: 1.05em;
	border-radius: 2px;
	background: var(--fsc-ac, #f05a22);
	flex-shrink: 0;
}

/* ---------- Icon ---------- */

.fsc-ico { display: inline-block; vertical-align: middle; }

/* Icon tiêu đề cột: ô vuông mờ trên nền header */
.fsc-hico {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 7px;
	background: color-mix(in srgb, var(--fsc-head-tx, #fff) 16%, transparent);
	margin-right: 9px;
	vertical-align: middle;
}

/* Icon hàng: hình tròn tint màu ở cột đầu */
.fsc-row-ico {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border-radius: 50%;
	margin-right: 10px;
	vertical-align: middle;
	flex-shrink: 0;
}

.fsc-cell-val { vertical-align: middle; display: inline-block; }

.fsc-tint-blue   { background: #EAF0FE; color: #1D4ED8; }
.fsc-tint-green  { background: #E7F8F0; color: #047857; }
.fsc-tint-orange { background: #FFF1EA; color: #F05A22; }
.fsc-tint-violet { background: #F3EDFD; color: #6D28D9; }
.fsc-tint-red    { background: #FDECEC; color: #DC2626; }
.fsc-tint-teal   { background: #E6F7F7; color: #0D9488; }
.fsc-tint-gray   { background: #F1F2F5; color: #4B5563; }

/* ---------- Ghi chú chân bảng ---------- */

.fsc-note {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	border: 1px solid var(--fsc-bd, #e5e7eb);
	border-top: none;
	background: color-mix(in srgb, var(--fsc-row-alt, #f9fafb) 60%, var(--fsc-row-bg, #fff));
	padding: 10px 16px;
	font-size: .88em;
	font-style: italic;
	color: color-mix(in srgb, var(--fsc-tx, #1f2937) 75%, transparent);
}

.fsc-note .fsc-ico {
	flex-shrink: 0;
	margin-top: 2px;
	color: var(--fsc-ac, #f05a22);
}

.fsc-rounded .fsc-note { border-radius: 0 0 14px 14px; }
.fsc-has-note.fsc-rounded .fsc-scroll { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.fsc-shadow .fsc-note { box-shadow: 0 4px 18px rgba(15, 23, 42, 0.07); }

/* ---------- Toolbar / search ---------- */

.fsc-toolbar { margin-bottom: 10px; }

.fsc-search {
	width: 100%;
	max-width: 320px;
	padding: 8px 12px;
	border: 1px solid var(--fsc-bd, #e5e7eb);
	border-radius: 8px;
	font-size: 0.95em;
	background: #fff;
	color: inherit;
	outline: none;
	transition: border-color 0.15s, box-shadow 0.15s;
}

.fsc-search:focus {
	border-color: var(--fsc-ac, #f05a22);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--fsc-ac, #f05a22) 18%, transparent);
}

/* ---------- Khung scroll ---------- */

.fsc-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
	border: 1px solid var(--fsc-bd, #e5e7eb);
	background: var(--fsc-row-bg, #fff);
}

.fsc-rounded .fsc-scroll { border-radius: 14px; }
.fsc-shadow .fsc-scroll { box-shadow: 0 4px 18px rgba(15, 23, 42, 0.07); }

/* ---------- Bảng ---------- */

.fsc-table {
	width: 100%;
	border-collapse: separate;
	border-spacing: 0;
	margin: 0;
	border: none;
	background: transparent;
	font-size: 1em;
}

.fsc-table thead th {
	background: var(--fsc-head-bg, #f05a22);
	color: var(--fsc-head-tx, #fff);
	font-weight: 600;
	text-align: left;
	white-space: nowrap;
	border: none;
	letter-spacing: 0.01em;
}

.fsc-table tbody td {
	background: var(--fsc-row-bg, #fff);
	border: none;
	border-top: 1px solid var(--fsc-bd, #e5e7eb);
	vertical-align: top;
}

.fsc-table tbody tr:first-child td { border-top: none; }

/* Mật độ */
.fsc-density-compact .fsc-table th,
.fsc-density-compact .fsc-table td { padding: 7px 12px; }
.fsc-density-normal .fsc-table th,
.fsc-density-normal .fsc-table td { padding: 11px 16px; }
.fsc-density-relaxed .fsc-table th,
.fsc-density-relaxed .fsc-table td { padding: 15px 20px; }

/* Kẻ sọc */
.fsc-striped .fsc-table tbody tr:nth-child(even) td {
	background: var(--fsc-row-alt, #f9fafb);
}

/* Viền dọc */
.fsc-bordered .fsc-table th + th,
.fsc-bordered .fsc-table td + td {
	border-left: 1px solid var(--fsc-bd, #e5e7eb);
}
.fsc-bordered .fsc-table thead th + th {
	border-left: 1px solid color-mix(in srgb, var(--fsc-head-tx, #fff) 25%, transparent);
}

/* Hover */
.fsc-hover .fsc-table tbody tr:hover td {
	background: color-mix(in srgb, var(--fsc-ac, #f05a22) 8%, var(--fsc-row-bg, #fff));
}

/* Header dính khi cuộn trang */
.fsc-sticky-head .fsc-table thead th {
	position: sticky;
	top: 0;
	z-index: 2;
}

/* Cột đầu dính khi cuộn ngang (hữu ích trên mobile) */
.fsc-sticky-first .fsc-table th:first-child,
.fsc-sticky-first .fsc-table td:first-child {
	position: sticky;
	left: 0;
	z-index: 1;
}
.fsc-sticky-first .fsc-table thead th:first-child { z-index: 3; }

/* Căn lề */
.fsc-al-left { text-align: left; }
.fsc-al-center { text-align: center; }
.fsc-al-right { text-align: right; }

/* Cột highlight */
.fsc-table td.fsc-hl {
	font-weight: 600;
	color: var(--fsc-ac, #f05a22);
}

/* ---------- Kiểu ô ---------- */

.fsc-num {
	font-variant-numeric: tabular-nums;
	font-weight: 500;
}

.fsc-badge {
	display: inline-block;
	padding: 3px 11px;
	border-radius: 999px;
	font-size: 0.85em;
	font-weight: 600;
	line-height: 1.5;
	color: var(--fsc-ac, #f05a22);
	background: color-mix(in srgb, var(--fsc-ac, #f05a22) 12%, transparent);
	white-space: nowrap;
}

.fsc-link {
	color: var(--fsc-ac, #f05a22);
	font-weight: 600;
	text-decoration: none;
	border-bottom: 1px solid color-mix(in srgb, var(--fsc-ac, #f05a22) 40%, transparent);
}
.fsc-link:hover { border-bottom-color: currentColor; }

.fsc-empty { opacity: 0.35; }

/* Ẩn hàng khi search không khớp */
.fsc-table tr.fsc-hide { display: none; }

/* =========================================================
   MOBILE
   - Chế độ scroll: giữ nguyên bảng, cuộn ngang mượt.
   - Chế độ stack: mỗi hàng thành 1 card, nhãn cột đứng trước giá trị.
   ========================================================= */

@media (max-width: 640px) {
	.fsc-wrap { font-size: 14px; }
	.fsc-size-lg { font-size: 15px; }

	.fsc-resp-stack .fsc-scroll {
		overflow-x: visible;
		border: none;
		background: transparent;
		box-shadow: none;
	}

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

	.fsc-resp-stack .fsc-table thead { display: none; }

	.fsc-resp-stack .fsc-table tr {
		margin-bottom: 12px;
		border: 1px solid var(--fsc-bd, #e5e7eb);
		border-top: 3px solid var(--fsc-head-bg, #f05a22);
		background: var(--fsc-row-bg, #fff);
		overflow: hidden;
	}
	.fsc-resp-stack.fsc-rounded .fsc-table tr { border-radius: 12px; }
	.fsc-resp-stack.fsc-shadow .fsc-table tr { box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06); }

	.fsc-resp-stack .fsc-table td {
		display: flex;
		gap: 12px;
		justify-content: space-between;
		align-items: baseline;
		text-align: right;
		border-top: 1px solid var(--fsc-bd, #e5e7eb);
		padding: 9px 14px;
	}
	.fsc-resp-stack .fsc-table tr td:first-child { border-top: none; }

	.fsc-resp-stack .fsc-table td::before {
		content: attr(data-label);
		font-weight: 600;
		text-align: left;
		flex-shrink: 0;
		max-width: 45%;
		color: color-mix(in srgb, var(--fsc-tx, #1f2937) 72%, transparent);
	}

	/* Trong stack, sọc áp theo card */
	.fsc-resp-stack.fsc-striped .fsc-table tbody tr:nth-child(even) td {
		background: var(--fsc-row-alt, #f9fafb);
	}

	/* sticky first không có ý nghĩa trong stack */
	.fsc-resp-stack .fsc-table td:first-child,
	.fsc-resp-stack .fsc-table th:first-child { position: static; }

	/* Ghi chú trong chế độ stack: khối riêng bo tròn */
	.fsc-resp-stack .fsc-note {
		border-top: 1px solid var(--fsc-bd, #e5e7eb);
		border-radius: 12px;
	}

	/* Icon hàng trong stack: thu nhỏ lại cho gọn card */
	.fsc-resp-stack .fsc-row-ico { width: 26px; height: 26px; }

	.fsc-search { max-width: 100%; }
}

/* Fallback cho trình duyệt chưa hỗ trợ color-mix */
@supports not (background: color-mix(in srgb, red 10%, white)) {
	.fsc-hover .fsc-table tbody tr:hover td { background: var(--fsc-row-alt, #f9fafb); }
	.fsc-badge { background: rgba(0, 0, 0, 0.06); }
	.fsc-search:focus { box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08); }
}
