/**
 * Mục lục bài viết — giao diện màu sắc, dễ đọc, phong cách wiki khoa học.
 */

.toc-box {
	position: relative;
	overflow: hidden;
	padding: 0 !important;
	border: 1px solid rgba(31, 94, 59, 0.14) !important;
	border-radius: 16px !important;
	background: #fff !important;
	box-shadow: 0 8px 28px rgba(15, 42, 26, 0.07);
}

.toc-box::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 3px;
	background: linear-gradient(90deg, #1f5e3b, #2e7d32, #3d9a6a);
}

/* Header */
.toc-box-header {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 18px 18px 14px;
	background: linear-gradient(135deg, #f0f9f3 0%, #ffffff 100%);
	border-bottom: 1px solid rgba(31, 94, 59, 0.08);
}

.toc-box-icon {
	display: grid;
	place-items: center;
	width: 40px;
	height: 40px;
	border-radius: 12px;
	background: linear-gradient(135deg, #1f5e3b, #2e7d32);
	color: #fff;
	flex-shrink: 0;
	box-shadow: 0 4px 12px rgba(31, 94, 59, 0.22);
}

.toc-box-icon svg {
	width: 18px;
	height: 18px;
}

.toc-box-titles {
	flex: 1;
	min-width: 0;
}

.toc-box-kicker {
	margin: 0 0 2px;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #2e7d32;
}

.toc-box-title {
	margin: 0;
	padding: 0;
	border: 0;
	font-family: var(--font-serif, "Source Serif 4", Georgia, serif);
	font-size: 16px;
	font-weight: 700;
	line-height: 1.25;
	color: var(--ink);
}

.toc-count {
	display: grid;
	place-items: center;
	min-width: 34px;
	height: 34px;
	padding: 0 8px;
	border-radius: 10px;
	background: rgba(46, 125, 50, 0.1);
	border: 1px solid rgba(46, 125, 50, 0.18);
	font-size: 13px;
	font-weight: 800;
	color: #1f5e3b;
	flex-shrink: 0;
}

/* Danh sách */
.toc-box .toc-list {
	list-style: none;
	margin: 0;
	padding: 12px 10px 14px;
	max-height: 420px;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: rgba(31, 94, 59, 0.25) transparent;
}

.toc-box .toc-list::-webkit-scrollbar {
	width: 5px;
}

.toc-box .toc-list::-webkit-scrollbar-thumb {
	border-radius: 999px;
	background: rgba(31, 94, 59, 0.22);
}

.toc-box .toc-list li {
	margin: 0 0 4px;
	display: block !important;
	flex-direction: unset !important;
	gap: unset !important;
}

.toc-box .toc-list li:last-child {
	margin-bottom: 0;
}

.toc-box .toc-list a {
	display: flex !important;
	flex-direction: row !important;
	align-items: flex-start !important;
	gap: 10px !important;
	padding: 9px 10px;
	border-radius: 10px;
	border: 1px solid transparent;
	text-decoration: none !important;
	color: inherit !important;
	transition:
		background 0.2s ease,
		border-color 0.2s ease,
		transform 0.2s ease,
		box-shadow 0.2s ease;
}

.toc-num {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 26px;
	height: 26px;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 800;
	line-height: 1;
	transition: all 0.2s ease;
}

.toc-text {
	flex: 1;
	min-width: 0;
	font-size: 13.5px;
	font-weight: 500;
	line-height: 1.45;
	color: #334155;
	transition: color 0.2s ease;
}

/* Cấp H2 */
.toc-level-2 .toc-num {
	background: linear-gradient(135deg, #e8f5ec, #d4edda);
	color: #1f5e3b;
	border: 1px solid rgba(31, 94, 59, 0.12);
}

.toc-level-2 a:hover .toc-num,
.toc-level-2.active .toc-num {
	background: linear-gradient(135deg, #1f5e3b, #2e7d32);
	color: #fff;
	border-color: transparent;
	box-shadow: 0 3px 10px rgba(31, 94, 59, 0.25);
}

/* Cấp H3 — thụt vào, màu xanh dương */
.toc-level-3 {
	padding-left: 14px;
}

.toc-level-3 .toc-num {
	width: 22px;
	height: 22px;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 900;
	background: linear-gradient(135deg, #e8f4fa, #d5ebf5);
	color: #1d6473;
	border: 1px solid rgba(29, 100, 115, 0.15);
}

.toc-level-3 .toc-text {
	font-size: 13px;
	color: #475569;
}

.toc-level-3 a:hover .toc-num,
.toc-level-3.active .toc-num {
	background: linear-gradient(135deg, #1d6473, #2a8a9d);
	color: #fff;
}

/* Hover & active */
.toc-box .toc-list a:hover {
	background: rgba(234, 245, 237, 0.65);
	border-color: rgba(31, 94, 59, 0.1);
	transform: translateX(2px);
}

.toc-box .toc-list a:hover .toc-text {
	color: #1f5e3b;
}

.toc-box .toc-list li.active a {
	background: linear-gradient(90deg, rgba(234, 245, 237, 0.95), rgba(255, 255, 255, 0.6));
	border-color: rgba(31, 94, 59, 0.14);
	box-shadow: inset 3px 0 0 #2e7d32;
}

.toc-box .toc-list li.active .toc-text {
	color: #1f5e3b;
	font-weight: 700;
}

/* Mobile toggle */
.toc-box .toc-toggle {
	display: none;
	width: calc(100% - 20px);
	margin: 0 10px 12px;
	padding: 11px 14px;
	border: 1px solid rgba(31, 94, 59, 0.14);
	border-radius: 10px;
	background: linear-gradient(135deg, #f0f9f3, #fff);
	color: #1f5e3b;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: background 0.2s ease;
}

.toc-box .toc-toggle:hover {
	background: #eaf5ed;
}

@media (max-width: 767px) {
	.toc-box-header {
		display: none;
	}

	.toc-box .toc-toggle {
		display: block;
		margin-top: 12px;
	}

	.toc-box .toc-list {
		display: none;
		max-height: none;
		padding-top: 0;
	}

	.toc-box.is-open .toc-list {
		display: block;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.toc-box .toc-list a {
		transition:
			background 0.22s ease,
			border-color 0.22s ease,
			transform 0.22s ease,
			box-shadow 0.22s ease;
	}
}

/* ── Màu theo từng hub (chỉ đổi accent, giữ layout) ── */
.hub-theme-cay-trong .toc-box::before {
	background: linear-gradient(90deg, #1b5e35, #43a047, #66bb6a);
}

.hub-theme-cay-trong .toc-box-kicker,
.hub-theme-cay-trong .toc-count {
	color: #1b5e35;
}

.hub-theme-cay-trong .toc-box-icon {
	background: linear-gradient(135deg, #1b5e35, #43a047);
}

.hub-theme-sau-benh .toc-box::before {
	background: linear-gradient(90deg, #c2410c, #ea580c, #fb923c);
}

.hub-theme-sau-benh .toc-box-header {
	background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%);
}

.hub-theme-sau-benh .toc-box-kicker,
.hub-theme-sau-benh .toc-count {
	color: #c2410c;
}

.hub-theme-sau-benh .toc-box-icon {
	background: linear-gradient(135deg, #c2410c, #ea580c);
	box-shadow: 0 4px 12px rgba(234, 88, 12, 0.22);
}

.hub-theme-sau-benh .toc-level-2 .toc-num {
	background: linear-gradient(135deg, #ffedd5, #fed7aa);
	color: #c2410c;
	border-color: rgba(194, 65, 12, 0.14);
}

.hub-theme-sau-benh .toc-level-2 a:hover .toc-num,
.hub-theme-sau-benh .toc-level-2.active .toc-num {
	background: linear-gradient(135deg, #c2410c, #ea580c);
}

.hub-theme-sau-benh .toc-box .toc-list li.active a {
	box-shadow: inset 3px 0 0 #ea580c;
}

.hub-theme-dinh-duong .toc-box::before {
	background: linear-gradient(90deg, #1d4ed8, #2563eb, #60a5fa);
}

.hub-theme-dinh-duong .toc-box-header {
	background: linear-gradient(135deg, #eff6ff 0%, #ffffff 100%);
}

.hub-theme-dinh-duong .toc-box-kicker,
.hub-theme-dinh-duong .toc-count {
	color: #1d4ed8;
}

.hub-theme-dinh-duong .toc-box-icon {
	background: linear-gradient(135deg, #1d4ed8, #2563eb);
	box-shadow: 0 4px 12px rgba(37, 99, 235, 0.22);
}

.hub-theme-dinh-duong .toc-level-2 .toc-num {
	background: linear-gradient(135deg, #dbeafe, #bfdbfe);
	color: #1d4ed8;
	border-color: rgba(29, 78, 216, 0.14);
}

.hub-theme-dinh-duong .toc-level-2 a:hover .toc-num,
.hub-theme-dinh-duong .toc-level-2.active .toc-num {
	background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

.hub-theme-vi-sinh .toc-box::before {
	background: linear-gradient(90deg, #0f766e, #14b8a6, #2dd4bf);
}

.hub-theme-vi-sinh .toc-box-header {
	background: linear-gradient(135deg, #f0fdfa 0%, #ffffff 100%);
}

.hub-theme-vi-sinh .toc-box-kicker,
.hub-theme-vi-sinh .toc-count {
	color: #0f766e;
}

.hub-theme-vi-sinh .toc-box-icon {
	background: linear-gradient(135deg, #0f766e, #14b8a6);
	box-shadow: 0 4px 12px rgba(15, 118, 110, 0.22);
}

.hub-theme-vi-sinh .toc-level-2 .toc-num {
	background: linear-gradient(135deg, #ccfbf1, #99f6e4);
	color: #0f766e;
	border-color: rgba(15, 118, 110, 0.14);
}

.hub-theme-vi-sinh .toc-level-2 a:hover .toc-num,
.hub-theme-vi-sinh .toc-level-2.active .toc-num {
	background: linear-gradient(135deg, #0f766e, #14b8a6);
}

.hub-theme-vi-sinh .toc-box .toc-list li.active a {
	box-shadow: inset 3px 0 0 #14b8a6;
}
