:root {
  --primary: #3bd2c9; /* Viola GeoExplorer */
  --primary-light: #61e0d7;
  --accent: #41c2b9;
  --bg-sidebar: #ffffff;
  --bg-map: #f4f4f4;
  --text-main: #333;
  --text-muted: #888;
  --shadow: rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body, html {
  height: 100%;
  width: 100%;
  font-family: 'Poppins', sans-serif;
  overflow: hidden;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Layout Mappa */
#map-container {
  flex: 1;
  position: relative;
  z-index: 1;
}

#map {
  height: 100%;
  width: 100%;
}

/* === RIGHELLO DINAMICO === */
#custom-scale-control {
  pointer-events: none;
  min-width: 120px;
  font-size: 15px;
  font-family: inherit;
  background: transparent;
  border-radius: 12px;
  padding: 6px 14px 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  right: 42px !important;
  bottom: 10px !important;
  z-index: 1200;
  flex-direction: column;
}

#custom-scale-control .scale-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#custom-scale-control .scale-label {
  font-size: 1em;
  color: #111;
  margin-bottom: -8px;
  margin-top: -10px;
  transform: translate(-20px, 10px); /* x=sinistra, y=basso */

  text-align: center;
}

#custom-scale-control .scale-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

#custom-scale-control .scale-bar {
  position: relative;
  height: 3px;
  border-radius: 3px;
  background: #111;
  margin: 8px 4px 0 4px;
  min-width: 60px;
  max-width: 120px;
  transition: width 0.2s;
  display: inline-block;
}

#custom-scale-control .scale-bar::before,
#custom-scale-control .scale-bar::after {
  content: '';
  position: absolute;
  width: 2px;
  height: 12px;
  margin-right: 2px;
  margin-left: 2px;
  background: #111;
  top: 0;
  transform: translateY(-50%);
}

#custom-scale-control .scale-bar::before {
  left: -4px;
}

#custom-scale-control .scale-bar::after {
  right: -4px;
}

#custom-scale-control .scale-icon {
  font-size: 1.5em;
  margin-right: 2px;
  margin-bottom: 14px;
}

@media (max-width: 600px) {
  #custom-scale-control {
    right: 10px;
    bottom: 90px;
    font-size: 13px;
    padding: 5px 8px 5px 7px;
  }
  #custom-scale-control .scale-bar {
    min-width: 40px;
    max-width: 80px;
    margin: 0px;
  }
}

/* Toggle per mobile */
.sidebar-toggle-btn {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 1000;
  background: white;
  border: none;
  width: 45px;
  height: 45px;
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow);
  cursor: pointer;
  display: none; /* Nascosto su desktop */
}

/* Custom Marker (Cerchio Rosso con punta) */
.custom-pin {
  background: #3bd2c9;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 16px;
  position: relative;
}

.custom-pin::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #31b1a8;
}

/* Stile per pin arancione */
.custom-pin.pin-comune {
  background: orange;
  color: white;
}

.custom-pin.pin-comune::after {
  border-top: 8px solid orange;
}

/* Info Card Bottom - Desktop con sidebar */
#map-card {
  position: fixed;
  left: 320px;
  width: calc(100% - 320px);
  padding: 0;
  transition: 0.35s cubic-bezier(0.25, 1, 0.3, 1);
  z-index: 1500;
}

#map-card.visible {
  bottom: 0;
}

.map-card-inner {
  background: white;
  color: var(--text-main);
  border-radius: 18px 18px 0 0;
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
}

.map-card-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.map-card-icon {
  width: 34px;
  height: 34px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.map-card-category {
  opacity: 0.6;
  font-size: 12px;
  text-transform: capitalize;
}

.map-card-title {
  font-size: 18px;
  margin: 2px 0;
  font-weight: 600;
}

.map-card-scroll {
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.map-card-desc {
  font-size: 14px;
  margin: 6px 0 12px;
  line-height: 1.5;
}

.map-card-scroll::-webkit-scrollbar {
  width: 6px;
}

.map-card-scroll::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 150, 0.6);
  border-radius: 6px;
}

.map-card-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.map-card-btn-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-card-btn {
  background: var(--primary);
  color: white;
  padding: 12px 18px;
  text-decoration: none;
  border-radius: 100px;
  font-weight: 600;
  display: inline-block;
  text-align: center;
  transition: transform 0.2s, background 0.2s;
}

.map-card-btn:hover {
  background: var(--accent);
  transform: scale(1.02);
}

.map-card-btn.secondary-btn {
  background: #f0f0f0;
  color: var(--text-main);
}

.map-card-btn.secondary-btn:hover {
  background: #e0e0e0;
}

.close-btn {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #ccc;
  cursor: pointer;
  z-index: 0;
}

.map-card-image {
    align-self: center;
    border-radius: 12px;
    overflow: hidden;
}

.map-card-image img {
    width: 80px;
    height: 100px;
    display: block;
}

.bounce {
  animation: markerBounce 0.5s ease;
}

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

/* Responsive */
@media (max-width: 768px) {
  .sidebar-toggle-btn { 
    display: flex; 
    align-items: center; 
    justify-content: center; 
  }
  
  .sidebar {
    position: absolute;
    left: -100% !important;
    z-index: 1001;
  }
  
  .sidebar.open { 
    left: 0 !important; 
  }
  
  /* Card mobile a larghezza piena */
  #map-card {
    left: 0 !important;
    width: 100% !important;
  }
}