/**
 * RMG Table of Contents - Frontend Styles
 * Matches rehab.com EZ TOC design system
 * Rehab Media Group's premium TOC styling
 */

.rmg-toc-container {
	margin: 32px 0;
	max-width: 100%;
}

/* Sticky positioning for sidebar usage */
.rmg-toc-container.rmg-toc-sticky {
	position: sticky;
	top: calc(80px + 8px); /* Adjust based on your header height */
	z-index: 1;
	margin-bottom: 24px;
}

.rmg-toc-header {
	padding: 12px 16px;
	position: relative;
	border-radius: 8px;
	background-color: #e8f4fd; /* var.$bg-ad-blue equivalent */
	color: #1e40af; /* var.$dark-blue equivalent */
	font-size: 18px;
	font-weight: 900;
	line-height: 22px;
	cursor: pointer;
	transition: all 0.15s ease;
}

.rmg-toc-header:after {
	position: absolute;
	content: "";
	right: 16px;
	top: 14px;
	width: 20px;
	height: 20px;
	background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%231E40AF"><path d="M7 10l5 5 5-5z"/></svg>') center
		center no-repeat;
	background-size: 12px;
	transition: all 0.15s;
}

/* Collapsed state */
.rmg-toc-container.rmg-toc-collapsed .rmg-toc-header:after {
	transform: rotate(180deg);
}

.rmg-toc-title {
	margin: 0;
	font-size: inherit;
	font-weight: inherit;
	color: inherit;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.rmg-toc-toggle {
	display: none; /* Hide the separate toggle button - we use the header click */
}

.rmg-toc-nav {
	margin: 8px 0 0;
	transition: all 0.3s ease;
}

.rmg-toc-nav.collapsed {
	display: none;
}

.rmg-toc-list {
	margin: 0;
	padding: 8px 16px;
	list-style: none;
	border-radius: 8px;
	background-color: #ffffff;
	box-shadow: 0px 0px 40px 0px rgba(38, 38, 44, 0.15);
	font-size: 16px;
	line-height: 1.6;
}

/* Level-based indentation instead of nested lists */
.rmg-toc-item.rmg-toc-level-1 {
	padding-left: 0;
}

.rmg-toc-item.rmg-toc-level-2 {
	padding-left: 0;
}

.rmg-toc-item.rmg-toc-level-3 {
	padding-left: 16px;
}

.rmg-toc-item.rmg-toc-level-4 {
	padding-left: 32px;
}

.rmg-toc-item.rmg-toc-level-5 {
	padding-left: 48px;
}

.rmg-toc-item.rmg-toc-level-6 {
	padding-left: 64px;
}

/* Optional bullet point styling for ul/li structure */
.rmg-toc-list.have_bullets {
	list-style: disc;
	padding-left: 20px;
}

.rmg-toc-list.no_bullets {
	list-style: none;
}

.rmg-toc-item {
	border-bottom: 1px solid #d1d5db; /* var.$grey300 equivalent */
	margin: 0;
}

.rmg-toc-item:last-child {
	border-bottom: 0;
}

/* Lighter border for nested heading levels */
.rmg-toc-item.rmg-toc-level-3,
.rmg-toc-item.rmg-toc-level-4,
.rmg-toc-item.rmg-toc-level-5,
.rmg-toc-item.rmg-toc-level-6 {
	border-bottom: 1px solid #e5e7eb; /* Lighter border for nested items */
}

.rmg-toc-link {
	display: block;
	padding: 8px 0;
	color: #374151; /* var.$grey700 equivalent */
	text-decoration: none;
	font-size: 16px;
	line-height: 1.6;
	transition: all 0.2s ease;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.rmg-toc-link:hover {
	color: #2563eb; /* var.$bright-blue equivalent */
	text-decoration: none;
}

.rmg-toc-link:focus {
	outline: none;
	color: #2563eb;
}

.rmg-toc-link.active {
	color: #2563eb;
	font-weight: 600;
}

/* Responsive design */
@media (max-width: 768px) {
	.rmg-toc-container {
		margin: 24px 0;
	}

	.rmg-toc-header {
		padding: 10px 14px;
		font-size: 16px;
	}

	.rmg-toc-header:after {
		top: 12px;
		right: 14px;
	}

	.rmg-toc-list {
		font-size: 14px;
		padding: 6px 12px;
	}

	/* Responsive level-based indentation */
	.rmg-toc-item.rmg-toc-level-3 {
		padding-left: 12px;
	}

	.rmg-toc-item.rmg-toc-level-4 {
		padding-left: 20px;
	}

	.rmg-toc-item.rmg-toc-level-5 {
		padding-left: 28px;
	}

	.rmg-toc-item.rmg-toc-level-6 {
		padding-left: 36px;
	}
}

/* Smooth scroll behavior */
html {
	scroll-behavior: smooth;
}

/* Heading anchor styling */
h1,
h2,
h3,
h4,
h5,
h6 {
	scroll-margin-top: 80px; /* Offset for fixed headers */
}

/* Compact TOC variant */
.rmg-toc-compact .rmg-toc-header {
	padding: 10px 14px;
	font-size: 16px;
}

.rmg-toc-compact .rmg-toc-list {
	padding: 6px 12px;
	font-size: 14px;
}

/* Compact level-based indentation */
.rmg-toc-compact .rmg-toc-item.rmg-toc-level-3 {
	padding-left: 12px;
}

.rmg-toc-compact .rmg-toc-item.rmg-toc-level-4 {
	padding-left: 24px;
}

.rmg-toc-compact .rmg-toc-item.rmg-toc-level-5 {
	padding-left: 36px;
}

.rmg-toc-compact .rmg-toc-item.rmg-toc-level-6 {
	padding-left: 48px;
}

/* Widget-specific styling */
.widget .rmg-toc-widget-wrapper {
	margin: 0;
}

.widget .rmg-toc-container {
	margin: 0;
	font-size: 14px;
}

.widget .rmg-toc-header {
	padding: 8px 12px;
	font-size: 14px;
	line-height: 18px;
}

.widget .rmg-toc-header:after {
	top: 10px;
	right: 12px;
	background-size: 10px;
}

.widget .rmg-toc-list {
	padding: 6px 10px;
	font-size: 13px;
	box-shadow: 0px 0px 20px 0px rgba(38, 38, 44, 0.1);
}

.widget .rmg-toc-link {
	padding: 6px 0;
	font-size: 13px;
	line-height: 1.4;
}

/* Widget level-based indentation */
.widget .rmg-toc-item.rmg-toc-level-3 {
	padding-left: 12px;
}

.widget .rmg-toc-item.rmg-toc-level-4 {
	padding-left: 24px;
}

.widget .rmg-toc-item.rmg-toc-level-5 {
	padding-left: 36px;
}

.widget .rmg-toc-item.rmg-toc-level-6 {
	padding-left: 48px;
}

/* Widget bullet styling based on wrapper class */
.widget .rmg-toc-bullets-enabled .rmg-toc-list {
	list-style: disc;
	padding-left: 20px;
}

.widget .rmg-toc-bullets-enabled .rmg-toc-link {
	display: inline;
}

/* Better mobile widget styling */
@media (max-width: 768px) {
	.widget .rmg-toc-header {
		padding: 6px 10px;
		font-size: 13px;
	}
	
	.widget .rmg-toc-header:after {
		top: 8px;
		right: 10px;
	}
	
	.widget .rmg-toc-list {
		font-size: 12px;
		padding: 4px 8px;
	}
	
	.widget .rmg-toc-link {
		padding: 4px 0;
		font-size: 12px;
	}
}
