:root {
	--forest: #1b4332;
	--green: #2d6a4f;
	--bg-gray: #f4f4f6;
}

html, body {
	height: 100%;
	min-height: 100vh;
	margin: 0;
	padding: 0;
	font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
	display: flex;
	flex-direction: column;

	/* ✅ FIX: evita problemi su mobile */
	overflow-x: hidden;
}

/* HEADER */
header {
	background: linear-gradient(135deg, var(--forest), var(--green));
	color: #fff;

	/* ✅ padding fluido */
	padding: 1px 2vw;

	box-shadow: 0 4px 10px rgba(0,0,0,0.1);
	z-index: 1000;
	flex-shrink: 0;

	display: flex;
	justify-content: space-between;
	/* align-items: center; */
	align-items: flex-start;

	height: auto; /* ✅ niente altezza fissa */
	min-height: 40px;
}

/* Testi */
.header-text {
	display: flex;
	flex-direction: column;
}

/* Logo responsive */
.header-logo img {
	height: clamp(50px, 6vw, 65px); /* ✅ adattivo */
	width: auto;
	flex-shrink: 0;
	display: flex;
	align-items: flex-start
}

/* Typography adattiva */
header h1 {
	margin: 5px 0 0 0;
	font-size: clamp(18px, 2.5vw, 24px);
	font-weight: 500;
	opacity: 0.85;
	letter-spacing: 0.5px;
	line-height: 1.1;
}

header h2 {
	margin: 6px 0 3px 0;
	font-size: clamp(10px, 1.7vw, 12px);
	font-weight: 300;
	opacity: 0.85;
	text-transform: uppercase;
	letter-spacing: 1px;
	line-height: 1;
}

/* MAIN */
main {
	flex: 1;
	position: relative;
	width: 100%;
	background-color: var(--bg-gray);
}

#map {
	width: 100%;
	height: 100%;
	position: absolute;
	inset: 0;
}

/* Popup */  
.popup-content {
	max-width: 250px;
	min-width: 0;
	word-wrap: break-word;
	overflow-wrap: break-word;
	word-break: break-word;
}

.popup-content a {
	word-break: break-all;
}
/* remove popup bottom tip */
.float-popup .leaflet-popup-tip-container {
    display: none !important;
}

/* Home button */
.leaflet-control-home {
	background-color: #fff;
	width: 30px;
	height: 30px;
	border-radius: 4px;
	border: 2px solid rgba(0,0,0,0.2);

	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;

	font-size: 18px;
	font-weight: bold;
	color: #333;
	box-shadow: 0 1px 5px rgba(0,0,0,0.65);
}

.leaflet-control-home:hover {
	background-color: #f4f4f4;
	color: #000;
}

/* filters panel */
.filter-item {
	display: grid;
	/*grid-template-columns: 80px auto;*/
	grid-template-columns: 80px minmax(0, 150px);
	align-items: center;
	gap: 10px;
	margin-bottom: 10px;
}

.filter-item label {
	text-align: left;
	padding-right: 8px;
}

.filter-item select {
	width: 100%;
	white-space: nowrap;       /* Impedisce al testo di andare a capo */
	overflow: hidden;          /* Nasconde il testo in eccesso */
	text-overflow: ellipsis;   /* Aggiunge i tre puntini (...) */
}		

.filter-buttons {
	display: flex;
	grid-template-columns: 80px auto;
	align-items: center;
	gap: 10px;
	margin-bottom: 5px;
}

.filter-buttons p {
	margin: 0; 
	margin-left: 15px;
	font-size: 85%;
}

/* Legenda */
.leaflet-control.info.legend {
	background: #e5e5f5;
	padding: 12px 16px;
	font-size: 12px;
	line-height: 18px;

	box-shadow: 4px 4px 8px rgba(0,0,0,0.35);
	border-radius: 8px;
	color: #333;
	box-sizing: border-box;     /* Include padding e border nel calcolo della larghezza (220px totali) */
	
	/*max-width: min(250px, 80vw);*/
	width: 270px;               /* Forza tutti i controlli ad avere esattamente questa larghezza in condizione 'espansa'; modificare all'occorrenza*/
	max-width: calc(100vw - 40px); /* Evita che il controllo esca dallo schermo su dispositivi molto piccoli */	
	
	
	max-height: 420px;
	overflow-y: auto;
	transition: none; 
	/*transition: width 0.3s ease;*/
	/*transition: all 0.1s ease;*/
	/*transition: width 0.3s ease, max-height 0.03s ease, padding 0.03s ease;*/
}

.info.legend h4 {
	margin: 0 0 8px 0;
	font-size: 13px;
	font-weight: 600;
	border-bottom: 1px solid #ddd;
	padding-bottom: 4px;
}

.legend-item {
	display: flex;
	align-items: center;
	margin-bottom: 4px;
}

.legend-toggle {
	cursor: pointer;
	font-weight: 600;
	padding: 4px 0;		

	/* Se il testo supera la larghezza fissa, mostra i tre puntini (...) */
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;	
}

.leaflet-control.info.legend.legend-collapsed {
	width: 100px !important; /*larghezza del blocco 'collapsed' */
	padding-top: 5px;
	max-height: 35px !important; /* Sicurezza per bloccare l'altezza da chiuso se necessario */
	overflow: hidden;	
}

.legend-collapsed .legend-content {
	display: none;
	max-height: 0;
}

.legend-color {
	width: 14px;
	height: 14px;
	border-radius: 3px;
	margin-right: 8px;
	flex-shrink: 0;
	border: 1px solid rgba(0,0,0,0.2);
}

/* Marker SVG */
.custom-svg-marker {
	background: none;
	border: none;
}

.custom-svg-marker svg {
	/* to slightly modify marker dimensions on map zoom */ /* marker-scale is updated in updateMarkerScale() */	
    transform-origin: center center;
	transform-box: fill-box;
	scale: var(--marker-scale, 1);
	transition: scale 0.1s ease-out;
}

/* FOOTER */
footer {			
	background: linear-gradient(135deg, var(--forest), var(--green));
	color: #fff;

	/* ✅ padding fluido */
	padding: 10px 2vw;

	font-size: clamp(11px, 1.5vw, 13px);
	text-align: center;
	z-index: 1000;
	flex-shrink: 0;
}

footer p {
	margin: 0;
	opacity: 0.85;
}

footer p.destra {
	padding: 0;
	text-align: right;		  	  
}

/* ✅ MEDIA QUERY MOBILE */
@media (max-width: 600px) {
	header {
		flex-direction: row;
		align-items: flex-start;
	}

	.header-logo {
		align-self: flex-end;
		flex-shrink: 0;
	}

	.header-text {
		flex: 1;
		min-width: 0;
		max-width: 70%;
	}
}
