/**
 * Public styles for WebEquipe PDF Search
 *
 * @package WebEquipe\PDFSearch
 * @since 1.0.0
 */

/* PDF Results Container */
.webequipe-pdf-results {
	margin: 20px 0;
}

.webequipe-pdf-results-list {
	list-style: none;
	padding: 0;
	margin: 0;
}

.webequipe-pdf-no-results {
	padding: 20px;
	text-align: center;
	color: #666;
	font-size: 1.1em;
}

/* PDF Result Items - block layout so meta/preview align under title (block themes e.g. Twenty Twenty-Five) */
.webequipe-pdf-result {
	display: block;
	position: relative;
	width: 100%;
	padding-left: 50px;
	margin-bottom: 20px;
	padding-bottom: 20px;
	border-bottom: 1px solid #e0e0e0;
	transition: background-color 0.2s ease;
	cursor: pointer;
	list-style: none;
	overflow: hidden;
	min-height: 0;
	box-sizing: border-box;
}

/* Meta/content box: same left margin as title so they align */
.webequipe-pdf-result .webequipe-pdf-search-result-content {
	display: block !important;
	width: 100% !important;
	min-width: 0;
	max-width: 100%;
	clear: both;
	box-sizing: border-box;
	margin: 0 0 10px 0;
	margin-top: 8px;
	margin-left: 0 !important;
	padding-left: 0 !important;
}

/* Thumbnail size (block themes e.g. Twenty Twenty-Five override without !important) */
.webequipe-pdf-result .webequipe-pdf-preview-wrapper {
	max-width: 220px !important;
	max-height: 280px !important;
	width: 220px !important;
}

.webequipe-pdf-result .webequipe-pdf-preview {
	max-width: 220px !important;
	max-height: 280px !important;
	width: 100% !important;
	height: auto !important;
	object-fit: contain;
}

.webequipe-pdf-result:hover {
	background-color: rgba(0, 0, 0, 0.03);
}

.webequipe-pdf-result a {
	text-decoration: none;
	color: inherit;
	display: block;
}

/* Title: same left margin as meta so they align (override theme margin) */
.webequipe-pdf-result h2,
.webequipe-pdf-result h3 {
	margin: 0 0 10px 0;
	margin-left: 0 !important;
	font-size: 1.2em;
}

.webequipe-pdf-title {
	margin: 0 0 10px 0;
	font-size: 1.2em;
}

.webequipe-pdf-title a {
	color: #2271b1;
	text-decoration: none;
}

.webequipe-pdf-title a:hover {
	text-decoration: underline;
}

/* Wrapper for PDF search result content (meta + excerpt). clear: both keeps this block
   below the theme's author/date line so that line stays on one line instead of wrapping. */
.webequipe-pdf-search-result-content {
	display: block;
	margin-top: 8px;
	clear: both;
}

/* Title line: keep PDF icon and title text on same line; allow title to wrap (theme compatibility e.g. Avada) */
/* Icon stays at top when title wraps so the heading starts at the icon. */
.webequipe-pdf-title-line {
	display: inline-flex;
	align-items: flex-start;
	flex-wrap: nowrap;
	gap: 8px;
	vertical-align: top;
	max-width: 100%;
}

/* Let title text wrap to multiple lines instead of truncating or breaking layout */
.webequipe-pdf-title-line,
h1 .webequipe-pdf-title-line,
h2 .webequipe-pdf-title-line,
h3 .webequipe-pdf-title-line {
	word-wrap: break-word;
	word-break: break-word;
	overflow-wrap: break-word;
}

/* PDF Icon/Badge */
.webequipe-pdf-icon {
	position: relative;
	left: 0;
	top: 0;
	width: 20px;
	height: 20px;
	font-size: 20px;
	line-height: 1;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Inline icon (in title): stay on same line as title text */
.webequipe-pdf-icon--inline {
	display: inline-flex;
	flex-shrink: 0;
	align-self: flex-start;
	vertical-align: top;
	width: 1em;
	height: 1em;
	font-size: 1em;
}

.webequipe-pdf-icon img,
.webequipe-pdf-icon svg {
	width: 100%;
	height: 100%;
	display: block;
}

.webequipe-pdf-icon svg {
	width: 100%;
	height: 100%;
}

.webequipe-pdf-icon--small {
	width: 16px;
	height: 16px;
	font-size: 16px;
}

.webequipe-pdf-icon--large {
	width: 28px;
	height: 28px;
	font-size: 28px;
}

/* File Meta Information - no left margin so meta aligns with file title */
.webequipe-pdf-meta {
	font-size: 0.9em;
	color: #555;
	margin: 0;
	margin-top: 8px;
	margin-bottom: 0;
	margin-left: 0;
	padding-left: 0;
	display: block;
	line-height: 1.7;
	max-width: 100%;
	overflow-wrap: break-word;
	word-wrap: break-word;
	word-break: break-word;
}

/* In theme cards, meta inherits so it stays visible on both light and dark cards */
.webequipe-pdf-search-result-content .webequipe-pdf-meta {
	color: inherit;
}

.webequipe-pdf-meta-item {
	display: inline;
	white-space: nowrap;
}

.webequipe-pdf-meta-sep {
	color: #b0b0b0;
	margin: 0 4px;
}

.webequipe-pdf-meta .webequipe-pdf-icon {
	display: inline-flex;
	align-items: center;
	margin-right: 6px;
}

.webequipe-pdf-meta .webequipe-pdf-icon svg {
	width: 16px;
	height: 16px;
	display: block;
}

.webequipe-pdf-meta .webequipe-pdf-icon-img {
	width: 16px;
	height: 16px;
	display: block;
}

/* Search Excerpts / summary */
.webequipe-pdf-excerpt {
	margin-top: 10px;
	line-height: 1.6;
	color: #444;
	display: block;
	max-width: 100%;
	max-height: none;
	-webkit-line-clamp: unset;
	-webkit-box-orient: unset;
	overflow-wrap: break-word;
	word-wrap: break-word;
	overflow: visible;
}

/* In theme cards, excerpt inherits so it stays visible on both light and dark cards */
.webequipe-pdf-search-result-content .webequipe-pdf-excerpt {
	color: inherit;
}

/* PDF Preview Thumbnail - constrained so it never shows full page (block themes) */
.webequipe-pdf-preview-wrapper {
	display: block;
	margin-top: 10px;
	margin-bottom: 10px;
	max-width: 220px !important;
	max-height: 280px !important;
	width: 220px;
}

.webequipe-pdf-preview {
	display: block;
	max-width: 220px !important;
	max-height: 280px !important;
	width: 100% !important;
	height: auto !important;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
	background: #fff;
	object-fit: contain;
}

/* Pagination */
.webequipe-pdf-pagination {
	margin: 30px 0;
	text-align: center;
}

.webequipe-pdf-pagination .page-numbers {
	display: inline-block;
	list-style: none;
	margin: 0;
	padding: 0;
}

.webequipe-pdf-pagination .page-numbers li {
	display: inline-block;
	margin: 0 4px;
}

.webequipe-pdf-pagination .page-numbers a,
.webequipe-pdf-pagination .page-numbers span {
	display: inline-block;
	padding: 8px 12px;
	border: 1px solid #ddd;
	border-radius: 4px;
	text-decoration: none;
	color: #2271b1;
	background: #fff;
	transition: all 0.2s ease;
}

.webequipe-pdf-pagination .page-numbers a:hover {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
}

.webequipe-pdf-pagination .page-numbers .current {
	background: #2271b1;
	color: #fff;
	border-color: #2271b1;
	cursor: default;
}

.webequipe-pdf-pagination .page-numbers .dots {
	border: none;
	background: transparent;
	color: #666;
	cursor: default;
}

/* Highlighted Search Terms */
.webequipe-pdf-excerpt mark {
	background-color: #ffeb3b;
	font-weight: bold;
	padding: 0 2px;
	color: inherit;
}

/* Search Form Styling */
.webequipe-pdf-search-form-wrapper {
	margin: 20px 0;
}

.webequipe-pdf-search-form {
	display: flex;
	gap: 10px;
	align-items: stretch;
}

.webequipe-pdf-search-input {
	flex: 1;
	padding: 10px 15px;
	border: 1px solid #ddd;
	border-radius: 4px;
	font-size: 16px;
}

.webequipe-pdf-search-input:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.1);
}

.webequipe-pdf-search-submit {
	padding: 10px 20px;
	background-color: #2271b1;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	font-size: 16px;
	transition: background-color 0.2s ease;
}

.webequipe-pdf-search-submit:hover {
	background-color: #135e96;
}

.webequipe-pdf-search-submit:focus {
	outline: none;
	box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.3);
}

/* Loading States */
.webequipe-pdf-loading {
	opacity: 0.6;
	position: relative;
	pointer-events: none;
}

.webequipe-pdf-loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #2271b1;
	border-radius: 50%;
	animation: webequipe-pdf-spin 1s linear infinite;
}

@keyframes webequipe-pdf-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
	.webequipe-pdf-result {
		padding-left: 40px;
		padding-bottom: 15px;
		margin-bottom: 15px;
	}

	.webequipe-pdf-icon {
		width: 24px;
		height: 24px;
		font-size: 24px;
	}

	.webequipe-pdf-result h2,
	.webequipe-pdf-result h3 {
		font-size: 1.1em;
	}

	.webequipe-pdf-meta {
		font-size: 0.85em;
		flex-direction: column;
		align-items: flex-start;
		gap: 5px;
	}

	.webequipe-pdf-meta-item::after {
		display: none;
	}

	.webequipe-pdf-search-form {
		flex-direction: column;
	}

	.webequipe-pdf-search-input,
	.webequipe-pdf-search-submit {
		width: 100%;
	}
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
	.webequipe-pdf-result {
		border-bottom-color: #444;
	}

	.webequipe-pdf-result:hover {
		background-color: rgba(255, 255, 255, 0.05);
	}

	.webequipe-pdf-meta {
		color: #aaa;
	}

	.webequipe-pdf-excerpt {
		color: #ccc;
	}

	.webequipe-pdf-search-input {
		background-color: #2a2a2a;
		border-color: #444;
		color: #fff;
	}
}

/* Print Styles */
@media print {
	.webequipe-pdf-icon {
		display: none;
	}

	.webequipe-pdf-result {
		padding-left: 0;
		page-break-inside: avoid;
	}

	.webequipe-pdf-search-form {
		display: none;
	}
}

/* RTL Support */
[dir="rtl"] .webequipe-pdf-result {
	padding-left: 0;
	padding-right: 50px;
}

[dir="rtl"] .webequipe-pdf-icon {
	left: auto;
	right: 0;
}

[dir="rtl"] .webequipe-pdf-search-form {
	direction: rtl;
}

/*
 * When "Display PDF thumbnail preview" is unchecked, some themes (e.g. Avada Classic)
 * still show the featured image in search results via their own template. This hides
 * that image only for PDF/attachment results on the search page.
 */
body.webequipe-pdf-preview-off.search .attachment .fusion-post-card-image,
body.webequipe-pdf-preview-off.search .attachment .fusion-post-card-image img {
	display: none !important;
}
