/* ==========================================================================
   Document Controls — frontend styles
   Written defensively: many WordPress themes apply global CSS to
   input/button/select/img (often with !important) that breaks embedded
   widgets. Every rule below is scoped to .pf-container (or is a Bootstrap
   modal/backdrop override, which must stay unscoped — see the bottom of
   this file) and uses !important where needed to guarantee this plugin
   always renders the same way regardless of the active theme.
   ========================================================================== */

.pf-container,
.pf-container * ,
.pf-container *:before,
.pf-container *:after {
	box-sizing: border-box !important;
}

.pf-container {
	max-width: 100% !important;
}

/* --------------------------------------------------------------------
   Toolbar: search input + search button + category select
   -------------------------------------------------------------------- */
.pf-toolbar {
	display: flex !important;
	flex-wrap: wrap !important;
	align-items: center !important;
	margin: 0 0 20px 0 !important;
	width: 100% !important;
}

.pf-search-form {
	margin: 0 !important;
	padding: 0 !important;
	width: 100% !important;
}

.pf-control-row {
	display: flex !important;
	flex-wrap: wrap !important;
	align-items: stretch !important;
	gap: 8px !important;
	width: 100% !important;
}

/* Reset the theme's own input/button/select styling for every control
   used inside this plugin's toolbar, then apply our own consistent look. */
.pf-toolbar input.pf-control,
.pf-toolbar select.pf-control,
.pf-toolbar button.pf-control {
	display: inline-block !important;
	float: none !important;
	height: 36px !important;
	min-height: 36px !important;
	max-height: 36px !important;
	padding: 6px 12px !important;
	margin: 0 !important;
	font-size: 14px !important;
	line-height: 22px !important;
	color: #333 !important;
	background-color: #fff !important;
	background-image: none !important;
	border: 1px solid #ccc !important;
	border-radius: 4px !important;
	box-shadow: none !important;
	vertical-align: middle !important;
}

.pf-toolbar input.pf-control {
	width: 240px !important;
	max-width: 100% !important;
}

.pf-toolbar select.pf-control {
	width: 180px !important;
	max-width: 100% !important;
}

.pf-toolbar button.pf-control {
	width: auto !important;
	white-space: nowrap !important;
	cursor: pointer !important;
	font-weight: 700 !important;
	background-color: #f8f9fa !important;
}
.pf-toolbar button.pf-control:hover {
	background-color: #e9ecef !important;
}

/* --------------------------------------------------------------------
   Button colors (Download / Histories)
   -------------------------------------------------------------------- */
.pf-container .btn-primary {
	color: #fff !important;
	background-color: #337ab7 !important;
	border-color: #2e6da4 !important;
}
.pf-container .btn-primary:hover,
.pf-container .btn-primary:focus {
	background-color: #286090 !important;
	border-color: #204d74 !important;
}

/* Bootstrap 3 has no "secondary" button by default — add one so the
   Histories button gets its own distinct grey tone. */
.pf-container .btn-secondary {
	color: #fff !important;
	background-color: #6c757d !important;
	border-color: #6c757d !important;
}
.pf-container .btn-secondary:hover,
.pf-container .btn-secondary:focus {
	background-color: #5a6268 !important;
	border-color: #545b62 !important;
}

/* --------------------------------------------------------------------
   Card (thumbnail)
   -------------------------------------------------------------------- */
.pf-thumbnail {
	position: relative !important;
	padding: 8px !important;
	border-radius: 6px !important;
	margin-bottom: 16px !important;
}

.pf-category-badge {
	position: absolute !important;
	top: 16px !important;
	left: 16px !important;
	z-index: 2 !important;
	font-size: 10px !important;
	font-weight: 700 !important;
	text-transform: uppercase !important;
	letter-spacing: 0.03em !important;
	padding: 2px 8px !important;
	border-radius: 20px !important;
	background: rgba(255, 255, 255, 0.92) !important;
	color: #3b4fd6 !important;
	border: 1px solid #dfe3f5 !important;
}

.pf-thumb-image {
	width: 100% !important;
	height: 150px !important;
	object-fit: cover !important;
	border-radius: 3px !important;
	display: block !important;
}
.pf-thumb-placeholder {
	width: 100% !important;
	height: 150px !important;
	display: flex !important;
	align-items: center !important;
	justify-content: center !important;
	text-align: center !important;
	background: #fff !important;
	border: 1px solid #ddd !important;
	border-radius: 3px !important;
	color: #333 !important;
	font-size: 14px !important;
	line-height: 1.4 !important;
}

/* Download + Histories buttons: built as a plain flex bar (not Bootstrap's
   btn-group-justified) so full-width sizing can never be broken by a
   theme's global CSS resetting .btn's display/width/float. Each button
   gets an explicit, non-negotiable flex-basis of 50%. */
.pf-caption-buttons {
	display: flex !important;
	width: 100% !important;
	margin: 10px 0 !important;
	gap: 0 !important;
}
.pf-caption-buttons > .btn {
	flex: 1 1 50% !important;
	width: 50% !important;
	max-width: 50% !important;
	display: block !important;
	float: none !important;
	text-align: center !important;
	border-radius: 0 !important;
	margin: 0 !important;
}
.pf-caption-buttons > .btn:first-child {
	border-top-left-radius: 3px !important;
	border-bottom-left-radius: 3px !important;
}
.pf-caption-buttons > .btn:last-child {
	border-top-right-radius: 3px !important;
	border-bottom-right-radius: 3px !important;
}
/* If only one of the two buttons is present, let it take the full row. */
.pf-caption-buttons > .btn:only-child {
	width: 100% !important;
	max-width: 100% !important;
	border-radius: 3px !important;
}

.pf-card-title {
	text-align: center !important;
	font-size: 13px !important;
	font-weight: 700 !important;
	margin: 6px 0 0 0 !important;
	white-space: normal !important;
	overflow: visible !important;
	word-wrap: break-word !important;
}
.pf-caption-divider {
	margin: 10px 0 6px 0 !important;
	border-color: #e5e5e5 !important;
}
.pf-caption-meta {
	text-align: center !important;
	font-size: 11px !important;
	color: #888 !important;
	margin: 0 !important;
}

/* --------------------------------------------------------------------
   History timeline (rendered inside the modal body)
   -------------------------------------------------------------------- */
.pf-history-modal .modal-body {
	max-height: 60vh !important;
	overflow-y: auto !important;
}
.pf-history-box {
	text-align: left !important;
}
.pf-history-title {
	display: none !important; /* the modal header already says "Activity History" */
}
.pf-timeline {
	position: relative !important;
	list-style: none !important;
	margin: 0 !important;
	padding-left: 18px !important;
}
.pf-timeline::before {
	content: '' !important;
	position: absolute !important;
	left: 4px !important;
	top: 4px !important;
	bottom: 4px !important;
	width: 2px !important;
	background: #e5e5e5 !important;
}
.pf-timeline-item {
	position: relative !important;
	padding-bottom: 16px !important;
}
.pf-timeline-item:last-child {
	padding-bottom: 0 !important;
}
.pf-timeline-dot {
	position: absolute !important;
	left: -18px !important;
	top: 3px !important;
	width: 10px !important;
	height: 10px !important;
	border-radius: 50% !important;
	background: #999 !important;
	border: 2px solid #fff !important;
	box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) !important;
}
.pf-timeline-row {
	display: flex !important;
	justify-content: space-between !important;
	align-items: center !important;
	gap: 6px !important;
	margin-bottom: 3px !important;
}
.pf-timeline-date {
	color: #999 !important;
	font-size: 12px !important;
	white-space: nowrap !important;
}
.pf-timeline-note {
	font-size: 13px !important;
	margin: 2px 0 !important;
}
.pf-timeline-user {
	color: #999 !important;
	font-size: 12px !important;
}

/* ==========================================================================
   Responsive breakpoints (written explicitly rather than relying on the
   Bootstrap utility classes the host theme might override)
   ========================================================================== */

/* ---- Tablet & below: stack the toolbar controls, full width ---- */
@media (max-width: 767px) {
	.pf-control-row {
		flex-direction: column !important;
	}
	.pf-toolbar input.pf-control,
	.pf-toolbar select.pf-control,
	.pf-toolbar button.pf-control {
		width: 100% !important;
	}
}

/* ---- Small phones: tighten card image height a bit further ---- */
@media (max-width: 480px) {
	.pf-thumb-image,
	.pf-thumb-placeholder {
		height: 120px !important;
	}
}

/* ==========================================================================
   Bootstrap modal / backdrop stacking fix.
   Deliberately NOT scoped to .pf-container: Bootstrap's JS appends both
   the modal (via our JS relocation, see frontend.js) and the backdrop
   directly to <body>, outside our container, so neither can be targeted
   with a descendant selector. Many themes/page builders wrap sections in
   an element with `transform`/`filter`, which silently traps
   position:fixed descendants in a local stacking context — no z-index
   can fix that from CSS alone, which is why frontend.js also physically
   moves the modal to be a child of <body>. These rules are the second
   half of that fix: once both elements share the same stacking context,
   z-index ordering decides who's on top, so we use very high values to
   comfortably clear any sticky header/menu z-index the theme may set.
   ========================================================================== */
.pf-history-modal.modal {
	z-index: 2147483000 !important;
}
.modal-backdrop {
	z-index: 2147482900 !important;
}
.pf-history-modal .modal-dialog {
	z-index: 2147483000 !important;
	position: relative !important;
}
