/**
 * Mattis Property Map Styles
 *
 * @package MattisPropertySearch
 * @version 1.0.0
 */

/* Contenedor del mapa - Para layout de columnas */
#mps-map-container {
	width: 100%;
	height: 100%;
	min-height: 700px;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transition: opacity 0.3s ease, visibility 0.3s ease;
	background: white;
	position: relative;
}

/* Estado oculto del mapa */
#mps-map-container.is-hidden {
	display: none !important;
	opacity: 0 !important;
	visibility: hidden !important;
}

/* Cuando el mapa está dentro de una columna de Elementor */
.mps-map-column #mps-map-container {
	height: 100%;
	min-height: 700px;
}

/* El div interno de Google Maps */
#mps-google-map {
	width: 100%;
	height: 100%;
	min-height: 700px;
}

/* Contenedor sticky para que el mapa se mantenga visible al hacer scroll */
.mps-map-column {
	position: sticky;
	top: 100px;
	align-self: flex-start;
	height: fit-content;
	max-height: calc(100vh - 120px);
}

/* Columna del mapa cuando está visible */
.elementor-column.mps-detected-map-column:not(.is-hidden) {
	width: 50% !important;
	flex: 0 0 50% !important;
}

/* Asegurar que la columna de propiedades se ajuste cuando el mapa está visible */
.mps-detected-map-column:not(.is-hidden) ~ .elementor-column {
	width: 50% !important;
	flex: 0 0 50% !important;
}

/* Info Window personalizado */
.mps-map-infowindow {
	max-width: 280px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
		'Helvetica Neue', Arial, sans-serif;
}

.mps-map-infowindow img {
	border-radius: 8px;
	margin-bottom: 10px;
}

.mps-map-infowindow h3 {
	margin: 0 0 8px 0;
	font-size: 16px;
	font-weight: 600;
	color: #1a1a1a;
	line-height: 1.4;
}

.mps-map-infowindow a {
	display: inline-block;
	background: #db7e2b;
	color: white;
	padding: 8px 16px;
	border-radius: 6px;
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
	transition: background 0.2s ease;
}

.mps-map-infowindow a:hover {
	background: #15803d;
}

/* Ajustes para Google Maps controles */
.gm-style .gm-style-iw-c {
	padding: 12px !important;
	border-radius: 8px !important;
}

.gm-style .gm-style-iw-d {
	overflow: auto !important;
}

.gm-style-iw button {
	top: 8px !important;
	right: 8px !important;
}

/* Responsive */
@media (max-width: 1024px) {
	/* En tablets, quitar sticky y ajustar altura */
	.mps-map-column {
		position: relative;
		top: auto;
	}

	#mps-map-container,
	#mps-google-map {
		min-height: 500px;
	}
}

@media (max-width: 768px) {
	#mps-map-container,
	#mps-google-map {
		min-height: 400px;
	}

	.mps-map-infowindow {
		max-width: 240px;
	}

	.mps-map-infowindow h3 {
		font-size: 14px;
	}

	.mps-map-infowindow a {
		padding: 6px 12px;
		font-size: 13px;
	}
}

/* Loading state */
#mps-map-container.is-loading::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 40px;
	height: 40px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #db7e2b;
	border-radius: 50%;
	animation: spin 1s linear infinite;
	z-index: 1000;
}

@keyframes spin {
	0% {
		transform: translate(-50%, -50%) rotate(0deg);
	}
	100% {
		transform: translate(-50%, -50%) rotate(360deg);
	}
}

/* ========================================
   ESTILOS PARA SHORTCODE [mps_property_map]
   ======================================== */

/* Contenedor principal del shortcode */
.mps-property-map-container {
	position: relative;
	width: 100%;
	margin: 20px 0;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Mensaje de error (Sin API Key) */
.mps-map-error {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	padding: 60px 40px;
	border-radius: 12px;
	text-align: center;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.mps-map-error__icon {
	font-size: 64px;
	margin-bottom: 20px;
	animation: bounce 2s infinite;
}

@keyframes bounce {
	0%,
	100% {
		transform: translateY(0);
	}
	50% {
		transform: translateY(-10px);
	}
}

.mps-map-error__title {
	font-size: 24px;
	font-weight: 600;
	margin: 0 0 15px 0;
}

.mps-map-error__message {
	font-size: 16px;
	line-height: 1.6;
	margin: 0 0 30px 0;
	opacity: 0.95;
}

.mps-map-error__button {
	display: inline-block;
	background: white;
	color: #667eea;
	padding: 12px 30px;
	border-radius: 8px;
	text-decoration: none;
	font-weight: 600;
	transition: all 0.3s ease;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.mps-map-error__button:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Barra de filtros */
.mps-map-filters {
	background: white;
	padding: 20px;
	border-radius: 12px 12px 0 0;
	border: 1px solid #e5e7eb;
	border-bottom: none;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.mps-map-filters__row {
	display: flex;
	gap: 15px;
	align-items: center;
	flex-wrap: wrap;
}

.mps-map-search {
	flex: 1;
	min-width: 250px;
	display: flex;
	gap: 10px;
}

.mps-map-search__input {
	flex: 1;
	padding: 12px 16px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	font-size: 14px;
	transition: border-color 0.3s ease;
}

.mps-map-search__input:focus {
	outline: none;
	border-color: #db7e2b;
}

.mps-map-search__button {
	padding: 12px 20px;
	background: #db7e2b;
	color: white;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	transition: background 0.3s ease;
}

.mps-map-search__button:hover {
	background: #15803d;
}

.mps-map-search__button .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

.mps-map-quick-filters {
	display: flex;
	gap: 10px;
	align-items: center;
	flex-wrap: wrap;
}

.mps-map-filter {
	padding: 12px 16px;
	border: 2px solid #e5e7eb;
	border-radius: 8px;
	font-size: 14px;
	background: white;
	cursor: pointer;
	transition: border-color 0.3s ease;
	min-width: 150px;
}

.mps-map-filter:focus {
	outline: none;
	border-color: #db7e2b;
}

.mps-map-filter-apply,
.mps-map-filter-clear {
	padding: 12px 24px;
	border: none;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
}

.mps-map-filter-apply {
	background: #db7e2b;
	color: white;
}

.mps-map-filter-apply:hover {
	background: #15803d;
}

.mps-map-filter-clear {
	background: #ef4444;
	color: white;
}

.mps-map-filter-clear:hover {
	background: #dc2626;
}

/* Contenedor del mapa (shortcode) */
.mps-map-wrapper {
	position: relative;
	width: 100%;
	border: 1px solid #e5e7eb;
	border-radius: 0 0 12px 12px;
	overflow: hidden;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.mps-map-filters + .mps-map-wrapper {
	border-radius: 0 0 12px 12px;
}

#mps-google-map-container {
	position: relative;
}

/* Indicador de carga */
.mps-map-loading {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	background: white;
	padding: 30px 40px;
	border-radius: 12px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
	text-align: center;
	z-index: 1000;
}

.mps-map-loading__spinner {
	width: 40px;
	height: 40px;
	margin: 0 auto 15px;
	border: 4px solid #f3f4f6;
	border-top-color: #db7e2b;
	border-radius: 50%;
	animation: spin-loader 1s linear infinite;
}

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

.mps-map-loading__text {
	margin: 0;
	font-size: 14px;
	color: #6b7280;
	font-weight: 500;
}

/* Contador de propiedades */
.mps-map-counter {
	position: absolute;
	top: 20px;
	left: 50%;
	transform: translateX(-50%);
	background: white;
	padding: 12px 24px;
	border-radius: 50px;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
	display: flex;
	align-items: center;
	gap: 10px;
	z-index: 100;
	font-size: 14px;
	font-weight: 500;
}

.mps-map-counter__icon {
	font-size: 18px;
}

.mps-map-counter__text {
	color: #374151;
}

#mps-map-counter-number {
	color: #db7e2b;
	font-weight: 700;
}

/* Botón de geolocalización */
.mps-map-geolocate {
	position: absolute;
	bottom: 120px;
	right: 20px;
	width: 48px;
	height: 48px;
	background: white;
	border: none;
	border-radius: 50%;
	box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s ease;
	z-index: 100;
}

.mps-map-geolocate:hover {
	background: #db7e2b;
	color: white;
	transform: scale(1.1);
}

.mps-map-geolocate .dashicons {
	font-size: 24px;
	width: 24px;
	height: 24px;
}

.mps-map-geolocate:hover .dashicons {
	color: white;
}

/* Responsive para shortcode */
@media (max-width: 768px) {
	.mps-map-filters__row {
		flex-direction: column;
		align-items: stretch;
	}

	.mps-map-search {
		min-width: 100%;
	}

	.mps-map-quick-filters {
		flex-direction: column;
		width: 100%;
	}

	.mps-map-filter {
		width: 100%;
	}

	.mps-map-counter {
		font-size: 12px;
		padding: 10px 20px;
	}

	.mps-map-geolocate {
		bottom: 80px;
		right: 10px;
	}
}
