/**
 * FPL Document Library — Standalone PDF Viewer Styles
 *
 * @package FPL\DocumentLibrary
 */

:root {
	--fpl-v-bg: #1c272c;
	--fpl-v-toolbar-bg: #113f4d;
	--fpl-v-toolbar-border: #1a5668;
	--fpl-v-text: #ffffff;
	--fpl-v-text-muted: #9cc1cc;
	--fpl-v-primary: #165567;
	--fpl-v-accent: #2baab8;
	--fpl-v-btn-hover: rgba(255, 255, 255, 0.12);
	--fpl-v-btn-active: rgba(255, 255, 255, 0.22);
	--fpl-v-radius: 6px;
}

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

html, body.fpl-viewer-body {
	margin: 0;
	padding: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	background-color: var(--fpl-v-bg);
	color: var(--fpl-v-text);
	font-family: var(--wp--preset--font-family--montserrat, 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif);
	-webkit-font-smoothing: antialiased;
}

.fpl-viewer-wrapper {
	display: flex;
	flex-direction: column;
	width: 100vw;
	height: 100vh;
	overflow: hidden;
}

body.admin-bar .fpl-viewer-wrapper {
	height: calc(100vh - 32px);
}

@media screen and (max-width: 782px) {
	body.admin-bar .fpl-viewer-wrapper {
		height: calc(100vh - 46px);
	}
}

/* Toolbar */
.fpl-viewer-toolbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	min-height: 56px;
	height: auto;
	padding: 6px 16px;
	background-color: var(--fpl-v-toolbar-bg);
	border-bottom: 1px solid var(--fpl-v-toolbar-border);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
	z-index: 100;
	flex-shrink: 0;
	gap: 12px;
}

.fpl-viewer-group {
	display: flex;
	align-items: center;
	gap: 8px;
}

.fpl-viewer-group-left {
	flex: 1 1 42%;
	min-width: 0;
}

.fpl-viewer-group-center {
	flex: 0 0 auto;
	justify-content: center;
}

.fpl-viewer-group-right {
	flex: 1 1 32%;
	justify-content: flex-end;
}

/* Document Title & Context Box */
.fpl-viewer-title-box {
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin-left: 10px;
	gap: 2px;
}

.fpl-viewer-title-row {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.fpl-vbadge {
	display: inline-flex;
	align-items: center;
	padding: 2px 7px;
	border-radius: 4px;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	flex-shrink: 0;
	letter-spacing: 0.02em;
}

.fpl-vbadge-type {
	background-color: rgba(98, 140, 165, 0.25);
	color: #9cc1cc;
	border: 1px solid rgba(98, 140, 165, 0.4);
}

.fpl-vbadge-status.status--in-force {
	background-color: rgba(34, 197, 94, 0.2);
	color: #4ade80;
	border: 1px solid rgba(34, 197, 94, 0.4);
}

.fpl-vbadge-status.status--repealed {
	background-color: rgba(239, 68, 68, 0.2);
	color: #f87171;
	border: 1px solid rgba(239, 68, 68, 0.4);
}

.fpl-vbadge-status.status--unknown {
	background-color: rgba(148, 163, 184, 0.2);
	color: #cbd5e1;
	border: 1px solid rgba(148, 163, 184, 0.35);
}

.fpl-viewer-title {
	margin: 0;
	font-family: var(--wp--preset--font-family--manrope, 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif);
	font-size: 13.5px;
	font-weight: 600;
	color: var(--fpl-v-text);
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	line-height: 1.3;
}

.fpl-viewer-subtitle {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 10px;
	font-size: 11px;
	color: var(--fpl-v-text-muted);
	line-height: 1.3;
}

.fpl-viewer-meta-item {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	white-space: nowrap;
}

.fpl-viewer-meta-label {
	color: rgba(255, 255, 255, 0.6);
	font-weight: 500;
}

.fpl-viewer-meta-val {
	color: var(--fpl-v-text);
	font-weight: 500;
}

.fpl-viewer-meta-category {
	background: rgba(255, 255, 255, 0.08);
	padding: 1px 6px;
	border-radius: 3px;
}

/* Buttons */
.fpl-vbtn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 38px;
	height: 38px;
	padding: 0 10px;
	background: transparent;
	border: 1px solid transparent;
	border-radius: var(--fpl-v-radius);
	color: var(--fpl-v-text);
	cursor: pointer;
	font-size: 13px;
	text-decoration: none;
	user-select: none;
	box-sizing: border-box;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fpl-vbtn svg {
	width: 18px;
	height: 18px;
	flex-shrink: 0;
}

.fpl-vbtn:hover:not(:disabled) {
	background-color: var(--fpl-v-btn-hover);
}

.fpl-vbtn:active:not(:disabled) {
	background-color: var(--fpl-v-btn-active);
}

.fpl-vbtn:focus-visible {
	outline: 2px solid var(--fpl-v-accent);
	outline-offset: 1px;
}

.fpl-vbtn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

/* Semantic Back Button */
.fpl-vbtn-back {
	background-color: rgba(255, 255, 255, 0.1);
	border: 1px solid rgba(255, 255, 255, 0.22);
	color: #ffffff;
	font-weight: 500;
	padding: 0 12px;
	gap: 6px;
	flex-shrink: 0;
}

.fpl-vbtn-back:hover:not(:disabled) {
	background-color: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.38);
	color: #ffffff;
}

/* Fit Width Button */
.fpl-vbtn-fit.active {
	background-color: rgba(43, 170, 184, 0.25);
	border-color: var(--fpl-v-accent);
	color: #ffffff;
}

/* Download Action Button */
.fpl-vbtn-download {
	background-color: var(--fpl-v-accent);
	color: #0b2229;
	font-weight: 600;
	gap: 6px;
	padding: 0 14px;
	border: 1px solid var(--fpl-v-accent);
}

.fpl-vbtn-download:hover:not(:disabled) {
	background-color: #3ad3e3;
	border-color: #3ad3e3;
	color: #0b2229;
}

/* Page Counter */
.fpl-viewer-page-counter {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 13px;
	color: var(--fpl-v-text);
}

.fpl-viewer-page-input {
	width: 48px;
	height: 34px;
	background-color: rgba(0, 0, 0, 0.28);
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: var(--fpl-v-radius);
	color: var(--fpl-v-text);
	text-align: center;
	font-size: 13px;
	font-weight: 500;
	-moz-appearance: textfield;
}

.fpl-viewer-page-input::-webkit-outer-spin-button,
.fpl-viewer-page-input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.fpl-viewer-page-input:focus {
	outline: 2px solid var(--fpl-v-accent);
	border-color: transparent;
}

.fpl-viewer-page-slash {
	color: var(--fpl-v-text-muted);
}

.fpl-viewer-page-total {
	font-weight: 500;
	min-width: 20px;
}

/* Zoom Dropdown */
.fpl-viewer-zoom-select {
	height: 38px;
	background-color: rgba(0, 0, 0, 0.28);
	border: 1px solid rgba(255, 255, 255, 0.22);
	border-radius: var(--fpl-v-radius);
	color: var(--fpl-v-text);
	font-size: 13px;
	padding: 0 10px;
	cursor: pointer;
}

.fpl-viewer-zoom-select:focus {
	outline: 2px solid var(--fpl-v-accent);
}

/* Main Content Area */
.fpl-viewer-main {
	flex: 1 1 auto;
	overflow: auto;
	position: relative;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 24px 16px;
	background-color: var(--fpl-v-bg);
}

.fpl-viewer-main:focus {
	outline: none;
}

.fpl-viewer-canvas-wrap {
	display: flex;
	justify-content: center;
	box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
	border-radius: 2px;
	background-color: #ffffff;
	max-width: 100%;
	margin: auto;
}

#fpl-vcanvas {
	display: block;
	max-width: 100%;
	height: auto;
}

/* Loading Spinner */
.fpl-viewer-loader {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 16px;
	background-color: rgba(17, 30, 35, 0.92);
	padding: 24px 32px;
	border-radius: 8px;
	backdrop-filter: blur(4px);
	z-index: 50;
}

.fpl-viewer-loader.hidden,
.fpl-viewer-error.hidden {
	display: none;
}

.fpl-viewer-spinner {
	width: 36px;
	height: 36px;
	border: 3px solid rgba(255, 255, 255, 0.15);
	border-top-color: var(--fpl-v-accent);
	border-radius: 50%;
	animation: fpl-v-spin 0.8s linear infinite;
}

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

/* Error State */
.fpl-viewer-error {
	max-width: 440px;
	margin: 60px auto;
	text-align: center;
	background-color: #212c31;
	border: 1px solid #d63638;
	padding: 32px 24px;
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.fpl-viewer-error-icon {
	font-size: 36px;
	margin-bottom: 12px;
}

.fpl-viewer-error-title {
	margin: 0 0 8px 0;
	font-size: 18px;
	color: #fff;
}

.fpl-viewer-error-message {
	margin: 0;
	font-size: 14px;
	color: var(--fpl-v-text-muted);
}

/* Mobile Toolbar Experience (<= 640px) */
@media (max-width: 640px) {
	.fpl-viewer-toolbar {
		height: auto;
		min-height: 56px;
		padding: 8px 10px;
		gap: 6px;
		flex-wrap: wrap;
	}

	.fpl-viewer-group-left {
		order: 1;
		flex: 1 1 100%;
		margin-bottom: 2px;
	}

	.fpl-viewer-group-center {
		order: 2;
		flex: 1 1 auto;
		justify-content: flex-start;
		gap: 4px;
	}

	.fpl-viewer-group-right {
		order: 3;
		flex: 0 0 auto;
		justify-content: flex-end;
		gap: 4px;
	}

	.fpl-viewer-title-box {
		margin-left: 8px;
		max-width: calc(100% - 75px);
	}

	.fpl-viewer-title-row {
		flex-wrap: wrap;
		gap: 4px;
	}

	.fpl-viewer-title {
		font-size: 12.5px;
	}

	.fpl-viewer-subtitle {
		font-size: 10px;
		gap: 6px;
	}

	.fpl-viewer-zoom-select {
		display: none;
	}

	.fpl-vbtn-label {
		display: inline;
	}

	.fpl-vbtn-download .fpl-vbtn-label {
		display: none;
	}

	.fpl-vbtn {
		min-width: 34px;
		height: 34px;
		padding: 0 6px;
	}

	.fpl-vbtn-back {
		padding: 0 8px;
		min-width: auto;
		font-size: 12px;
	}

	.fpl-vbtn-download {
		padding: 0 8px;
		min-width: 34px;
	}

	.fpl-viewer-main {
		padding: 8px 4px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fpl-vbtn,
	.fpl-viewer-spinner {
		transition: none;
		animation: none;
	}
}
