/* ============================================
   Projects Map Showcase — Frontend Styles
   Blocksy-compatible, dark card design
   ============================================ */

:root {
	--pms-primary: #4bbe6a;
	--pms-primary-hover: #3da85a;
	--pms-dark: #1e2a3a;
	--pms-darker: #151f2b;
	--pms-card-bg: #1e2a3a;
	--pms-card-text: #ffffff;
	--pms-card-meta: #a0aec0;
	--pms-body-bg: #ffffff;
	--pms-body-text: #1a202c;
	--pms-border: #e2e8f0;
	--pms-radius: 12px;
	--pms-shadow: 0 4px 20px rgba(0,0,0,0.08);
	--pms-split-left: 40%;
	--pms-split-right: 60%;
}

.pms-showcase {
	position: relative;
	margin: 0 auto;
	font-family: inherit;
}

/* ---- Layout: Toggle (default max-width) ---- */
.pms-layout-toggle {
	max-width: 1200px;
}

/* ---- Layout: Split ---- */
.pms-layout-split {
	max-width: 100%;
}

.pms-layout-split .pms-content {
	display: flex;
	gap: 0;
	min-height: 80vh;
}

.pms-layout-split .pms-list-view {
	width: var(--pms-split-left);
	max-height: 85vh;
	overflow-y: auto;
	padding: 16px 20px;
	box-sizing: border-box;
	scrollbar-width: thin;
	scrollbar-color: var(--pms-card-meta) transparent;
}

.pms-layout-split .pms-list-view::-webkit-scrollbar {
	width: 6px;
}
.pms-layout-split .pms-list-view::-webkit-scrollbar-track {
	background: transparent;
}
.pms-layout-split .pms-list-view::-webkit-scrollbar-thumb {
	background: var(--pms-card-meta);
	border-radius: 3px;
}

.pms-layout-split .pms-map-view {
	width: var(--pms-split-right);
	position: sticky;
	top: 0;
	height: 85vh;
	border-radius: 0;
	box-shadow: none;
}

.pms-layout-split .pms-map {
	height: 100%;
}

.pms-layout-split .pms-projects-grid {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.pms-layout-split .pms-project-card {
	flex-direction: row;
	min-height: 0;
}

.pms-layout-split .pms-card-image {
	width: 180px;
	min-width: 180px;
	height: auto;
	min-height: 180px;
	object-fit: cover;
}

.pms-layout-split .pms-card-image-placeholder {
	width: 180px;
	min-width: 180px;
	height: auto;
	min-height: 180px;
}

.pms-layout-split .pms-card-body {
	padding: 16px 20px;
}

.pms-layout-split .pms-card-title {
	font-size: 17px;
}

.pms-layout-split .pms-card-code {
	margin-bottom: 10px;
}

.pms-layout-split .pms-view-toggle {
	display: none !important;
}

.pms-layout-split .pms-results-count {
	padding: 8px 20px 0;
}

/* ---- Filter Bar ---- */
.pms-filter-bar {
	display: flex;
	justify-content: center;
	padding: 12px 0;
	border-bottom: 2px solid var(--pms-border);
	margin-bottom: 0;
}

.pms-layout-toggle .pms-filter-bar {
	margin-bottom: 20px;
}

.pms-filter-toggle {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: none;
	border: none;
	cursor: pointer;
	font-size: 16px;
	font-weight: 600;
	color: var(--pms-dark);
	padding: 8px 16px;
	transition: color 0.2s;
}

.pms-filter-toggle:hover {
	color: var(--pms-primary);
}

.pms-filter-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: var(--pms-primary);
	color: #fff;
	border-radius: 50%;
	width: 22px;
	height: 22px;
	font-size: 12px;
	font-weight: 700;
}

/* ---- Filter Panel ---- */
.pms-filter-panel {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.4);
	z-index: 99999;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding-top: 40px;
	animation: pms-fadeIn 0.2s ease;
}

.pms-filter-panel-inner {
	background: #fff;
	border-radius: 16px;
	width: 90%;
	max-width: 560px;
	max-height: 85vh;
	overflow-y: auto;
	box-shadow: 0 10px 40px rgba(0,0,0,0.2);
	animation: pms-slideUp 0.3s ease;
}

@keyframes pms-fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes pms-slideUp {
	from { transform: translateY(30px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

.pms-filter-panel-header {
	display: flex;
	align-items: center;
	padding: 16px 20px;
	border-bottom: 1px solid var(--pms-border);
	gap: 12px;
	position: sticky;
	top: 0;
	background: #fff;
	z-index: 10;
	border-radius: 16px 16px 0 0;
}

.pms-filter-close,
.pms-filter-reset {
	background: none;
	border: 1px solid var(--pms-border);
	border-radius: 50%;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	color: var(--pms-dark);
	transition: all 0.2s;
}

.pms-filter-close:hover,
.pms-filter-reset:hover {
	background: var(--pms-dark);
	color: #fff;
	border-color: var(--pms-dark);
}

.pms-filter-search-btn {
	margin-left: auto;
	background: var(--pms-primary);
	color: #fff;
	border: none;
	border-radius: 24px;
	padding: 10px 28px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.pms-filter-search-btn:hover {
	background: var(--pms-primary-hover);
}

.pms-filter-panel-body {
	padding: 20px;
	max-width: 600px;
	margin: 0 auto;
}

.pms-filter-section {
	margin-bottom: 28px;
}

.pms-filter-section h4 {
	font-size: 16px;
	font-weight: 700;
	margin: 0 0 12px;
	color: var(--pms-dark);
}

.pms-filter-input {
	width: 100%;
	padding: 12px 16px;
	border: 1px solid var(--pms-border);
	border-radius: 8px;
	font-size: 15px;
	outline: none;
	transition: border-color 0.2s;
	box-sizing: border-box;
}

.pms-filter-input:focus {
	border-color: var(--pms-primary);
}

.pms-filter-options {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.pms-filter-option {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-size: 15px;
	color: var(--pms-body-text);
	padding: 6px 0;
}

.pms-filter-option input[type="checkbox"],
.pms-filter-option input[type="radio"] {
	width: 20px;
	height: 20px;
	accent-color: var(--pms-primary);
	cursor: pointer;
}

.pms-filter-select {
	width: 100%;
	padding: 10px 14px;
	border: 1px solid var(--pms-border);
	border-radius: 8px;
	font-size: 15px;
	background: #fff;
	cursor: pointer;
}

/* ---- Results Count ---- */
.pms-results-count {
	font-size: 14px;
	color: var(--pms-card-meta);
	padding: 0 0 16px;
}

/* ---- View Toggle (toggle mode only) ---- */
.pms-view-toggle {
	position: fixed;
	bottom: 30px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 9999;
}

.pms-view-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	background: var(--pms-dark);
	color: #fff;
	border: none;
	border-radius: 30px;
	padding: 12px 24px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 20px rgba(0,0,0,0.3);
	transition: background 0.2s, transform 0.2s;
}

.pms-view-btn:hover {
	background: var(--pms-darker);
	transform: scale(1.03);
}

/* ---- Projects Grid (List/Toggle View) ---- */
.pms-layout-toggle .pms-projects-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
	gap: 24px;
}

/* ---- Project Card ---- */
.pms-project-card {
	background: var(--pms-card-bg);
	border-radius: var(--pms-radius);
	overflow: hidden;
	transition: transform 0.2s, box-shadow 0.2s;
	display: flex;
	flex-direction: column;
}

.pms-project-card:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.pms-card-image {
	width: 100%;
	height: 200px;
	object-fit: cover;
	display: block;
}

.pms-card-image-placeholder {
	width: 100%;
	height: 200px;
	background: var(--pms-darker);
	display: flex;
	align-items: center;
	justify-content: center;
}

.pms-card-image-placeholder svg {
	opacity: 0.3;
}

.pms-card-body {
	padding: 24px;
	flex: 1;
	display: flex;
	flex-direction: column;
}

.pms-card-title {
	font-size: 20px;
	font-weight: 700;
	color: var(--pms-card-text);
	margin: 0 0 6px;
	line-height: 1.3;
}

.pms-card-code {
	font-size: 13px;
	color: var(--pms-card-meta);
	margin: 0 0 16px;
}

.pms-card-meta {
	list-style: none;
	padding: 0;
	margin: 0 0 16px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.pms-card-meta li {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 14px;
	color: var(--pms-card-text);
}

.pms-card-meta li svg {
	flex-shrink: 0;
	color: var(--pms-primary);
}

.pms-card-link {
	margin-top: auto;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--pms-primary);
	text-decoration: none;
	font-weight: 600;
	font-size: 14px;
	transition: gap 0.2s;
}

.pms-card-link:hover {
	gap: 10px;
}

/* ---- Map View ---- */
.pms-map-view {
	border-radius: var(--pms-radius);
	overflow: hidden;
	box-shadow: var(--pms-shadow);
}

.pms-map {
	height: 600px;
	width: 100%;
}

.pms-map .leaflet-popup-content-wrapper {
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.pms-map .leaflet-popup-content {
	margin: 0;
	min-width: 200px;
}

.pms-map-popup {
	padding: 12px;
}

.pms-map-popup h4 {
	margin: 0 0 4px;
	font-size: 15px;
	font-weight: 700;
	color: var(--pms-dark);
}

.pms-map-popup .pms-popup-code {
	font-size: 12px;
	color: #999;
	margin: 0 0 8px;
}

.pms-map-popup .pms-popup-meta {
	font-size: 13px;
	color: #666;
	margin: 0 0 10px;
	line-height: 1.5;
}

.pms-map-popup .pms-popup-link {
	display: inline-block;
	color: var(--pms-primary);
	font-weight: 600;
	font-size: 13px;
	text-decoration: none;
}

.pms-map-popup .pms-popup-link:hover {
	text-decoration: underline;
}

/* ---- Load More ---- */
.pms-load-more-wrap {
	text-align: center;
	padding: 30px 0;
}

.pms-load-more {
	background: var(--pms-dark);
	color: #fff;
	border: none;
	border-radius: 8px;
	padding: 12px 32px;
	font-size: 15px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.2s;
}

.pms-load-more:hover {
	background: var(--pms-primary);
}

.pms-load-more:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

/* ---- No Results ---- */
.pms-no-results {
	text-align: center;
	padding: 60px 20px;
	color: var(--pms-card-meta);
}

.pms-no-results p {
	font-size: 18px;
	margin: 0 0 12px;
}

.pms-reset-link {
	background: none;
	border: none;
	color: var(--pms-primary);
	font-size: 15px;
	cursor: pointer;
	text-decoration: underline;
}

/* ---- Loading ---- */
.pms-loading {
	display: flex;
	justify-content: center;
	padding: 40px;
}

.pms-spinner {
	width: 36px;
	height: 36px;
	border: 3px solid var(--pms-border);
	border-top-color: var(--pms-primary);
	border-radius: 50%;
	animation: pms-spin 0.8s linear infinite;
}

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

/* ---- Custom Map Marker ---- */
.pms-marker-icon {
	background: #fff;
	border-radius: 50%;
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 2px 8px rgba(0,0,0,0.2);
	border: 2px solid #fff;
	overflow: hidden;
}

.pms-marker-icon img {
	width: 28px;
	height: 28px;
	object-fit: contain;
}

.pms-marker-icon svg {
	width: 20px;
	height: 20px;
	color: var(--pms-primary);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
	.pms-layout-toggle .pms-projects-grid {
		grid-template-columns: 1fr;
		gap: 16px;
	}

	.pms-layout-toggle .pms-map {
		height: 450px;
	}

	.pms-layout-toggle .pms-card-body {
		padding: 18px;
	}

	.pms-layout-toggle .pms-card-title {
		font-size: 17px;
	}

	/* Split becomes stacked on mobile */
	.pms-layout-split .pms-content {
		flex-direction: column;
	}

	.pms-layout-split .pms-list-view {
		width: 100%;
		max-height: none;
		overflow-y: visible;
		padding: 16px;
	}

	.pms-layout-split .pms-map-view {
		width: 100%;
		position: relative;
		height: 400px;
		order: -1;
	}

	.pms-layout-split .pms-project-card {
		flex-direction: column;
	}

	.pms-layout-split .pms-card-image,
	.pms-layout-split .pms-card-image-placeholder {
		width: 100%;
		min-width: 0;
		height: 180px;
		min-height: 0;
	}

	.pms-filter-panel {
		padding-top: 0;
		background: #fff;
	}

	.pms-filter-panel-inner {
		border-radius: 0;
		width: 100%;
		max-width: 100%;
		max-height: 100%;
		box-shadow: none;
	}

	.pms-filter-panel-header {
		border-radius: 0;
	}
}

/* ---- Blocksy Compatibility ---- */
[data-theme="dark"] .pms-filter-panel-inner,
.ct-dark-mode .pms-filter-panel-inner {
	background: #1a1a2e;
}

[data-theme="dark"] .pms-filter-panel-header,
.ct-dark-mode .pms-filter-panel-header {
	background: #1a1a2e;
	border-color: #2d2d44;
}

[data-theme="dark"] .pms-filter-input,
[data-theme="dark"] .pms-filter-select,
.ct-dark-mode .pms-filter-input,
.ct-dark-mode .pms-filter-select {
	background: #2d2d44;
	border-color: #3d3d55;
	color: #fff;
}

[data-theme="dark"] .pms-filter-section h4,
.ct-dark-mode .pms-filter-section h4 {
	color: #fff;
}

[data-theme="dark"] .pms-filter-option,
.ct-dark-mode .pms-filter-option {
	color: #ccc;
}

/* Cluster marker styles — !important needed to override MarkerCluster.Default.css from CDN */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
	background-color: rgba(75, 190, 106, 0.3) !important;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
	background-color: var(--pms-primary) !important;
	color: #fff !important;
	font-weight: 700;
}
