/**
 * WP-Cadastre Public Stylesheet
 * Premium, Modern and Responsive Design System.
 */

:root {
	--wp-cadastre-accent-hover: #1d4ed8;
	--wp-cadastre-border-radius: 12px;
	--wp-cadastre-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	--wp-cadastre-font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

/* 1. Sistemes de Temes */
.theme-glassmorphic {
	--wpc-bg: #f8fafc;
	--wpc-card-bg: rgba(255, 255, 255, 0.75);
	--wpc-card-border: rgba(226, 232, 240, 0.8);
	--wpc-text: #1e293b;
	--wpc-text-muted: #64748b;
	--wpc-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
	--wpc-blur: blur(12px);
	--wpc-badge-bg: #eff6ff;
	--wpc-badge-text: var(--wp-cadastre-accent);
}

.theme-light {
	--wpc-bg: #ffffff;
	--wpc-card-bg: #f8fafc;
	--wpc-card-border: #e2e8f0;
	--wpc-text: #0f172a;
	--wpc-text-muted: #64748b;
	--wpc-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
	--wpc-blur: none;
	--wpc-badge-bg: #f1f5f9;
	--wpc-badge-text: #334155;
}

.theme-dark {
	--wpc-bg: #0f172a;
	--wpc-card-bg: #1e293b;
	--wpc-card-border: #334155;
	--wpc-text: #f8fafc;
	--wpc-text-muted: #94a3b8;
	--wpc-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
	--wpc-blur: none;
	--wpc-badge-bg: #334155;
	--wpc-badge-text: #f8fafc;
}

/* Estils Generals del Contenidor */
.wp-cadastre-wrap {
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	color: var(--wpc-text);
	background-color: var(--wpc-bg);
	border-radius: var(--wp-cadastre-border-radius);
	padding: 20px;
	box-shadow: var(--wpc-shadow);
	margin-bottom: 30px;
	position: relative;
	transition: var(--wp-cadastre-transition);
}

/* 2. Cercador d'Adreces (Autocomplete) */
.wp-cadastre-search-bar {
	position: relative;
	margin-bottom: 20px;
	z-index: 1000;
}

.wp-cadastre-input-wrapper {
	display: flex;
	align-items: center;
	background: var(--wpc-card-bg);
	border: 1.5px solid var(--wpc-card-border);
	border-radius: var(--wp-cadastre-border-radius);
	padding: 8px 16px;
	box-shadow: var(--wpc-shadow);
	backdrop-filter: var(--wpc-blur);
	transition: var(--wp-cadastre-transition);
}

.wp-cadastre-input-wrapper:focus-within {
	border-color: var(--wp-cadastre-accent);
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.wp-cadastre-search-icon {
	font-size: 18px;
	margin-right: 12px;
	color: var(--wpc-text-muted);
}

#wp-cadastre-search-input {
	flex-grow: 1;
	border: none !important;
	outline: none !important;
	background: transparent !important;
	color: var(--wpc-text) !important;
	font-size: 16px !important;
	padding: 8px 0 !important;
	margin: 0 !important;
	box-shadow: none !important;
	width: 100%;
}

#wp-cadastre-clear-btn {
	background: none;
	border: none;
	color: var(--wpc-text-muted);
	font-size: 20px;
	cursor: pointer;
	padding: 0 8px;
	transition: var(--wp-cadastre-transition);
}

#wp-cadastre-clear-btn:hover {
	color: var(--wpc-text);
}

.wp-cadastre-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid var(--wpc-card-border);
	border-top-color: var(--wp-cadastre-accent);
	border-radius: 50%;
	animation: wpc-spin 0.8s linear infinite;
	margin-left: 8px;
}

/* Dropdown de resultats d'adreces */
.wp-cadastre-autocomplete-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: var(--wpc-card-bg);
	border: 1px solid var(--wpc-card-border);
	border-radius: var(--wp-cadastre-border-radius);
	margin-top: 8px;
	box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
	backdrop-filter: var(--wpc-blur);
	max-height: 250px;
	overflow-y: auto;
	z-index: 1001;
}

.wp-cadastre-autocomplete-item {
	padding: 12px 16px;
	cursor: pointer;
	font-size: 14px;
	border-bottom: 1px solid var(--wpc-card-border);
	transition: var(--wp-cadastre-transition);
}

.wp-cadastre-autocomplete-item:last-child {
	border-bottom: none;
}

.wp-cadastre-autocomplete-item:hover {
	background-color: var(--wpc-badge-bg);
	color: var(--wp-cadastre-accent);
}

/* 3. Cos Principal: Mapa + Barra lateral */
.wp-cadastre-main-content {
	display: flex;
	gap: 20px;
	height: 600px;
}

.wp-cadastre-map-wrapper {
	flex: 1;
	border-radius: var(--wp-cadastre-border-radius);
	overflow: hidden;
	border: 1px solid var(--wpc-card-border);
	box-shadow: var(--wpc-shadow);
	position: relative;
}

#wp-cadastre-map {
	width: 100%;
	height: 100%;
	z-index: 5;
}

/* 4. Barra lateral (Drawer) */
.wp-cadastre-drawer {
	width: 380px;
	background: var(--wpc-card-bg);
	border: 1px solid var(--wpc-card-border);
	border-radius: var(--wp-cadastre-border-radius);
	padding: 20px;
	overflow-y: auto;
	box-shadow: var(--wpc-shadow);
	backdrop-filter: var(--wpc-blur);
	display: flex;
	flex-direction: column;
	transition: var(--wp-cadastre-transition);
}

/* Estats del Drawer */
.wp-cadastre-info-helper {
	display: flex;
	flex-direction: column;
	align-items: center;
	text-align: center;
	justify-content: center;
	height: 100%;
	color: var(--wpc-text-muted);
}

.wp-cadastre-icon-large {
	font-size: 48px;
	margin-bottom: 16px;
}

.wp-cadastre-info-helper h3 {
	margin: 0 0 8px 0;
	color: var(--wpc-text);
}

.wp-cadastre-info-helper p {
	font-size: 14px;
	line-height: 1.5;
	margin: 0;
}

/* 5. Selector de Divisions */
.wp-cadastre-building-header {
	border-bottom: 1px solid var(--wpc-card-border);
	padding-bottom: 16px;
	margin-bottom: 16px;
}

.wp-cadastre-building-header h3 {
	margin: 0 0 8px 0;
	font-size: 18px;
	line-height: 1.3;
}

.wp-cadastre-b-meta {
	font-size: 12px;
	color: var(--wpc-text-muted);
}

.wp-cadastre-divisions-section h4 {
	margin: 0 0 8px 0;
	font-size: 14px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: var(--wpc-text-muted);
}

.wp-cadastre-helper-text {
	font-size: 13px;
	color: var(--wpc-text-muted);
	margin-top: 0;
	margin-bottom: 12px;
}

.wp-cadastre-divisions-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 8px;
	margin-bottom: 24px;
}

.wp-cadastre-div-btn {
	background: var(--wpc-bg);
	border: 1px solid var(--wpc-card-border);
	border-radius: 8px;
	padding: 10px 8px;
	font-size: 12px;
	font-weight: 500;
	text-align: center;
	cursor: pointer;
	color: var(--wpc-text);
	transition: var(--wp-cadastre-transition);
}

.wp-cadastre-div-btn:hover {
	border-color: var(--wp-cadastre-accent);
	background-color: var(--wpc-badge-bg);
	color: var(--wp-cadastre-accent);
}

.wp-cadastre-div-btn.active {
	background-color: var(--wp-cadastre-accent);
	border-color: var(--wp-cadastre-accent);
	color: #ffffff;
}

/* 6. Fitxa de Detalls de la Unitat */
.wp-cadastre-unit-details-card {
	animation: wpc-fade-in 0.4s ease-out;
}

.wp-cadastre-details-header h4 {
	margin: 16px 0 12px 0;
	font-size: 16px;
	border-left: 4px solid var(--wp-cadastre-accent);
	padding-left: 8px;
}

.wp-cadastre-details-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
	margin-bottom: 20px;
}

.wp-cadastre-detail-item {
	background: var(--wpc-bg);
	border: 1px solid var(--wpc-card-border);
	padding: 12px;
	border-radius: 8px;
	display: flex;
	flex-direction: column;
}

.wp-cadastre-detail-item .label {
	font-size: 11px;
	color: var(--wpc-text-muted);
	text-transform: uppercase;
	margin-bottom: 4px;
}

.wp-cadastre-detail-item .value {
	font-size: 14px;
	font-weight: 600;
}

.wp-cadastre-detail-item .value.mono {
	font-family: var(--wp-cadastre-font-mono);
	font-size: 11px;
	letter-spacing: -0.2px;
	word-break: break-all;
}

/* Copiar Referència */
.wp-cadastre-copy-wrapper {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 6px;
}

.wp-cadastre-copy-btn {
	background: none;
	border: none;
	cursor: pointer;
	font-size: 14px;
	padding: 2px 4px;
	border-radius: 4px;
	transition: var(--wp-cadastre-transition);
}

.wp-cadastre-copy-btn:hover {
	background-color: var(--wpc-card-border);
}

.wp-cadastre-copy-btn:active {
	transform: scale(0.9);
}

/* Imatge de Street View */
.wp-cadastre-streetview-box {
	border-radius: var(--wp-cadastre-border-radius);
	overflow: hidden;
	height: 180px;
	background: #cbd5e1;
	border: 1px solid var(--wpc-card-border);
	margin-bottom: 16px;
	position: relative;
}

.wp-cadastre-streetview-box iframe {
	width: 100%;
	height: 100%;
	border: none;
}

.wp-cadastre-streetview-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	height: 100%;
	text-align: center;
	padding: 20px;
	background: linear-gradient(135deg, #475569 0%, #1e293b 100%);
	color: #ffffff;
}

.wp-cadastre-streetview-placeholder h5 {
	margin: 0 0 6px 0;
	font-size: 14px;
}

.wp-cadastre-streetview-placeholder p {
	margin: 0 0 12px 0;
	font-size: 11px;
	color: #94a3b8;
}

/* Botó extern de street view */
.wp-cadastre-btn-sm {
	background-color: #ffffff;
	color: #0f172a;
	border: none;
	border-radius: 6px;
	padding: 6px 12px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
	transition: var(--wp-cadastre-transition);
}

.wp-cadastre-btn-sm:hover {
	background-color: #f1f5f9;
	transform: translateY(-1px);
}

/* Elements Constructius */
.wp-cadastre-components-section h5 {
	margin: 16px 0 8px 0;
	font-size: 13px;
	text-transform: uppercase;
	color: var(--wpc-text-muted);
}

.wp-cadastre-components-list {
	list-style: none;
	padding: 0;
	margin: 0 0 20px 0;
}

.wp-cadastre-components-list li {
	display: flex;
	justify-content: space-between;
	padding: 6px 0;
	border-bottom: 1px dashed var(--wpc-card-border);
	font-size: 13px;
}

.wp-cadastre-components-list li span.use {
	font-weight: 500;
}

.wp-cadastre-components-list li span.surface {
	font-family: var(--wp-cadastre-font-mono);
	color: var(--wpc-text-muted);
}

/* 7. Targeta Premium (Upsell) */
.wp-cadastre-premium-upsell {
	margin-top: 24px;
	background: linear-gradient(135deg, rgba(239, 246, 255, 0.8) 0%, rgba(219, 234, 254, 0.8) 100%);
	border: 1.5px solid #93c5fd;
	border-radius: var(--wp-cadastre-border-radius);
	padding: 20px;
	text-align: center;
	position: relative;
	box-shadow: 0 4px 20px rgba(37, 99, 235, 0.06);
	backdrop-filter: var(--wpc-blur);
}

.theme-dark .wp-cadastre-premium-upsell {
	background: linear-gradient(135deg, #1e293b 0%, #1e1b4b 100%);
	border-color: #3b82f6;
}

.wp-cadastre-premium-badge {
	position: absolute;
	top: -12px;
	left: 50%;
	transform: translateX(-50%);
	background: var(--wp-cadastre-accent);
	color: #ffffff;
	font-size: 10px;
	font-weight: 700;
	padding: 4px 12px;
	border-radius: 9999px;
	letter-spacing: 1px;
}

.wp-cadastre-premium-upsell h4 {
	margin: 8px 0 10px 0;
	font-size: 16px;
	color: #1e3a8a;
}

.theme-dark .wp-cadastre-premium-upsell h4 {
	color: #93c5fd;
}

.wp-cadastre-premium-upsell p {
	font-size: 13px;
	line-height: 1.4;
	margin: 0 0 12px 0;
	color: #1e40af;
}

.theme-dark .wp-cadastre-premium-upsell p {
	color: #94a3b8;
}

.wp-cadastre-premium-upsell ul {
	text-align: left;
	padding: 0;
	margin: 0 0 16px 12px;
	list-style: none;
}

.wp-cadastre-premium-upsell li {
	font-size: 12.5px;
	margin-bottom: 6px;
	color: #1e3a8a;
}

.theme-dark .wp-cadastre-premium-upsell li {
	color: #cbd5e1;
}

.wp-cadastre-upsell-price {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	margin-bottom: 16px;
}

.wp-cadastre-upsell-price .old-price {
	font-size: 14px;
	text-decoration: line-through;
	color: #93c5fd;
}

.theme-dark .wp-cadastre-upsell-price .old-price {
	color: #64748b;
}

.wp-cadastre-upsell-price .new-price {
	font-size: 22px;
	font-weight: 800;
	color: #1d4ed8;
}

.theme-dark .wp-cadastre-upsell-price .new-price {
	color: #60a5fa;
}

.wp-cadastre-btn {
	width: 100%;
	padding: 12px 20px;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: var(--wp-cadastre-transition);
}

.wp-cadastre-btn-premium {
	background-color: var(--wp-cadastre-accent);
	color: #ffffff;
	box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.wp-cadastre-btn-premium:hover {
	background-color: var(--wp-cadastre-accent-hover);
	transform: translateY(-1px);
	box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
}

.wp-cadastre-secure-badge {
	display: block;
	font-size: 11px;
	color: #2563eb;
	margin-top: 10px;
}

.theme-dark .wp-cadastre-secure-badge {
	color: #60a5fa;
}

/* 8. Estats de Càrrega (Skeleton Skeletons) */
.wp-cadastre-skeleton-header {
	height: 24px;
	background: var(--wpc-card-border);
	margin-bottom: 12px;
	border-radius: 4px;
	animation: wpc-pulse 1.5s infinite ease-in-out;
}

.wp-cadastre-skeleton-text {
	height: 14px;
	background: var(--wpc-card-border);
	margin-bottom: 8px;
	border-radius: 4px;
	animation: wpc-pulse 1.5s infinite ease-in-out;
}

.wp-cadastre-skeleton-text.short {
	width: 60%;
}

.wp-cadastre-skeleton-media {
	height: 140px;
	background: var(--wpc-card-border);
	margin: 16px 0;
	border-radius: 8px;
	animation: wpc-pulse 1.5s infinite ease-in-out;
}

.wp-cadastre-skeleton-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 12px;
}

.wp-cadastre-skeleton-grid div {
	height: 48px;
	background: var(--wpc-card-border);
	border-radius: 8px;
	animation: wpc-pulse 1.5s infinite ease-in-out;
}

/* 9. Animacions */
@keyframes wpc-spin {
	to { transform: rotate(360deg); }
}

@keyframes wpc-pulse {
	0% { opacity: 0.6; }
	50% { opacity: 1; }
	100% { opacity: 0.6; }
}

@keyframes wpc-fade-in {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

/* 10. Disseny Responsive */
@media (max-width: 768px) {
	.wp-cadastre-main-content {
		flex-direction: column;
		height: auto;
	}

	.wp-cadastre-map-wrapper {
		height: 350px;
		width: 100%;
	}

	.wp-cadastre-drawer {
		width: 100%;
		height: auto;
		max-height: 500px;
		box-sizing: border-box;
	}
	
	.wp-cadastre-divisions-grid {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
	}
}
