/**
 * FileDocs — Documentation UI Stylesheet
 *
 * CSS custom properties for easy theming.
 * Responsive: mobile-first, sidebar becomes drawer < 768px.
 * Light and dark mode support.
 *
 * @package FileDocs
 */

/* =========================================================
   1. CSS Custom Properties (Theming)
   ========================================================= */

:root {
	--filedocs-sidebar-width: 280px;
	--filedocs-toc-width: 220px;
	--filedocs-accent: #2563eb;
	--filedocs-accent-hover: #1d4ed8;
	--filedocs-accent-light: #dbeafe;
	--filedocs-radius: 8px;
	--filedocs-radius-sm: 4px;
	--filedocs-transition: 0.2s ease;
	--filedocs-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
	--filedocs-font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
	--filedocs-font-size: 15px;
	--filedocs-line-height: 1.7;
}

/* Light theme (default) */
.filedocs-wrap.filedocs-light,
.filedocs-wrap:not(.filedocs-dark) {
	--filedocs-bg: #ffffff;
	--filedocs-bg-alt: #f8fafc;
	--filedocs-bg-sidebar: #f1f5f9;
	--filedocs-bg-hover: #e2e8f0;
	--filedocs-bg-active: var(--filedocs-accent-light);
	--filedocs-border: #e2e8f0;
	--filedocs-text: #1e293b;
	--filedocs-text-secondary: #64748b;
	--filedocs-text-muted: #94a3b8;
	--filedocs-code-bg: #f1f5f9;
	--filedocs-code-border: #e2e8f0;
	--filedocs-blockquote-border: var(--filedocs-accent);
	--filedocs-blockquote-bg: #f8fafc;
	--filedocs-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
	--filedocs-shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
}

/* Dark theme */
.filedocs-wrap.filedocs-dark {
	--filedocs-bg: #0f172a;
	--filedocs-bg-alt: #1e293b;
	--filedocs-bg-sidebar: #1e293b;
	--filedocs-bg-hover: #334155;
	--filedocs-bg-active: #1e3a5f;
	--filedocs-border: #334155;
	--filedocs-text: #e2e8f0;
	--filedocs-text-secondary: #94a3b8;
	--filedocs-text-muted: #64748b;
	--filedocs-code-bg: #1e293b;
	--filedocs-code-border: #334155;
	--filedocs-blockquote-border: var(--filedocs-accent);
	--filedocs-blockquote-bg: #1e293b;
	--filedocs-shadow: 0 1px 3px rgba(0,0,0,0.3);
	--filedocs-shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
	--filedocs-accent-light: #1e3a5f;
}

/* Auto dark mode via system preference */
@media (prefers-color-scheme: dark) {
	.filedocs-wrap:not(.filedocs-light):not(.filedocs-dark) {
		--filedocs-bg: #0f172a;
		--filedocs-bg-alt: #1e293b;
		--filedocs-bg-sidebar: #1e293b;
		--filedocs-bg-hover: #334155;
		--filedocs-bg-active: #1e3a5f;
		--filedocs-border: #334155;
		--filedocs-text: #e2e8f0;
		--filedocs-text-secondary: #94a3b8;
		--filedocs-text-muted: #64748b;
		--filedocs-code-bg: #1e293b;
		--filedocs-code-border: #334155;
		--filedocs-blockquote-bg: #1e293b;
		--filedocs-shadow: 0 1px 3px rgba(0,0,0,0.3);
		--filedocs-shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
		--filedocs-accent-light: #1e3a5f;
	}
}

/* =========================================================
   2. Layout — Three-column grid
   ========================================================= */

.filedocs-wrap {
	display: flex;
	min-height: 500px;
	background: var(--filedocs-bg);
	color: var(--filedocs-text);
	font-family: var(--filedocs-font);
	font-size: var(--filedocs-font-size);
	line-height: var(--filedocs-line-height);
	position: relative;
	border: 1px solid var(--filedocs-border);
	border-radius: var(--filedocs-radius);
	overflow: hidden;
}

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

.filedocs-empty {
	padding: 60px 24px;
	text-align: center;
	color: var(--filedocs-text-secondary);
	font-size: 16px;
}

/* =========================================================
   3. Sidebar
   ========================================================= */

.filedocs-sidebar {
	width: var(--filedocs-sidebar-width);
	min-width: var(--filedocs-sidebar-width);
	background: var(--filedocs-bg-sidebar);
	border-right: 1px solid var(--filedocs-border);
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	position: relative;
	z-index: 10;
}

/* Search */
.filedocs-search-wrap {
	padding: 16px;
	border-bottom: 1px solid var(--filedocs-border);
	position: relative;
}

.filedocs-search-input {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid var(--filedocs-border);
	border-radius: var(--filedocs-radius-sm);
	background: var(--filedocs-bg);
	color: var(--filedocs-text);
	font-size: 14px;
	font-family: var(--filedocs-font);
	outline: none;
	transition: border-color var(--filedocs-transition);
}

.filedocs-search-input:focus {
	border-color: var(--filedocs-accent);
	box-shadow: 0 0 0 3px var(--filedocs-accent-light);
}

.filedocs-search-input::placeholder {
	color: var(--filedocs-text-muted);
}

/* Search results */
.filedocs-search-results {
	display: none;
	position: absolute;
	top: 100%;
	left: 16px;
	right: 16px;
	background: var(--filedocs-bg);
	border: 1px solid var(--filedocs-border);
	border-radius: var(--filedocs-radius-sm);
	box-shadow: var(--filedocs-shadow-lg);
	max-height: 300px;
	overflow-y: auto;
	z-index: 100;
}

.filedocs-search-results.is-visible {
	display: block;
}

.filedocs-search-result {
	padding: 10px 14px;
	cursor: pointer;
	border-bottom: 1px solid var(--filedocs-border);
	transition: background var(--filedocs-transition);
}

.filedocs-search-result:last-child {
	border-bottom: none;
}

.filedocs-search-result:hover {
	background: var(--filedocs-bg-hover);
}

.filedocs-search-result-plugin {
	font-size: 11px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--filedocs-accent);
	font-weight: 600;
	margin-bottom: 2px;
}

.filedocs-search-result-section {
	font-size: 13px;
	font-weight: 600;
	color: var(--filedocs-text);
}

.filedocs-search-result-excerpt {
	font-size: 12px;
	color: var(--filedocs-text-secondary);
	margin-top: 2px;
}

.filedocs-search-result-excerpt mark {
	background: #fef08a;
	color: #1e293b;
	border-radius: 2px;
	padding: 0 2px;
}

.filedocs-search-no-results {
	padding: 12px 14px;
	color: var(--filedocs-text-muted);
	font-size: 13px;
	text-align: center;
}

/* Navigation */
.filedocs-nav {
	flex: 1;
	overflow-y: auto;
	padding: 8px 0;
}

.filedocs-nav-plugin {
	border-bottom: 1px solid var(--filedocs-border);
}

.filedocs-nav-plugin:last-child {
	border-bottom: none;
}

.filedocs-nav-plugin-btn {
	display: flex;
	align-items: center;
	width: 100%;
	padding: 10px 16px;
	border: none;
	background: transparent;
	color: var(--filedocs-text);
	font-size: 14px;
	font-weight: 600;
	font-family: var(--filedocs-font);
	cursor: pointer;
	text-align: left;
	gap: 8px;
	transition: background var(--filedocs-transition);
}

.filedocs-nav-plugin-btn:hover {
	background: var(--filedocs-bg-hover);
}

.filedocs-nav-plugin.is-active > .filedocs-nav-plugin-btn {
	color: var(--filedocs-accent);
	background: var(--filedocs-bg-active);
}

.filedocs-nav-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 22px;
	height: 22px;
	flex-shrink: 0;
}

.filedocs-nav-icon .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.filedocs-nav-icon img {
	border-radius: 2px;
}

.filedocs-nav-label {
	flex: 1;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.filedocs-nav-arrow {
	flex-shrink: 0;
	display: flex;
	align-items: center;
	color: var(--filedocs-text-muted);
	transition: transform var(--filedocs-transition);
}

.filedocs-nav-plugin.is-active > .filedocs-nav-plugin-btn .filedocs-nav-arrow {
	transform: rotate(90deg);
}

/* Section links */
.filedocs-nav-sections {
	list-style: none;
	margin: 0;
	padding: 0 0 8px 0;
}

.filedocs-nav-section {
	margin: 0;
}

.filedocs-nav-section-link,
.filedocs-nav-subsection-link {
	display: block;
	padding: 5px 16px 5px 46px;
	color: var(--filedocs-text-secondary);
	text-decoration: none;
	font-size: 13px;
	border-left: 2px solid transparent;
	transition: all var(--filedocs-transition);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.filedocs-nav-subsection-link {
	padding-left: 60px;
	font-size: 12px;
}

.filedocs-nav-section-link:hover,
.filedocs-nav-subsection-link:hover {
	color: var(--filedocs-text);
	background: var(--filedocs-bg-hover);
}

.filedocs-nav-section-link.is-active,
.filedocs-nav-subsection-link.is-active {
	color: var(--filedocs-accent);
	border-left-color: var(--filedocs-accent);
	background: var(--filedocs-bg-active);
	font-weight: 600;
	margin-top: 10px;
}
}

.filedocs-nav-subsections {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* =========================================================
   4. Main content area
   ========================================================= */

.filedocs-main {
	flex: 1;
	min-width: 0;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}

/* Breadcrumbs */
.filedocs-breadcrumbs {
	padding: 12px 24px;
	font-size: 13px;
	color: var(--filedocs-text-muted);
	border-bottom: 1px solid var(--filedocs-border);
	background: var(--filedocs-bg-alt);
	display: flex;
	align-items: center;
	gap: 6px;
	flex-shrink: 0;
}

.filedocs-breadcrumb-sep {
	color: var(--filedocs-text-muted);
}

/* Content + TOC side-by-side */
.filedocs-content-layout {
	display: flex;
	flex: 1;
	min-height: 0;
}

/* Article content */
.filedocs-content {
	flex: 1;
	min-width: 0;
	padding: 32px 40px;
	max-width: 800px;
	overflow-y: auto;
}

/* =========================================================
   5. Content typography
   ========================================================= */

.filedocs-content h1 {
	font-size: 2em;
	font-weight: 800;
	margin: 0 0 24px 0;
	color: var(--filedocs-text);
	letter-spacing: -0.02em;
	line-height: 1.3;
}

.filedocs-content h2 {
	font-size: 1.5em;
	font-weight: 700;
	margin: 48px 0 16px 0;
	padding-bottom: 8px;
	border-bottom: 1px solid var(--filedocs-border);
	color: var(--filedocs-text);
	letter-spacing: -0.01em;
	line-height: 1.35;
}

.filedocs-content h2:first-child {
	margin-top: 0;
}

.filedocs-content h3 {
	font-size: 1.2em;
	font-weight: 600;
	margin: 32px 0 12px 0;
	color: var(--filedocs-text);
}

.filedocs-content h4 {
	font-size: 1.0em;
	font-weight: 600;
	margin: 32px 0 12px 0;
	color: var(--filedocs-text);
}

.filedocs-content p {
	margin: 0 0 16px 0;
}

.filedocs-content a {
	color: var(--filedocs-accent);
	text-decoration: none;
	border-bottom: 1px solid transparent;
	transition: border-color var(--filedocs-transition);
}

.filedocs-content a:hover {
	border-bottom-color: var(--filedocs-accent);
}

.filedocs-content strong {
	font-weight: 600;
}

.filedocs-content ul,
.filedocs-content ol {
	margin: 0 0 16px 0;
	padding-left: 24px;
}

.filedocs-content li {
	margin: 4px 0;
}

.filedocs-content li > ul,
.filedocs-content li > ol {
	margin-bottom: 0;
}

/* Inline code */
.filedocs-content code {
	background: var(--filedocs-code-bg);
	border: 1px solid var(--filedocs-code-border);
	border-radius: 3px;
	padding: 1px 5px;
	font-family: var(--filedocs-font-mono);
	font-size: 0.875em;
	word-break: break-word;
}

/* Code blocks */
.filedocs-content pre {
	background: var(--filedocs-code-bg);
	border: 1px solid var(--filedocs-code-border);
	border-radius: var(--filedocs-radius-sm);
	padding: 16px 20px;
	margin: 0 0 16px 0;
	overflow-x: auto;
	font-family: var(--filedocs-font-mono);
	font-size: 13px;
	line-height: 1.6;
}

.filedocs-content pre code {
	background: none;
	border: none;
	padding: 0;
	font-size: inherit;
}

/* Blockquotes */
.filedocs-content blockquote {
	margin: 0 0 16px 0;
	padding: 12px 20px;
	border-left: 3px solid var(--filedocs-blockquote-border);
	background: var(--filedocs-blockquote-bg);
	border-radius: 0 var(--filedocs-radius-sm) var(--filedocs-radius-sm) 0;
	color: var(--filedocs-text-secondary);
}

.filedocs-content blockquote p:last-child {
	margin-bottom: 0;
}

/* Tables */
.filedocs-content table {
	width: 100%;
	border-collapse: collapse;
	margin: 0 0 16px 0;
	font-size: 14px;
}

.filedocs-content th,
.filedocs-content td {
	padding: 10px 14px;
	border: 1px solid var(--filedocs-border);
	text-align: left;
}

.filedocs-content th {
	background: var(--filedocs-bg-alt);
	font-weight: 600;
}

.filedocs-content tr:hover td {
	background: var(--filedocs-bg-alt);
}

/* Images */
.filedocs-content img {
	max-width: 100%;
	height: auto;
	border-radius: var(--filedocs-radius-sm);
	margin: 8px 0;
}

/* Horizontal rule */
.filedocs-content hr {
	border: none;
	border-top: 1px solid var(--filedocs-border);
	margin: 32px 0;
}

/* =========================================================
   6. Table of Contents (right sidebar)
   ========================================================= */

.filedocs-toc {
	width: var(--filedocs-toc-width);
	min-width: var(--filedocs-toc-width);
	border-left: 1px solid var(--filedocs-border);
	position: sticky;
	top: 0;
	max-height: 100vh;
	overflow-y: auto;
	padding: 24px 16px;
	font-size: 13px;
}

.filedocs-toc-header {
	margin-bottom: 12px;
}

.filedocs-toc-toggle {
	display: none; /* Only visible on mobile */
	width: 100%;
	background: none;
	border: none;
	color: var(--filedocs-text-secondary);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
	cursor: pointer;
	padding: 8px 0;
	font-family: var(--filedocs-font);
	text-align: left;
	align-items: center;
	gap: 6px;
}

.filedocs-toc-header::before {
	content: 'On This Page';
	display: block;
	color: var(--filedocs-text-secondary);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1px;
}

.filedocs-toc-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.filedocs-toc-item {
	margin: 0;
}

.filedocs-toc-link {
	display: block;
	padding: 4px 0 4px 12px;
	color: var(--filedocs-text-muted);
	text-decoration: none;
	border-left: 2px solid transparent;
	transition: all var(--filedocs-transition);
	font-size: 13px;
	line-height: 1.4;
}

.filedocs-toc-sublink {
	padding-left: 24px;
	font-size: 12px;
}

.filedocs-toc-link:hover {
	color: var(--filedocs-text);
}

.filedocs-toc-link.is-active {
	color: var(--filedocs-accent);
	border-left-color: var(--filedocs-accent);
	font-weight: 600;
}

.filedocs-toc-sublist {
	list-style: none;
	margin: 0;
	padding: 0;
}

/* =========================================================
   7. Prev / Next navigation
   ========================================================= */

.filedocs-prevnext {
	display: flex;
	gap: 16px;
	padding: 24px 40px;
	border-top: 1px solid var(--filedocs-border);
	margin-top: auto;
	flex-shrink: 0;
}

.filedocs-prevnext-prev,
.filedocs-prevnext-next {
	flex: 1;
}

.filedocs-prevnext-next {
	text-align: right;
}

.filedocs-prevnext-link {
	display: inline-flex;
	flex-direction: column;
	padding: 12px 16px;
	border: 1px solid var(--filedocs-border);
	border-radius: var(--filedocs-radius);
	text-decoration: none;
	color: var(--filedocs-text);
	transition: all var(--filedocs-transition);
	max-width: 240px;
}

.filedocs-prevnext-link:hover {
	border-color: var(--filedocs-accent);
	box-shadow: var(--filedocs-shadow);
}

.filedocs-prevnext-label {
	font-size: 12px;
	color: var(--filedocs-text-muted);
	margin-bottom: 4px;
}

.filedocs-prevnext-title {
	font-weight: 600;
	font-size: 14px;
	color: var(--filedocs-accent);
}

/* =========================================================
   8. Hamburger / Mobile Sidebar
   ========================================================= */

.filedocs-hamburger {
	display: none;
	position: fixed;
	bottom: 24px;
	left: 24px;
	z-index: 1000;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: none;
	background: var(--filedocs-accent);
	color: #fff;
	cursor: pointer;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	box-shadow: var(--filedocs-shadow-lg);
	transition: transform var(--filedocs-transition), background var(--filedocs-transition);
}

.filedocs-hamburger:hover {
	background: var(--filedocs-accent-hover);
	transform: scale(1.05);
}

.filedocs-hamburger span {
	display: block;
	width: 20px;
	height: 2px;
	background: #fff;
	border-radius: 2px;
	transition: transform var(--filedocs-transition), opacity var(--filedocs-transition);
}

.filedocs-hamburger.is-open span:nth-child(1) {
	transform: rotate(45deg) translateY(4px) translateX(3px);
}

.filedocs-hamburger.is-open span:nth-child(2) {
	opacity: 0;
}

.filedocs-hamburger.is-open span:nth-child(3) {
	transform: rotate(-45deg) translateY(-4px) translateX(3px);
}

.filedocs-sidebar-overlay {
	display: none;
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.4);
	z-index: 99;
}

.filedocs-sidebar-overlay.is-visible {
	display: block;
}

/* =========================================================
   9. Scrollbar styling
   ========================================================= */

.filedocs-sidebar::-webkit-scrollbar,
.filedocs-toc::-webkit-scrollbar,
.filedocs-content::-webkit-scrollbar,
.filedocs-search-results::-webkit-scrollbar {
	width: 6px;
}

.filedocs-sidebar::-webkit-scrollbar-track,
.filedocs-toc::-webkit-scrollbar-track,
.filedocs-content::-webkit-scrollbar-track,
.filedocs-search-results::-webkit-scrollbar-track {
	background: transparent;
}

.filedocs-sidebar::-webkit-scrollbar-thumb,
.filedocs-toc::-webkit-scrollbar-thumb,
.filedocs-content::-webkit-scrollbar-thumb,
.filedocs-search-results::-webkit-scrollbar-thumb {
	background: var(--filedocs-border);
	border-radius: 3px;
}

.filedocs-sidebar::-webkit-scrollbar-thumb:hover,
.filedocs-toc::-webkit-scrollbar-thumb:hover,
.filedocs-content::-webkit-scrollbar-thumb:hover,
.filedocs-search-results::-webkit-scrollbar-thumb:hover {
	background: var(--filedocs-text-muted);
}

/* =========================================================
   10. Loading state
   ========================================================= */

.filedocs-content.is-loading {
	position: relative;
	pointer-events: none;
	opacity: 0.5;
}

.filedocs-content.is-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 32px;
	height: 32px;
	margin: -16px 0 0 -16px;
	border: 3px solid var(--filedocs-border);
	border-top-color: var(--filedocs-accent);
	border-radius: 50%;
	animation: filedocs-spin 0.6s linear infinite;
}

@keyframes filedocs-spin {
	to { transform: rotate(360deg); }
}

/* =========================================================
   11. Responsive — mobile styles (< 768px)
   ========================================================= */

@media (max-width: 767px) {
	.filedocs-wrap {
		flex-direction: column;
	}

	.filedocs-hamburger {
		display: flex;
	}

	.filedocs-sidebar {
		position: fixed;
		top: 0;
		left: 0;
		bottom: 0;
		width: 300px;
		min-width: 300px;
		z-index: 100;
		transform: translateX(-100%);
		transition: transform 0.3s ease;
		box-shadow: var(--filedocs-shadow-lg);
	}

	.filedocs-sidebar.is-open {
		transform: translateX(0);
	}

	/* TOC: move above content on mobile */
	.filedocs-content-layout {
		flex-direction: column;
	}

	.filedocs-toc {
		width: 100%;
		min-width: 100%;
		border-left: none;
		border-bottom: 1px solid var(--filedocs-border);
		position: relative;
		max-height: none;
		padding: 0;
	}

	.filedocs-toc-header::before {
		display: none;
	}

	.filedocs-toc-toggle {
		display: flex;
		padding: 12px 16px;
		border-bottom: 1px solid var(--filedocs-border);
	}

	.filedocs-toc-nav {
		display: none;
		padding: 8px 16px 16px;
	}

	.filedocs-toc-nav.is-open {
		display: block;
	}

	.filedocs-toc-arrow {
		transition: transform var(--filedocs-transition);
	}

	.filedocs-toc-toggle[aria-expanded="true"] .filedocs-toc-arrow {
		transform: rotate(180deg);
	}

	.filedocs-content {
		padding: 20px 16px;
	}

	.filedocs-prevnext {
		padding: 16px;
		flex-direction: column;
	}

	.filedocs-prevnext-next {
		text-align: left;
	}

	.filedocs-prevnext-link {
		max-width: 100%;
		width: 100%;
	}

	.filedocs-breadcrumbs {
		padding: 10px 16px;
		font-size: 12px;
	}
}

/* =========================================================
   12. Print styles
   ========================================================= */

@media print {
	.filedocs-sidebar,
	.filedocs-toc,
	.filedocs-hamburger,
	.filedocs-sidebar-overlay,
	.filedocs-search-wrap,
	.filedocs-prevnext {
		display: none !important;
	}

	.filedocs-content {
		max-width: 100% !important;
		padding: 0 !important;
	}

	.filedocs-wrap {
		border: none !important;
	}
}

/* =========================================================
   13. Prism.js overrides (blend with theme)
   ========================================================= */

.filedocs-content pre[class*="language-"] {
	background: var(--filedocs-code-bg);
	border: 1px solid var(--filedocs-code-border);
	border-radius: var(--filedocs-radius-sm);
	padding: 16px 20px;
	margin: 0 0 16px 0;
}

.filedocs-wrap.filedocs-dark pre[class*="language-"] {
	background: #0d1117;
}

.filedocs-wrap.filedocs-dark code[class*="language-"] {
	color: #e6edf3;
}

/* =========================================================
   14. Heading anchor hover effect
   ========================================================= */

.filedocs-content h2,
.filedocs-content h3 {
	position: relative;
	scroll-margin-top: 24px;
}

.filedocs-content h2:hover::before,
.filedocs-content h3:hover::before {
	content: '#';
	position: absolute;
	left: -1.2em;
	color: var(--filedocs-accent);
	opacity: 0.5;
	font-weight: 400;
}
