// Questo file fa parte di MyTown.
// MyTown è software libero: puoi ridistribuirlo e/o modificarlo secondo
// i termini della GNU Affero General Public License come pubblicata dalla
// Free Software Foundation, versione 3.
// Distribuito senza ALCUNA GARANZIA; vedi la GNU AGPL v3 per i dettagli.
// Copyright (C) Kondor Consulting & Services S.r.l.
// SPDX-License-Identifier: AGPL-3.0-or-later

:host {
	display: block;
	width: 100%;
}

// ── Mappa wrapper ─────────────────────────────────────────
.mappa-wrapper {
	width: 100%;
	min-height: 300px;
	overflow: hidden;
	position: relative;
	background: #e8c87a;
	border-top: 2px solid #c8aa60;

	// L2: sfondo uguale al canvas sabbia per continuità visiva
	&.canvas-l2-bg {
		background-image: linear-gradient(180deg, #f0d878 0%, #c9a038 100%);
		background-size: 100% 100%;
	}
}

// Area scrollabile interna (separata dai controlli zoom)
.mappa-scroll {
	width: 100%;
	height: 100%;
	overflow: hidden;

	// Quando l'utente zooma > 1: abilita scroll/pan
	&.zoomed {
		overflow: auto;
		-webkit-overflow-scrolling: touch;
	}
}

// ── Controlli zoom (FAB verticale in alto a destra) ───────
.map-zoom-controls {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 50;
	display: flex;
	flex-direction: column;
	gap: 4px;
	background: rgba(255, 255, 255, 0.92);
	border-radius: 10px;
	padding: 4px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.map-zoom-btn {
	all: unset;
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: 7px;
	cursor: pointer;
	color: var(--ion-color-dark, #222);
	font-size: 11px;
	font-weight: 700;
	transition: background 0.12s;

	ion-icon { font-size: 20px; }

	&:hover  { background: rgba(0, 0, 0, 0.06); }
	&:active { background: rgba(0, 0, 0, 0.12); }

	&:disabled {
		opacity: 0.35;
		cursor: not-allowed;
	}
}

.map-zoom-level {
	font-size: 10px;
	letter-spacing: -0.3px;
}

// ── Contenitore scaled (clippa canvas in L2) ──────────────
.canvas-scaled-outer {
	overflow: hidden;
	position: relative;
	flex-shrink: 0;
}

// ── Canvas landscape 900×auto ────────────────────────────
.mappa-canvas {
	position: relative;
	box-sizing: border-box;
	overflow: hidden;
	transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);

	// L2: solo sabbia, nessun mare
	&.canvas-beach.canvas-l2 {
		background-image: linear-gradient(180deg, #f0d878 0%, #c9a038 100%);
		background-size: 100% 100%;
	}

	// Spiaggia
	&.canvas-beach {
		background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='540'%3E%3Cdefs%3E%3ClinearGradient id='sea' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23082744'/%3E%3Cstop offset='55%25' stop-color='%231a6ea8'/%3E%3Cstop offset='100%25' stop-color='%233d98cc'/%3E%3C/linearGradient%3E%3ClinearGradient id='sand' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0%25' stop-color='%23f0d878'/%3E%3Cstop offset='100%25' stop-color='%23c9a038'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='900' height='540' fill='url(%23sand)'/%3E%3Cpath d='M0,90 Q75,78 150,90 Q225,102 300,90 Q375,78 450,90 Q525,102 600,90 Q675,78 750,90 Q825,102 900,90 L900,0 L0,0 Z' fill='url(%23sea)'/%3E%3Cellipse cx='150' cy='38' rx='100' ry='3' fill='white' opacity='0.13'/%3E%3Cellipse cx='450' cy='58' rx='130' ry='3' fill='white' opacity='0.10'/%3E%3Cellipse cx='730' cy='35' rx='90' ry='3' fill='white' opacity='0.12'/%3E%3Cpath d='M0,88 Q75,80 150,88 Q225,96 300,88 Q375,80 450,88 Q525,96 600,88 Q675,80 750,88 Q825,96 900,88' stroke='rgba(255,255,255,0.35)' stroke-width='2' fill='none'/%3E%3C/svg%3E");
		background-size: 100% 100%;
		background-repeat: no-repeat;
		border-color: #2980b9;
	}

	// Ristorante: pavimento "parquet" (copiato dal portale web)
	&.canvas-restaurant {
		background-color: #c8a97a;
		background-image:
			repeating-linear-gradient(90deg, rgba(0,0,0,.04) 0px, rgba(0,0,0,.04) 1px, transparent 1px, transparent 60px),
			repeating-linear-gradient(0deg,  rgba(0,0,0,.03) 0px, rgba(0,0,0,.03) 1px, transparent 1px, transparent 20px),
			linear-gradient(160deg, #d4a96a 0%, #c49560 20%, #d8ad78 40%, #be8d58 60%, #d0a570 80%, #c4975e 100%);
		border-color: #9a6b3a;
	}

	// Generico (default, niente tipologia specifica)
	&.canvas-generic {
		background-color: #ffffff;
		background-image: radial-gradient(circle, #ccc 1px, transparent 1px);
		background-size: 20px 20px;
	}
}

// ── Muri RESTAURANT (path SVG bianco con drop-shadow) ─────
.walls-svg-ro {
	position: absolute;
	left: 0;
	top: 0;
	pointer-events: none;
	z-index: 4;
	overflow: visible;

	.wall-shape-ro {
		fill: none;
		stroke: #fff;
		stroke-width: 2;
		stroke-linecap: butt;
		stroke-linejoin: miter;
		stroke-miterlimit: 10;
		filter: drop-shadow(1px 1px 1.5px rgba(0, 0, 0, 0.4));
	}
}

// ── Bande orizzontali fila (legenda prezzi via callback) ───
.fila-band {
	z-index: 4;
	pointer-events: none;
	box-sizing: border-box;
	box-shadow: inset 0 3px 8px rgba(0,0,0,0.10), inset 0 -3px 8px rgba(0,0,0,0.10);
}

// ── Sfondo zona L1 BEACH (colonne verticali) ──────────────
.beach-l1-zone-bg {
	position: absolute;
	top: 0;
	bottom: 0;
	z-index: 2;
	box-sizing: border-box;

	&--clickable {
		cursor: pointer;
		transition: filter 0.15s;

		&:hover {
			filter: brightness(1.15);
		}
	}
}

// ── Card info zona L1 BEACH ───────────────────────────────
.beach-l1-zone-card {
	position: absolute;
	top: 8px;
	display: flex;
	align-items: center;
	gap: 8px;
	background: rgba(0, 0, 0, 0.60);
	border-radius: 6px;
	padding: 5px 12px;
	pointer-events: none;
	z-index: 20;
	white-space: nowrap;
}

.blz-label {
	font-size: 10px;
	font-weight: 700;
	color: #fff;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	margin-right: 2px;
}

.blz-stat {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 11px;
	font-weight: 600;
	color: #fff;
}

.blz-dot {
	width: 9px;
	height: 9px;
	border-radius: 50%;
	border: 1.5px solid rgba(255, 255, 255, 0.7);
	flex-shrink: 0;

	&.blz-dot--free  { background: #27ae60; }
	&.blz-dot--palma { background: #f39c12; width: 11px; height: 11px; }
}

// ── Puntino stato BEACH (livello 1) ───────────────────────
.beach-status-dot {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: 24px;
	height: 24px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.88);
	z-index: 12;
	pointer-events: none;
	box-shadow: 0 1px 5px rgba(0, 0, 0, 0.40);

	&.free   { background: #27ae60; }
	&.booked { background: #e74c3c; }

	&.beach-status-dot--palma {
		width: 40px;
		height: 40px;
		border-width: 2.5px;
	}
}

// ── Contatore zona in L2 (centrato in cima al wrapper) ────
.l2-zone-counter {
	position: absolute;
	top: 10px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 30;
	white-space: nowrap;
	pointer-events: none;
}

// ── Bottone torna a vista generale ────────────────────────
.zone-back-btn {
	position: absolute;
	top: 10px;
	left: 10px;
	z-index: 30;
	display: flex;
	align-items: center;
	gap: 5px;
	background: rgba(0, 0, 0, 0.65);
	color: #fff;
	border: 1px solid rgba(255, 255, 255, 0.4);
	border-radius: 20px;
	padding: 5px 14px;
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s;

	ion-icon { font-size: 14px; }
	&:active { background: rgba(0, 0, 0, 0.85); }
}

// ── Risorsa sul canvas ────────────────────────────────────
.resource-on-canvas {
	position: absolute;
	cursor: pointer;
	user-select: none;
	z-index: 10;

	// Vista zona L2 BEACH
	&.resource-beach-l2 {
		background: #fff;
		border-radius: 5px;
		box-shadow: 0 1px 4px rgba(0,0,0,0.18);

		&.resource-beach-l2--booked {
			outline: 2px solid #e74c3c;
			cursor: not-allowed;
			opacity: 0.80;
		}

		&.resource-beach-l2--free {
			outline: 2px solid #27ae60;
		}
	}

	// Risorsa selezionata
	&.resource-selezionato {
		outline: 2.5px solid #3880ff !important;
		background: rgba(56, 128, 255, 0.18) !important;
		box-shadow: 0 0 7px rgba(56, 128, 255, 0.65) !important;
	}
}

// ── Icona risorsa (SVG) ───────────────────────────────────
.resource-icon {
	width: 100%;
	height: 100%;
	display: block;
	filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.3));
}

// ── Etichetta risorsa ─────────────────────────────────────
.resource-label {
	position: absolute;
	bottom: 1px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 9px;
	font-weight: 700;
	background: rgba(255, 255, 255, 0.92);
	border-radius: 3px;
	padding: 0px 4px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	white-space: nowrap;
	pointer-events: none;
	line-height: 1.4;
}

// ── Etichetta extra sotto (manager: cliente) ──────────────
.resource-label-extra {
	position: absolute;
	bottom: -14px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 8px;
	font-weight: 600;
	color: var(--ion-color-dark, #222);
	background: rgba(255, 255, 255, 0.92);
	border-radius: 3px;
	padding: 0px 4px;
	border: 1px solid rgba(0, 0, 0, 0.15);
	white-space: nowrap;
	pointer-events: none;
	max-width: 80px;
	overflow: hidden;
	text-overflow: ellipsis;
}

// ── Overlay stato (risorse non-beach) ─────────────────────
.status-overlay {
	position: absolute;
	inset: 0;
	border-radius: 4px;
	opacity: 0.35;
	pointer-events: none;
	z-index: 11;
	transition: opacity 0.15s;

	&.free   { background: #2ecc71; }
	&.booked { background: #e74c3c; }
}

// ── RESTAURANT: bordo gruppo prenotazione (multi-tavolo) ──
.booking-group-border {
	position: absolute;
	inset: -3px;
	border: 3px solid;
	border-radius: 6px;
	pointer-events: none;
	z-index: 13;
	box-shadow: 0 0 6px rgba(0, 0, 0, 0.20);
}

// ── RESTAURANT: label cliente (solo sul tavolo primario) ──
.booking-group-label {
	position: absolute;
	top: -22px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 10px;
	font-weight: 700;
	color: #fff;
	padding: 2px 8px;
	border-radius: 10px;
	white-space: nowrap;
	pointer-events: none;
	z-index: 14;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
	max-width: 200px;
	overflow: hidden;
	text-overflow: ellipsis;
}

// ── Stabilimento ─────────────────────────────────────────
.stabilimento-ro {
	position: absolute;
	z-index: 3;
	box-sizing: border-box;
	box-shadow: 0 3px 10px rgba(0,0,0,0.30);
	pointer-events: none;
	border-radius: 4px;
	overflow: hidden;
}

// ── Passerelle ────────────────────────────────────────────
.passerella-ro {
	position: absolute;
	background: #e8e0d0;
	border: 2px solid #e8e0d0;
	border-radius: 0;
	z-index: 5;
	box-sizing: border-box;
	pointer-events: none;
}
