/**
 * SVG Interactive Maps Buleboo — Estilos del frontend
 *
 * @package SVG_Interactive_Maps
 */

.svgim-map-container {
	position: relative;
	width: 100%;
	height: 80vh;
	/* Nunca más alto que el 80% del viewport. */
	overflow: hidden;
	border-radius: 6px;
	background: #f7f7f7;
	width: 100vw;
	margin: 0 !important;
	max-width: 100%;
	/* Aspect ratio del shortcode (viewBox o 4:3) cuando no hay height fijo. */
	aspect-ratio: var( --svgim-aspect, var( --svgim-vb-aspect, 4 / 3 ) );
}

.svgim-map-container .svgim-map-canvas {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.svgim-map-container .leaflet-container {
	background: #f7f7f7;
	font: inherit;
}

/* ------------------------------------------------------------------
 * Controles: zoom (+/−) y descarga
 * ---------------------------------------------------------------- */

.svgim-controls {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 4px;
}

/* Disposición configurable de los botones de zoom. */
.svgim-controls-vertical {
	flex-direction: column;
}

.svgim-controls-horizontal {
	flex-direction: row;
}

.svgim-ctl-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 2px solid rgba(0, 0, 0, 0.25);
	border-radius: 6px;
	background: #fff;
	color: #1d2327;
	font-size: 19px;
	font-weight: 700;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
	text-decoration: none;
	transition: background 0.15s ease, color 0.15s ease;
}

.svgim-ctl-btn:hover,
.svgim-ctl-btn:focus-visible {
	background: #1d2327;
	color: #fff;
}

.svgim-ctl-btn:disabled {
	opacity: 0.45;
	cursor: default;
	background: #fff;
	color: #1d2327;
}

.svgim-ctl-btn svg {
	display: block;
}

/* ------------------------------------------------------------------
 * Markers
 * ---------------------------------------------------------------- */

.svgim-marker-wrap {
	background: none;
	border: none;
}

.svgim-marker {
	display: block;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 3px solid #fff;
	border-radius: 50% 50% 50% 0;
	transform: rotate(-45deg);
	box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
	cursor: pointer;
	transition: transform 0.15s ease;
}

.svgim-marker:hover,
.svgim-marker:focus-visible {
	transform: rotate(-45deg) scale(1.15);
}

/* Anillo de foco accesible (contraste AA sobre fondos claros y oscuros). */
.svgim-marker:focus-visible {
	outline: 3px solid #1a5fb4;
	outline-offset: 3px;
}

/* ------------------------------------------------------------------
 * Popups y tooltips
 * ---------------------------------------------------------------- */

.svgim-popup .leaflet-popup-content-wrapper {
	border-radius: 8px;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.svgim-popup .leaflet-popup-content {
	margin: 14px 18px;
	line-height: 1.55;
	color: #1d2327;
}

.svgim-content-title {
	margin: 0 0 6px;
	font-size: 16px;
	line-height: 1.3;
	color: #1d2327;
}

.svgim-tooltip .leaflet-tooltip-content {
	color: #1d2327;
	line-height: 1.5;
}

/* ------------------------------------------------------------------
 * Panel lateral deslizante
 * ---------------------------------------------------------------- */

.svgim-info-panel {
	position: absolute;
	z-index: 800;
	top: 0;
	right: 0;
	bottom: 0;
	width: min(340px, 85%);
	display: flex;
	flex-direction: column;
	background: #fff;
	box-shadow: -6px 0 24px rgba(0, 0, 0, 0.2);
	transform: translateX(100%);
	transition: transform 0.25s ease;
	border-radius: 8px 0 0 8px;
}

.svgim-info-panel[hidden] {
	display: none;
}

.svgim-info-panel.svgim-panel-open {
	transform: translateX(0);
}

/* Handle: visible solo en móvil (bottom sheet) */
.svgim-panel-handle {
	display: none;
	width: 48px;
	height: 5px;
	margin: 8px auto 0;
	border-radius: 3px;
	background: #b8bcc2;
}

.svgim-panel-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	padding: 12px 16px;
	border-bottom: 1px solid #e2e4e7;
}

.svgim-panel-title {
	margin: 0;
	font-size: 16px;
	color: #1d2327;
}

.svgim-panel-close {
	border: 0;
	background: none;
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
	color: #3c434a;
	padding: 4px 8px;
}

.svgim-panel-close:hover,
.svgim-panel-close:focus-visible {
	color: #d63638;
}

.svgim-panel-body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px 16px;
	line-height: 1.6;
	color: #2c3338;
}

/* ------------------------------------------------------------------
 * Toasts
 * ---------------------------------------------------------------- */

.svgim-toasts {
	position: absolute;
	z-index: 900;
	top: 12px;
	right: 12px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	width: min(300px, 80%);
	pointer-events: none;
}

.svgim-toast {
	pointer-events: auto;
	background: #1d2327;
	color: #f0f0f1;
	border-radius: 6px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
	padding: 10px 12px;
	font-size: 13px;
	line-height: 1.5;
}

.svgim-toast-head {
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	margin-bottom: 4px;
}

.svgim-toast-head strong {
	color: #fff;
}

.svgim-toast-close {
	border: 0;
	background: none;
	color: #c3c4c7;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	padding: 2px 6px;
}

.svgim-toast-close:hover,
.svgim-toast-close:focus-visible {
	color: #fff;
}

.svgim-toast-body a {
	color: #72aee6;
}

/* ------------------------------------------------------------------
 * Regiones interactivas
 * ---------------------------------------------------------------- */

.svgim-map-container [data-svgim-region]:focus-visible {
	outline: none;
	stroke: #1a5fb4;
	stroke-width: 3px;
}

/* ------------------------------------------------------------------
 * Responsive: popup y panel se convierten en bottom sheet
 * ---------------------------------------------------------------- */

@media (max-width: 767px) {
	.svgim-info-panel {
		top: auto;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		max-height: 85%;
		height: 55%;
		border-radius: 14px 14px 0 0;
		transform: translateY(100%);
		box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
	}

	.svgim-info-panel.svgim-panel-open {
		transform: translateY(0);
	}

	.svgim-panel-handle {
		display: block;
		touch-action: none;
		cursor: grab;
	}

	.svgim-toasts {
		top: auto;
		bottom: 12px;
		left: 12px;
		right: 12px;
		width: auto;
	}

	/* El popup de Leaflet en móvil queda limitado para no tapar el mapa entero. */
	.svgim-popup .leaflet-popup-content-wrapper {
		max-height: 45vh;
		overflow-y: auto;
	}
}

/* Preferencia de movimiento reducido. */
@media (prefers-reduced-motion: reduce) {

	.svgim-info-panel,
	.svgim-marker {
		transition: none;
	}
}
/* Formas dibujadas (círculo, rectángulo, polígono): foco accesible. */
.svgim-shape {
	cursor: pointer;
}

.svgim-shape:focus {
	outline: none;
	stroke-width: 3;
}

/* Botón de pantalla completa: el contenedor ocupa toda la ventana. */
.svgim-map-container.svgim-fullscreen {
	position: fixed;
	inset: 0;
	z-index: 99999;
	width: 100vw !important;
	height: 100vh !important;
	max-width: none;
	background: #fff;
	border-radius: 0;
}

/* Fallback para navegadores sin Fullscreen API. */
.svgim-map-container.svgim-fs-fallback {
	position: fixed;
	inset: 0;
	z-index: 99999;
	width: 100vw !important;
	height: 100vh !important;
	max-width: none;
	background: #fff;
}

/* Imagen de leyenda: una esquina configurable, ancho en px (inline). */
.svgim-legend {
	position: absolute;
	z-index: 800; /* Por encima de los paneles, debajo de los controles */
	max-width: 60%;
	height: auto;
	pointer-events: none;
	user-select: none;
}

.svgim-legend-topleft {
	top: 10px;
	left: 10px;
}

.svgim-legend-topright {
	top: 10px;
	right: 10px;
}

.svgim-legend-bottomleft {
	bottom: 10px;
	left: 10px;
}

.svgim-legend-bottomright {
	bottom: 10px;
	right: 10px;
}

/* Hover de regiones y formas: puro CSS con variables (sin listeners JS). */
.svgim-region {
	fill: var(--svgim-fill, transparent);
	fill-opacity: var(--svgim-fill-opacity, 0.35);
	stroke-opacity: var(--svgim-stroke-opacity, 1);
	transition: fill .15s ease, fill-opacity .15s ease;
}

.svgim-region:hover,
.svgim-region:focus {
	fill: var(--svgim-hover-fill, var(--svgim-fill));
	fill-opacity: var(--svgim-hover-opacity, var(--svgim-fill-opacity));
}
