/**
 * Table of Contents CSS Stylesheet
 *
 * Giao diện hiện đại, tinh gọn, tương thích tối đa với Anvet / Flatsome theme.
 * Tối ưu Core Web Vitals (CLS = 0), hỗ trợ Dark Mode & Responsive.
 */

:root {
	--theme-toc-bg: #ffffff;
	--theme-toc-summary-bg: #eceff3;
	--theme-toc-summary-text: #1a202c;
	--theme-toc-border: #e2e8f0;
	--theme-toc-text: #2d3748;
	--theme-toc-title: #1a202c;
	--theme-toc-link: #3182ce;
	--theme-toc-link-hover: #1b4977;
	--theme-toc-offset: 90px;
}

/* Kích hoạt cuộn trang mượt mà nếu được bật */
html.theme-toc-smooth-scroll {
	scroll-behavior: smooth;
}

/* Bù trừ khoảng cách Sticky Header & Admin Bar khi nhảy Anchor */
.theme-toc-target {
	scroll-margin-top: calc(var(--theme-toc-offset, 90px) + var(--wp-admin--admin-bar--height, 0px));
}

@media screen and (max-width: 782px) {
	.admin-bar .theme-toc-target {
		scroll-margin-top: calc(var(--theme-toc-offset, 90px) + 46px);
	}
}

@media screen and (min-width: 783px) {
	.admin-bar .theme-toc-target {
		scroll-margin-top: calc(var(--theme-toc-offset, 90px) + 32px);
	}
}

/* Khối bao ngoài TOC */
.theme-toc-nav {
	margin: 25px 0 35px;
	width: 100%;
	display: block;
	clear: both;
}

.theme-toc-details {
	background-color: var(--theme-toc-bg);
	border: 1px solid var(--theme-toc-border);
	border-radius: 8px;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
	overflow: hidden;
	transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-toc-details:hover {
	box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
	border-color: #cbd5e0;
}

/* Tiêu đề & Nút toggle <summary> */
.theme-toc-summary {
	padding: 12px 18px;
	margin: 0;
	cursor: pointer;
	user-select: none;
	list-style: none;
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-weight: 600;
	font-size: 16px;
	background-color: var(--theme-toc-summary-bg, #eceff3);
	color: var(--theme-toc-summary-text, var(--theme-toc-title));
	transition: background-color 0.2s ease, filter 0.2s ease;
	outline: none;
}

/* Ẩn marker mặc định của trình duyệt */
.theme-toc-summary::-webkit-details-marker {
	display: none;
}

.theme-toc-summary::marker {
	display: none;
}

.theme-toc-summary:hover {
	filter: brightness(0.97);
}

.theme-toc-summary:focus-visible {
	box-shadow: inset 0 0 0 2px var(--theme-toc-link);
}

.theme-toc-title-wrap {
	display: flex;
	align-items: center;
	gap: 10px;
}

.theme-toc-icon-book {
	color: var(--theme-toc-summary-text, #718096);
	opacity: 0.85;
	flex-shrink: 0;
}

.theme-toc-title {
	letter-spacing: -0.01em;
}

/* Mũi tên toggle xoay mượt mà */
.theme-toc-toggle-indicator {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	color: var(--theme-toc-summary-text, #718096);
	background: rgba(0, 0, 0, 0.04);
	transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.2s ease;
}

.theme-toc-summary:hover .theme-toc-toggle-indicator {
	background: rgba(0, 0, 0, 0.06);
	color: var(--theme-toc-title);
}

.theme-toc-details[open] .theme-toc-toggle-indicator {
	transform: rotate(180deg);
}

/* Nội dung danh sách mục lục */
.theme-toc-content {
	padding: 14px 20px 18px 20px;
	border-top: 1px solid var(--theme-toc-border);
}

/* Danh sách cấp 1 */
.theme-toc-content ol,
.theme-toc-content ul {
	margin: 0;
	padding: 0 0 0 22px;
	list-style-position: outside;
}

.theme-toc-content > ol,
.theme-toc-content > ul {
	padding-left: 20px;
}

/* Các cấp con lồng nhau */
.theme-toc-content ol ol,
.theme-toc-content ul ul,
.theme-toc-content ol ul,
.theme-toc-content ul ol {
	margin-top: 6px;
	margin-bottom: 6px;
	padding-left: 20px;
}

.theme-toc-content li {
	margin: 6px 0;
	line-height: 1.5;
	font-size: 15px;
	color: var(--theme-toc-text);
}

/* Đánh số thứ tự đa cấp cho <ol> (1, 1.1, 1.2) */
.theme-toc-content ol {
	counter-reset: toc-counter;
	list-style: none;
	padding-left: 0;
}

.theme-toc-content ol > li {
	counter-increment: toc-counter;
	position: relative;
	padding-left: 24px;
}

.theme-toc-content ol > li::before {
	content: counters(toc-counter, ".") ".";
	position: absolute;
	left: 0;
	top: 0;
	font-weight: 500;
	color: #a0aec0;
	font-size: 0.9em;
}

/* Liên kết trong mục lục */
.theme-toc-content a {
	color: var(--theme-toc-text);
	text-decoration: none;
	transition: color 0.15s ease, padding-left 0.15s ease;
	display: inline-block;
}

.theme-toc-content a:hover {
	color: var(--theme-toc-link-hover);
	text-decoration: underline;
}

/* Tối ưu màn hình cảm ứng & Mobile */
@media screen and (max-width: 767px) {
	.theme-toc-summary {
		padding: 10px 14px;
		font-size: 15px;
	}

	.theme-toc-content {
		padding: 12px 14px 16px 14px;
	}

	.theme-toc-content li {
		margin: 8px 0;
		font-size: 14.5px;
	}

	.theme-toc-content a {
		padding: 2px 0;
	}
}

.theme-toc-badge {
	display: none;
}

/* ==========================================================================
   TOC PRESET STYLES (5 Distinct UI Archetypes)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. STYLE: MINIMALIST (Tối giản thanh thoát - User Approved)
   -------------------------------------------------------------------------- */
.theme-toc-nav.style-minimalist .theme-toc-details {
	background: transparent;
	border: none;
	border-left: 3px solid var(--primary-color, #ff7b42);
	border-radius: 0;
	box-shadow: none;
	padding-left: 14px;
}
.theme-toc-nav.style-minimalist .theme-toc-summary {
	background: transparent;
	padding: 4px 0 8px 0;
	color: var(--theme-toc-title, #1a202c);
	cursor: pointer;
}
.theme-toc-nav.style-minimalist .theme-toc-content {
	border-top: none;
	padding: 6px 0 0 0;
}
.theme-toc-nav.style-minimalist .theme-toc-toggle-indicator {
	background: transparent;
	opacity: 0.6;
}

/* --------------------------------------------------------------------------
   2. STYLE: CARD BOXED (Thẻ nội dung đóng khung cao cấp - Khác biệt Accordion)
   -------------------------------------------------------------------------- */
.theme-toc-nav.style-card_boxed .theme-toc-details {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-top: 4px solid var(--primary-color, #ff7b42);
	border-radius: 12px;
	box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
	overflow: hidden;
}
.theme-toc-nav.style-card_boxed .theme-toc-summary {
	background: transparent;
	border-bottom: 1px solid #f1f5f9;
	padding: 16px 22px 14px 22px;
	cursor: default;
}
.theme-toc-nav.style-card_boxed .theme-toc-title {
	font-size: 13.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.8px;
	color: #1e293b;
}
.theme-toc-nav.style-card_boxed .theme-toc-icon-book {
	color: var(--primary-color, #ff7b42);
	opacity: 1;
}
.theme-toc-nav.style-card_boxed .theme-toc-badge {
	display: inline-block;
	font-size: 11px;
	font-weight: 600;
	padding: 2px 8px;
	border-radius: 999px;
	background: #f1f5f9;
	color: #64748b;
	margin-left: 8px;
	letter-spacing: normal;
	text-transform: none;
}
.theme-toc-nav.style-card_boxed .theme-toc-toggle-indicator {
	display: none;
}
.theme-toc-nav.style-card_boxed .theme-toc-content {
	border-top: none;
	padding: 16px 24px 22px 24px;
}
.theme-toc-nav.style-card_boxed .theme-toc-content ol > li::before {
	color: var(--primary-color, #ff7b42);
	font-weight: 700;
}

/* --------------------------------------------------------------------------
   3. STYLE: STICKY SIDEBAR (Nằm trong blog-wrapper, bám sát mép trái entry-content)
   -------------------------------------------------------------------------- */

/* Thiết lập lề trái cho khung bài viết trên desktop để chứa TOC sát viền trái */
@media screen and (min-width: 1024px) {
	body.has-theme-toc-sticky-sidebar .blog-wrapper.blog-single .row.align-center,
	.blog-wrapper.blog-single.has-theme-toc-sticky-sidebar .row.align-center,
	.blog-wrapper.blog-single:has(.style-sticky_sidebar) .row.align-center {
		max-width: 1260px;
		padding-left: 270px;
		box-sizing: border-box;
	}

	body.has-theme-toc-sticky-sidebar .blog-wrapper.blog-single .large-10.col,
	.blog-wrapper.blog-single.has-theme-toc-sticky-sidebar .large-10.col,
	.blog-wrapper.blog-single:has(.style-sticky_sidebar) .large-10.col {
		max-width: 100%;
		flex-basis: 100%;
	}

	body.has-theme-toc-sticky-sidebar .blog-wrapper.blog-single .row-large,
	.blog-wrapper.blog-single.has-theme-toc-sticky-sidebar .row-large,
	.blog-wrapper.blog-single:has(.style-sticky_sidebar) .row-large {
		max-width: 1340px;
		padding-left: 270px;
		box-sizing: border-box;
	}

	/* Đẩy TOC sang bên trái, sát viền của entry-content single-page */
	.theme-toc-nav.style-sticky_sidebar {
		position: sticky;
		top: calc(var(--theme-toc-offset, 90px) + 20px);
		float: left;
		width: 240px;
		margin-left: -270px; /* Bám sát mép viền bên trái entry-content, không che chữ */
		margin-right: 30px;
		margin-top: 0;
		margin-bottom: 25px;
		z-index: 20;
		clear: both;
	}
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-details {
	background: #ffffff;
	border: none;
	border-radius: 10px;
	box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.06);
	padding: 10px 16px;
	max-height: calc(100vh - var(--theme-toc-offset, 90px) - 50px);
	display: flex;
	flex-direction: column;
	transition: padding 0.2s ease, box-shadow 0.2s ease;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-details[open] {
	padding: 14px 16px;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-summary {
	background: transparent;
	padding: 0;
	border-bottom: none;
	margin-bottom: 0;
	cursor: pointer;
}

/* Đường kẻ phân cách và khoảng đệm chỉ hiển thị khi mục lục đang mở [open] */
.theme-toc-nav.style-sticky_sidebar .theme-toc-details[open] .theme-toc-summary {
	padding-bottom: 10px;
	border-bottom: 1px solid #f1f5f9;
	margin-bottom: 10px;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-title {
	font-size: 11.5px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: #64748b;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-icon-book {
	color: var(--primary-color, #ff7b42);
	width: 15px;
	height: 15px;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-toggle-indicator {
	display: none;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-content {
	border-top: none;
	padding: 0;
	overflow-y: auto;
	scrollbar-width: thin;
	scrollbar-color: #cbd5e0 transparent;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-content::-webkit-scrollbar {
	width: 4px;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-content::-webkit-scrollbar-thumb {
	background-color: #cbd5e0;
	border-radius: 4px;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-content li {
	margin: 6px 0;
	font-size: 13.5px;
	line-height: 1.4;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-content a {
	color: #475569;
}

.theme-toc-nav.style-sticky_sidebar .theme-toc-content a:hover {
	color: var(--primary-color, #ff7b42);
	text-decoration: none;
}

/* Trên màn hình hẹp hơn (< 1024px): hiển thị gọn gàng trong bài viết, không float tràn viền */
@media screen and (max-width: 1023px) {
	.theme-toc-nav.style-sticky_sidebar {
		position: static;
		width: 100%;
		margin: 20px 0;
		float: none;
	}
	.theme-toc-nav.style-sticky_sidebar .theme-toc-details {
		background: #ffffff;
		border: none;
		border-radius: 10px;
		box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
	}
}

/* --------------------------------------------------------------------------
   4. STYLE: PILL / BADGE COUNTER (Hàng thẻ tương tác với số Badge viên thuốc)
   -------------------------------------------------------------------------- */
.theme-toc-nav.style-pill_counter .theme-toc-details {
	background: #f8fafc;
	border: 1px dashed #cbd5e1;
	border-radius: 14px;
	box-shadow: none;
	padding: 16px 18px;
}
.theme-toc-nav.style-pill_counter .theme-toc-summary {
	background: transparent;
	border: none;
	padding: 0 0 12px 0;
	margin-bottom: 12px;
	border-bottom: 1px solid #e2e8f0;
	cursor: default;
}
.theme-toc-nav.style-pill_counter .theme-toc-title {
	font-size: 15.5px;
	font-weight: 700;
	color: #0f172a;
}
.theme-toc-nav.style-pill_counter .theme-toc-badge {
	display: inline-flex;
	align-items: center;
	background: var(--primary-color, #ff7b42);
	color: #ffffff;
	font-size: 11px;
	font-weight: 700;
	padding: 2px 9px;
	border-radius: 999px;
	margin-left: 8px;
	box-shadow: 0 2px 6px rgba(255, 123, 66, 0.25);
}
.theme-toc-nav.style-pill_counter .theme-toc-toggle-indicator {
	display: none;
}
.theme-toc-nav.style-pill_counter .theme-toc-content {
	border-top: none;
	padding: 0;
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol > li {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 8px;
	padding: 8px 12px;
	margin-bottom: 8px;
	display: flex;
	align-items: center;
	transition: all 0.2s ease;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol > li:hover {
	border-color: var(--primary-color, #ff7b42);
	transform: translateX(4px);
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol > li::before {
	content: counters(toc-counter, ".");
	position: static;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 24px;
	padding: 0 6px;
	margin-right: 10px;
	border-radius: 999px;
	background-color: var(--primary-color, #ff7b42);
	color: #ffffff;
	font-size: 11.5px;
	font-weight: 700;
	line-height: 1;
	flex-shrink: 0;
	box-shadow: 0 2px 4px rgba(255, 123, 66, 0.25);
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol ol > li {
	background: #f1f5f9;
	border-color: #e2e8f0;
	margin-top: 6px;
	margin-bottom: 4px;
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol ol > li::before {
	background-color: #94a3b8;
	font-size: 10px;
	min-width: 20px;
	height: 20px;
	box-shadow: none;
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol > li > a {
	flex: 1;
	font-size: 14.5px;
	font-weight: 500;
	color: #1e293b;
}
.theme-toc-nav.style-pill_counter .theme-toc-content ol ol {
	width: 100%;
	padding-left: 14px;
}

/* --------------------------------------------------------------------------
   5. STYLE: ACCORDION CLEAN LIGHT (Accordion nguyên bản, chuẩn gập/mở thanh lịch)
   -------------------------------------------------------------------------- */
.theme-toc-nav.style-accordion_clean .theme-toc-details {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 10px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
	overflow: hidden;
}
.theme-toc-nav.style-accordion_clean .theme-toc-summary {
	background: var(--theme-toc-summary-bg, #f8fafc);
	color: var(--theme-toc-summary-text, #1e293b);
	border-bottom: 1px solid transparent;
	padding: 13px 18px;
	transition: background-color 0.2s ease, border-color 0.2s ease;
	cursor: pointer;
}
.theme-toc-nav.style-accordion_clean .theme-toc-summary:hover {
	filter: brightness(0.98);
}
.theme-toc-nav.style-accordion_clean .theme-toc-details[open] .theme-toc-summary {
	border-bottom-color: #e2e8f0;
}
.theme-toc-nav.style-accordion_clean .theme-toc-toggle-indicator {
	width: 28px;
	height: 28px;
	border-radius: 6px;
	background: #ffffff;
	border: 1px solid #e2e8f0;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
	color: var(--primary-color, #ff7b42);
}
.theme-toc-nav.style-accordion_clean .theme-toc-content {
	border-top: none;
	padding: 14px 20px 18px 20px;
}
