/* PDF Extractor — front end styles. Scoped to .pdfx-* and built to survive
   being dropped into any theme, flex container or page builder column. */

.pdfx-app {
	/* Every colour below is supplied inline by the plugin, derived from the
	   configured background and contrast-checked. These are only fallbacks. */
	--pdfx-bg: transparent;
	--pdfx-ink: #171614;
	--pdfx-muted: #56534c;
	--pdfx-border: #c9c7c1;
	--pdfx-surface: #e6e5e1;
	--pdfx-card: #ffffff;
	--pdfx-track: #d7d5d0;
	--pdfx-accent: #1f6feb;
	--pdfx-accent-ink: #1a5fc8;
	--pdfx-on-accent: #ffffff;
	--pdfx-ok: #14663a;
	--pdfx-warn: #7a5310;
	--pdfx-error: #96231f;
	--pdfx-radius: 14px;
	background: var(--pdfx-bg);
	color: var(--pdfx-ink);
	box-sizing: border-box;
	display: block;
	width: 100%;
	max-width: 100%;
	min-width: 0;
	flex: 1 1 100%;
	align-self: stretch;
	grid-column: 1 / -1;
}

/* Give the block breathing room when it paints its own background. */
.pdfx-app.has-bg {
	padding: clamp(18px, 3vw, 32px);
	border-radius: var(--pdfx-radius);
}

.pdfx-app h2,
.pdfx-app h3,
.pdfx-app p,
.pdfx-app label,
.pdfx-app pre {
	color: var(--pdfx-ink);
}

.pdfx-app *,
.pdfx-app *::before,
.pdfx-app *::after {
	box-sizing: border-box;
}

.pdfx-heading {
	margin: 0 0 .4em;
}

.pdfx-intro {
	margin: 0 0 1.2em;
	max-width: 65ch;
}

.pdfx-intro p:last-child {
	margin-bottom: 0;
}

.pdfx-locked {
	padding: 1em 1.2em;
	border: 1px dashed var(--pdfx-border, rgba(0, 0, 0, .2));
	border-radius: 12px;
}

/* ---------- dropzone ---------- */

.pdfx-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: .4em;
	padding: 2.6em 1.5em;
	text-align: center;
	border: 2px dashed var(--pdfx-border);
	border-radius: var(--pdfx-radius);
	background: var(--pdfx-surface);
	cursor: pointer;
	transition: border-color .15s ease, background .15s ease;
}

.pdfx-drop:hover,
.pdfx-drop:focus-visible,
.pdfx-drop.is-over {
	border-color: var(--pdfx-accent);
	background: color-mix(in srgb, var(--pdfx-accent) 7%, transparent);
	outline: none;
}

.pdfx-drop-icon {
	width: 34px;
	height: 34px;
	color: var(--pdfx-accent-ink);
}

.pdfx-drop-title {
	margin: 0;
	font-weight: 600;
}

.pdfx-drop-note {
	margin: 0;
	font-size: .88em;
	color: var(--pdfx-muted);
	max-width: 46ch;
}

/* ---------- status + progress ---------- */

.pdfx-status {
	margin: 1em 0 0;
	padding: .7em 1em;
	border: 1px solid var(--pdfx-border);
	border-radius: 10px;
	font-size: .95em;
	color: var(--pdfx-muted);
	background: var(--pdfx-surface);
}

.pdfx-status--ok {
	border-color: color-mix(in srgb, var(--pdfx-ok) 40%, var(--pdfx-border));
	background: color-mix(in srgb, var(--pdfx-ok) 8%, var(--pdfx-bg, transparent));
	color: var(--pdfx-ok);
}

.pdfx-status--warn {
	border-color: color-mix(in srgb, var(--pdfx-warn) 40%, var(--pdfx-border));
	background: color-mix(in srgb, var(--pdfx-warn) 10%, var(--pdfx-bg, transparent));
	color: var(--pdfx-warn);
}

.pdfx-status--error {
	border-color: color-mix(in srgb, var(--pdfx-error) 40%, var(--pdfx-border));
	background: color-mix(in srgb, var(--pdfx-error) 8%, var(--pdfx-bg, transparent));
	color: var(--pdfx-error);
}

.pdfx-progress {
	margin-top: 1em;
}

.pdfx-bar {
	height: 8px;
	border-radius: 999px;
	background: var(--pdfx-track);
	overflow: hidden;
}

.pdfx-bar-fill {
	height: 100%;
	width: 0;
	border-radius: 999px;
	background: var(--pdfx-accent);
	transition: width .2s ease;
}

.pdfx-bar-label {
	margin-top: .45em;
	font-size: .85em;
	color: var(--pdfx-muted);
}

/* ---------- results ---------- */

.pdfx-results {
	margin-top: 1.4em;
}

.pdfx-stats {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 1.1em;
}

.pdfx-stat {
	color: var(--pdfx-ink);
	display: flex;
	flex-direction: column;
	align-items: baseline;
	gap: 2px;
	padding: .6em 1.1em;
	border: 1px solid var(--pdfx-border);
	border-radius: 10px;
	background: var(--pdfx-surface);
	min-width: 90px;
}

.pdfx-stat strong {
	font-size: 1.35em;
	line-height: 1.1;
}

.pdfx-stat span {
	font-size: .82em;
	color: var(--pdfx-muted);
}

.pdfx-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin-bottom: .9em;
}

.pdfx-options {
	display: flex;
	flex-wrap: wrap;
	gap: 1.2em;
	margin-bottom: 1.2em;
	font-size: .9em;
	color: var(--pdfx-muted);
}

.pdfx-options label {
	display: inline-flex;
	align-items: center;
	gap: .45em;
	cursor: pointer;
	margin: 0;
	font-weight: inherit;
}

.pdfx-btn {
	font: inherit;
	line-height: 1.2;
	padding: .62em 1.15em;
	border-radius: 999px;
	border: 1px solid var(--pdfx-border);
	background: var(--pdfx-card);
	color: var(--pdfx-ink);
	cursor: pointer;
	transition: background .15s ease, opacity .15s ease;
}

.pdfx-btn:hover:not(:disabled) {
	background: var(--pdfx-surface);
}

.pdfx-btn-primary {
	background: var(--pdfx-accent);
	border-color: var(--pdfx-accent);
	color: var(--pdfx-on-accent);
	font-weight: 600;
}

.pdfx-btn-primary:hover:not(:disabled) {
	background: var(--pdfx-accent);
	filter: brightness(1.07);
}

.pdfx-btn-small {
	padding: .35em .9em;
	font-size: .85em;
}

.pdfx-btn:disabled {
	opacity: .45;
	cursor: not-allowed;
}

/* ---------- markdown panel ---------- */

.pdfx-panel {
	border: 1px solid var(--pdfx-border);
	border-radius: var(--pdfx-radius);
	overflow: hidden;
	margin-bottom: 1.4em;
}

.pdfx-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
	padding: .55em .7em;
	border-bottom: 1px solid var(--pdfx-border);
	background: var(--pdfx-surface);
	flex-wrap: wrap;
}

.pdfx-panel-head h3 {
	margin: 0;
	font-size: 1em;
}

.pdfx-preview {
	margin: 0;
	background: var(--pdfx-card);
	color: var(--pdfx-ink);
	padding: 1em 1.1em;
	max-height: 460px;
	overflow: auto;
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: .85em;
	line-height: 1.6;
	white-space: pre-wrap;
	word-break: break-word;
	tab-size: 2;
}

/* ---------- panel tabs ---------- */

.pdfx-tabs {
	display: flex;
	gap: 4px;
	padding: 3px;
	border: 1px solid var(--pdfx-border);
	border-radius: 999px;
	background: var(--pdfx-card);
}

.pdfx-tab {
	font: inherit;
	font-size: .85em;
	line-height: 1.2;
	padding: .38em .95em;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: var(--pdfx-muted);
	cursor: pointer;
	transition: background .15s ease, color .15s ease;
}

.pdfx-tab:hover {
	color: var(--pdfx-ink);
}

.pdfx-tab.is-active {
	background: var(--pdfx-accent);
	color: var(--pdfx-on-accent);
	font-weight: 600;
}

/* ---------- rendered preview ---------- */

.pdfx-rendered {
	padding: 1.4em 1.6em;
	max-height: 460px;
	overflow: auto;
	background: var(--pdfx-card);
	color: var(--pdfx-ink);
	line-height: 1.6;
}

.pdfx-rendered > *:first-child {
	margin-top: 0;
}

.pdfx-rendered h1,
.pdfx-rendered h2,
.pdfx-rendered h3,
.pdfx-rendered h4 {
	line-height: 1.25;
	margin: 1.6em 0 .5em;
	color: var(--pdfx-ink);
}

.pdfx-rendered h1 { font-size: 1.6em; }
.pdfx-rendered h2 { font-size: 1.3em; }
.pdfx-rendered h3 { font-size: 1.1em; }

.pdfx-rendered p { margin: 0 0 1em; }

.pdfx-rendered ul,
.pdfx-rendered ol {
	margin: 0 0 1em;
	padding-left: 1.4em;
}

.pdfx-rendered li { margin: .2em 0; }

.pdfx-rendered hr {
	border: 0;
	border-top: 1px solid var(--pdfx-border);
	margin: 1.8em 0;
}

.pdfx-rendered figure { margin: 1.2em 0; }

.pdfx-rendered img {
	max-width: 100%;
	height: auto;
	border-radius: 6px;
}

.pdfx-rendered figcaption {
	margin-top: .4em;
	font-size: .82em;
	color: var(--pdfx-muted);
}

.pdfx-rendered code {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: .9em;
	background: var(--pdfx-surface);
	padding: .12em .35em;
	border-radius: 4px;
}

/* ---------- gallery ---------- */

.pdfx-gallery-wrap h3 {
	margin: 0 0 .7em;
	font-size: 1em;
}

.pdfx-gallery {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
	gap: 14px;
}

.pdfx-thumb {
	margin: 0;
	border: 1px solid var(--pdfx-border);
	border-radius: 10px;
	overflow: hidden;
	background: var(--pdfx-card);
}

.pdfx-thumb img {
	display: block;
	width: 100%;
	height: 120px;
	object-fit: contain;
	/* Chequerboard so transparent PNGs are readable on any background. */
	background: repeating-conic-gradient(rgba(128, 128, 128, .18) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
}

.pdfx-thumb figcaption {
	padding: .4em .6em;
	font-size: .75em;
	color: var(--pdfx-muted);
	text-align: center;
	border-top: 1px solid var(--pdfx-border);
}

@media (prefers-reduced-motion: reduce) {
	.pdfx-app * {
		transition: none !important;
	}
}
