/* Base tokens mirror refs/index.css */
.pn-sbf-root {
	--pn-sbf-primary: #0f4d4d;
	--pn-sbf-primary-soft: rgba(15, 77, 77, 0.1);
	--pn-sbf-primary-border: rgba(15, 77, 77, 0.2);
	--pn-sbf-accent: #efb80c;
	--pn-sbf-destructive: #ca2f25;
	--pn-sbf-border: #e5e7eb;
	--pn-sbf-muted: #f5f5f5;
	--pn-sbf-foreground: #272a2f;
}

/* === SEARCH WIDGET === */
.pn-sbf-search-widget {
	width: 100%;
	max-width: 32rem; /* max-w-lg */
	margin: 0 auto;
	position: relative;
}

.pn-sbf-search-wrapper {
	position: relative;
	display: flex;
	align-items: center;
}

.pn-sbf-search-icon {
	position: absolute;
	left: 0.75rem;
	color: #64748b;
}

.pn-sbf-search-input {
	width: 100%;
	padding: 1rem 3rem;
	border: 1px solid #ccc;
	border-radius: 6px;
	font-size: 1.2rem;
	background: #ffffff;
	transition: border-color 0.2s, box-shadow 0.2s;
	box-sizing: border-box;
}

.pn-sbf-search-input:focus {
	outline: none;
	border-color: var(--pn-sbf-primary);
	box-shadow: 0 0 0 2px rgba(15, 77, 77, 0.16);
}

.pn-sbf-search-clear {
	position: absolute;
	right: 0.75rem;
	background: none;
	border: none;
	color: #64748b;
	cursor: pointer;
	padding: 0;
	display: flex;
	align-items: center;
	justify-content: center;
}

.pn-sbf-search-clear:hover {
	color: #0f172a;
}

/* === FILTERS WIDGET === */
.pn-sbf-root {
	/* Shared wrapper marker for instance-scoped JS */
}

.pn-sbf-mobile-toggle {
	display: none !important; /* ensure hidden on desktop even if theme overrides */
	align-items: center;
	gap: 0.5rem;
	margin-bottom: 1rem;
}

.pn-sbf-filters-wrapper {
	width: 100%;
}

.pn-sbf-filters-content {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 0.75rem; /* rounded-xl */
	padding: 1.25rem;
	box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.pn-sbf-filters-title {
	font-size: 2rem; 
	font-weight: 700;
	color: #0f172a;
	margin-bottom: 0.75rem;
}

.pn-sbf-section-divider {
	height: 1px;
	background: #e2e8f0;
	width: 100%;
}

.pn-sbf-section-title {
	font-size: 0.75rem;
	font-weight: 700;
	color: #0f172a;
}

.pn-sbf-filter-section {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.pn-sbf-filters-header-mobile {
	display: none;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1.5rem;
}

.pn-sbf-filters-header-mobile h3 {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
}

.pn-sbf-mobile-close {
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
	color: #64748b;
}

.pn-sbf-filters-inner {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.pn-sbf-filter-group {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.pn-sbf-filter-group label {
	font-size: 1rem;
	font-weight: 500;
	color: #0f172a;
}

.pn-sbf-select {
	width: 100%;
	padding: 0.5rem 0.75rem;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	background-color: #f8fafc;
	font-size: 0.875rem;
	color: #0f172a;
	box-sizing: border-box;
}

.pn-sbf-select:focus {
	outline: none;
	border-color: var(--pn-sbf-primary);
	background-color: #ffffff;
}

/* Checkbox groups (Lovable-like) */
.pn-sbf-checkboxes {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
	max-height: 220px;
	overflow: auto;
	padding-right: 0.25rem;
	padding-top: 2px; /* prevent first checkbox from clipping at scroll top */
}

.pn-sbf-checkbox {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	cursor: pointer;
	user-select: none;
	font-size: 0.75rem;
	color: #0f172a;
}

.pn-sbf-checkbox input[type="checkbox"] {
	appearance: none;
	-webkit-appearance: none;
	width: 14px;
	height: 14px;
	border: 1px solid #94a3b8;
	border-radius: 3px;
	background: #ffffff;
	display: inline-block;
	position: relative;
	box-sizing: border-box;
	flex: 0 0 auto;
	margin-top: 1px; /* visually center in line box (avoids top cut-off) */
}

.pn-sbf-checkbox input[type="checkbox"]:checked {
	border-color: var(--pn-sbf-primary);
	background: var(--pn-sbf-primary);
}

.pn-sbf-checkbox input[type="checkbox"]:checked::after {
	content: '';
	position: absolute;
	left: 3px;
	top: 1px;
	width: 4px;
	height: 8px;
	border: solid #ffffff;
	border-width: 0 2px 2px 0;
	transform: rotate(45deg);
}

.pn-sbf-checkbox-text {
	line-height: 1.2;
	font-size: inherit;
}

.pn-sbf-checkboxes::-webkit-scrollbar {
	width: 8px;
}
.pn-sbf-checkboxes::-webkit-scrollbar-track {
	background: transparent;
}
.pn-sbf-checkboxes::-webkit-scrollbar-thumb {
	background: #94a3b8;
	border-radius: 999px;
}

/* Price header labels */
.pn-sbf-price-minmax {
	display: flex;
	justify-content: space-between;
	font-size: 0.75rem;
	color: #0f172a;
}

/* Price slider styling closer to Lovable */
.pn-sbf-price-slider input[type="range"]::-webkit-slider-thumb {
	background: var(--pn-sbf-primary);
	box-shadow: none;
}
.pn-sbf-slider-track {
	background: #e2e8f0;
}

/* Price Slider */
.pn-sbf-price-group {
	margin-top: 0.5rem;
}

.pn-sbf-price-slider {
	position: relative;
	height: 20px;
	display: flex;
	align-items: center;
	margin-bottom: 0.5rem;
}

.pn-sbf-slider-track {
	position: absolute;
	width: 100%;
	height: 4px;
	background: #e2e8f0;
	border-radius: 2px;
	z-index: 1;
}

.pn-sbf-price-slider input[type="range"] {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	background: transparent;
	position: absolute;
	pointer-events: none;
	z-index: 2;
	margin: 0;
}

.pn-sbf-price-slider input[type="range"]::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	height: 16px;
	width: 16px;
	border-radius: 50%;
	background: var(--pn-sbf-primary);
	cursor: pointer;
	pointer-events: auto;
	box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.pn-sbf-price-inputs {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}

.pn-sbf-price-inputs input {
	width: 100%;
	padding: 0.375rem;
	border: 1px solid #e2e8f0;
	border-radius: 6px;
	text-align: center;
	font-size: 0.875rem;
	background: #f8fafc;
	box-sizing: border-box;
}

/* Buttons */
.pn-sbf-btn-outline {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 0.5rem 1rem;
	border: 1px solid #e2e8f0;
	background: #ffffff;
	border-radius: 6px;
	font-size: 0.875rem;
	font-weight: 500;
	color: #0f172a;
	cursor: pointer;
	transition: background-color 0.2s;
}

.pn-sbf-btn-outline:hover {
	background: #f8fafc;
}

.pn-sbf-btn-primary {
	background-color: var(--pn-sbf-destructive);
	color: #ffffff;
	padding: 0.5rem 1rem;
	border-radius: 6px;
	font-size: 0.875rem;
	font-weight: 600;
	text-decoration: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: none;
	cursor: pointer;
	transition: background-color 0.2s;
}

.pn-sbf-btn-primary:hover {
	background-color: #a9271f;
	color: #ffffff;
}

.pn-sbf-actions {
	display: flex;
	gap: 0.75rem;
	align-items: center;
	justify-content: space-between;
	margin-top: 0.25rem;
}

.pn-sbf-actions .pn-sbf-btn-outline,
.pn-sbf-actions .pn-sbf-btn-primary {
	flex: 1;
}

.pn-sbf-btn-destructive {
	background-color: var(--pn-sbf-destructive);
	color: #ffffff;
	padding: 0.75rem 1rem;
	border-radius: 6px;
	font-size: 12px;
	line-height: 1.2;
	font-weight: 500;
	text-decoration: none;
	display: inline-block;
	border: none;
	cursor: pointer;
	transition: background-color 0.2s;
}

.pn-sbf-btn-destructive:hover {
	background-color: #a9271f;
	color: #ffffff;
}

/* Mobile responsive filters */ 
	.pn-sbf-mobile-toggle {
		display: flex !important;
		padding: 0.375rem 0.75rem;
		border-radius: 6px;
		font-size: 2rem;
		font-weight: 700;
		gap: 0.5rem;
		position: sticky;
		top: 0.75rem;
		z-index: 5;
	}
	
	.pn-sbf-filters-wrapper {
		display: none; /* hidden by default on mobile */
		position: fixed;
		inset: 0; /* JS overrides top/bottom inline to fit between header/footer */
		z-index: 9999;
	}
	
	.pn-sbf-filters-wrapper.is-open {
		display: block;
	}
	
	.pn-sbf-filters-overlay {
		position: absolute;
		inset: 0;
		background: rgba(15, 23, 42, 0.4);
	}
	
	.pn-sbf-filters-content {
		position: absolute;
		inset: 0;
		background: #ffffff;
		border-radius: 0;
		border: none;
		overflow-y: auto;
		padding: 1.25rem;
		animation: pnSbfSlideUp 0.3s ease-out;
		padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
		padding-top: calc(1.25rem + env(safe-area-inset-top));
	}
	
	.pn-sbf-filters-header-mobile {
		display: flex;
	}

	@keyframes pnSbfSlideUp {
		from { transform: translateY(100%); }
		to { transform: translateY(0); }
	}
}

/* === GRID WIDGET === */
.pn-sbf-grid-widget {
	width: 100%;
}

.pn-sbf-grid-header {
	margin-bottom: 1rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.pn-sbf-title {
	font-size: 2rem; /* text-xl */
	font-weight: 700;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	margin: 0;
}

.pn-sbf-title-icon {
	color: var(--pn-sbf-primary);
}

#pn-sbf-results-count-bracket {
	font-size: 1rem; /* text-sm */
	font-weight: 400;
	color: #64748b;
}

.pn-sbf-grid {
	display: grid;
	grid-template-columns: 1fr;
	gap: 1rem;
}

@media (min-width: 640px) {
	.pn-sbf-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1280px) {
	.pn-sbf-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Lovable Card Style */
.pn-sbf-card {
	background: #ffffff;
	border: 1px solid #e2e8f0;
	border-radius: 0.5rem; /* rounded-lg */
	padding: 1rem; /* p-4 */
	transition: all 0.2s ease;
}

.pn-sbf-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05); /* shadow-warm */
	border-color: rgba(239, 184, 12, 0.4);
}

.pn-sbf-card-link {
	text-decoration: none;
	color: inherit;
	display: block;
}

.pn-sbf-card-header {
	display: flex;
	gap: 0.75rem; /* gap-3 */
}

.pn-sbf-card-img-wrapper {
	flex-shrink: 0;
}

.pn-sbf-card-img {
	width: 56px; /* w-14 */
	height: 56px; /* h-14 */
	border-radius: 0.5rem; /* rounded-lg */
	object-fit: cover;
	background-color: #f1f5f9; /* bg-secondary */
}

.pn-sbf-card-info {
	flex: 1;
	min-width: 0;
}

.pn-sbf-card-title {
	font-size: 14px;
	font-weight: 700;
	line-height: 1.25;
	margin: 0;
	color: #0f172a;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	transition: color 0.2s;
}

.pn-sbf-card-link:hover .pn-sbf-card-title {
	color: var(--pn-sbf-primary);
}

.pn-sbf-card-publisher {
	font-size: 12px;
	font-weight: 400;
	line-height: 1.25;
	color: #64748b;
	margin: 0.125rem 0 0 0;
}

.pn-sbf-card-badges {
	margin-top: 1rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	flex-wrap: nowrap;
	overflow: hidden;
	min-width: 0;
}

.pn-sbf-badge {
	font-size: 10px;
	line-height: 1.2;
	padding: 2px 8px;
	border-radius: 9999px;
	font-weight: 600;
	border: 1px solid transparent;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	flex: 0 1 auto;
	min-width: 0;
}

.pn-sbf-badge-class {
	background-color: var(--pn-sbf-primary-soft);
	color: var(--pn-sbf-primary);
	border-color: var(--pn-sbf-primary-border);
	flex-shrink: 0;
}

.pn-sbf-badge-outline {
	background-color: transparent;
	border-color: #e2e8f0;
	color: #0f172a;
	max-width: 42%;
}

.pn-sbf-badge-bookset {
	flex-shrink: 0;
	max-width: none;
}

.pn-sbf-card-rating {
	margin-top: 1.25rem;
	display: flex;
	align-items: center;
	gap: 0.35rem;
	min-height: 22px;
	font-size: 11px;
	color: #64748b;
	font-weight: 500;
}

.pn-sbf-rating-pill {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 3px;
	height: 22px;
	padding: 0 7px;
	border-radius: 4px;
	background: var(--pn-sbf-primary);
	color: #ffffff;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.pn-sbf-rating-star {
	display: block;
	flex: 0 0 auto;
	color: currentColor;
}

.pn-sbf-rating-count {
	color: #64748b;
	font-size: 11px;
	line-height: 1;
}

.pn-sbf-card-footer {
	margin-top: 0.75rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.pn-sbf-card-price {
	font-size: 16px;
	line-height: 1.2;
	font-weight: 700;
	color: var(--pn-sbf-destructive);
}

.pn-sbf-card-price del {
	color: #94a3b8;
	font-size: 0.75rem;
	font-weight: 400;
	margin-right: 0.25rem;
}

.pn-sbf-card-price ins {
	text-decoration: none;
}

/* Pagination */
.pn-sbf-pagination {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	flex-wrap: wrap;
	margin-top: 1.5rem;
}

.pn-sbf-page-btn {
	min-width: 36px;
	height: 36px;
	padding: 0 0.75rem;
	border: 1px solid var(--pn-sbf-border);
	border-radius: 6px;
	background: #ffffff;
	color: var(--pn-sbf-foreground);
	font-size: 13px;
	font-weight: 600;
	cursor: pointer;
	transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.pn-sbf-page-btn:hover:not(:disabled),
.pn-sbf-page-btn.is-active {
	border-color: var(--pn-sbf-primary);
	background: var(--pn-sbf-primary);
	color: #ffffff;
}

.pn-sbf-page-btn:disabled {
	cursor: not-allowed;
	opacity: 0.45;
}

.pn-sbf-page-ellipsis {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 24px;
	height: 36px;
	color: #64748b;
	font-size: 13px;
	font-weight: 700;
}

/* Loading & Empty States */
.pn-sbf-loading {
	display: flex;
	justify-content: center;
	padding: 3rem 0;
}

.pn-sbf-spinner {
	width: 32px;
	height: 32px;
	border: 2px solid #e2e8f0;
	border-top-color: var(--pn-sbf-primary);
	border-radius: 50%;
	animation: pn-sbf-spin 1s linear infinite;
}

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

.pn-sbf-empty {
	text-align: center;
	padding: 3rem; /* p-12 */
	border: 2px dashed #e2e8f0; /* border-dashed */
	border-radius: 0.75rem; /* rounded-xl */
}

.pn-sbf-empty-title {
	font-size: 1.125rem; /* text-lg */
	font-weight: 700;
	margin: 0;
	color: #0f172a;
}

.pn-sbf-empty-subtitle {
	font-size: 0.875rem; /* text-sm */
	color: #64748b;
	margin: 0.25rem 0 0 0;
}

/* Hide filters title on mobile */
@media (max-width: 767px) {
	.pn-sbf-filters-title {
		display: none;
	}
}