/* Map-specific styles */
.map-main {
  display: flex;
  height: calc(100vh - 140px);
  position: relative;
}

/* Control Panel */
.map-controls {
  width: 320px;
  background: var(--card-background-light);
  border-right: 2px solid var(--border-color-light);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.controls-header {
  padding: 20px;
  background: var(--primary-color-light);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.controls-header h2 {
  color: white;
  font-size: 1.3em;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.controls-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.2em;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.controls-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.controls-content {
  padding: 20px;
}

/* Search Container */
.search-container {
  margin-bottom: 25px;
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 12px 45px 12px 15px;
  border: 2px solid var(--border-color-light);
  border-radius: 25px;
  font-size: 14px;
  background: var(--background-color-light);
  color: var(--text-color-light);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-container input:focus {
  outline: none;
  border-color: var(--primary-color-light);
  box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.1);
}

.search-container button {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--primary-color-light);
  border: none;
  color: white;
  width: 35px;
  height: 35px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-container button:hover {
  background: #0a3d91;
}

/* Category Filters */
.category-filters {
  margin-bottom: 25px;
}

.category-filters h3 {
  color: var(--primary-color-light);
  margin-bottom: 15px;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.filter-btn {
  padding: 12px;
  border: 2px solid var(--border-color-light);
  background: var(--background-color-light);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  text-align: center;
  color: var(--text-color-light);
}

.filter-btn:hover {
  background: var(--primary-color-light);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.filter-btn.active {
  background: var(--primary-color-light);
  color: white;
  border-color: var(--primary-color-light);
}

.filter-btn i {
  font-size: 1.2em;
}

.filter-btn span {
  font-size: 1em;
  font-weight: 600;
}

/* Map Actions */
.map-actions {
  margin-bottom: 25px;
}

.map-actions h3 {
  color: var(--primary-color-light);
  margin-bottom: 15px;
  font-size: 1.1em;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  padding: 10px 15px;
  background: var(--card-background-light);
  border: 1px solid var(--border-color-light);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-color-light);
}

.action-btn:hover {
  background: var(--primary-color-light);
  color: white;
  border-color: var(--primary-color-light);
}

/* Legend */
.map-legend h3 {
  color: var(--primary-color-light);
  margin-bottom: 15px;
  font-size: 1.1em;
}
.map-legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.map-legend li {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.95em;
}

.map-legend img {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}


.legend-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9em;
  color: var(--text-color-light);
}

.legend-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.legend-icon.historic { background: #8B4513; }
.legend-icon.sacred { background: #FFD700; }
.legend-icon.sport { background: #32CD32; }
.legend-icon.attraction { background: #FF6347; }
.legend-icon.beach { background: #87CEEB; }
.legend-icon.park { background: #228B22; }

/* Map Container */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map {
  height: 100%;
  width: 100%;
  background: #f0f8ff;
}

/* Loading */
.map-loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-color-light);
  border-top: 4px solid var(--primary-color-light);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.map-loading p {
  color: var(--text-color-light);
  font-size: 1.1em;
}

/* Info Panel */
.info-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 300px;
  background: var(--card-background-light);
  border-radius: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  z-index: 1500;
  transform: translateX(320px);
  transition: transform 0.3s ease;
  border: 2px solid var(--border-color-light);
}

.info-panel.show {
  transform: translateX(0);
}

.info-header {
  background: var(--primary-color-light);
  color: white;
  padding: 15px 20px;
  border-radius: 10px 10px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.info-header h3 {
  margin: 0;
  font-size: 1.1em;
}

.info-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.2em;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.3s ease;
}

.info-close:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.info-content {
  padding: 20px;
}

.info-content #infoDescription {
  color: var(--text-color-light);
  line-height: 1.5;
  margin-bottom: 15px;
}

.info-actions {
  display: flex;
  gap: 10px;
}

.info-btn {
  padding: 8px 16px;
  background: var(--primary-color-light);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9em;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background-color 0.3s ease;
  flex: 1;
  justify-content: center;
}

.info-btn:hover {
  background: #0a3d91;
}

/* Banner Ad */
.banner-ad {
  text-align: center;
  padding: 20px;
  background: var(--background-color-light);
  border-top: 1px solid var(--border-color-light);
}

.banner-ad img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Styles */
body.dark-mode .map-controls {
  background: var(--card-background-dark);
  border-right-color: var(--border-color-dark);
}

body.dark-mode .controls-header {
  background: var(--primary-color-dark);
  color: var(--text-color-dark);
}

body.dark-mode .controls-header h2 {
  color: var(--text-color-dark);
}

body.dark-mode .search-container input {
  background: var(--background-color-dark);
  color: var(--text-color-dark);
  border-color: var(--border-color-dark);
}

body.dark-mode .search-container input:focus {
  border-color: var(--primary-color-dark);
  box-shadow: 0 0 0 3px rgba(250, 217, 73, 0.1);
}

body.dark-mode .search-container button {
  background: var(--primary-color-dark);
  color: var(--text-color-dark);
}

body.dark-mode .category-filters h3,
body.dark-mode .map-actions h3,
body.dark-mode .map-legend h3 {
  color: #90caf9;
}

body.dark-mode .filter-btn {
  background: var(--background-color-dark);
  color: var(--text-color-dark);
  border-color: var(--border-color-dark);
}

body.dark-mode .filter-btn:hover,
body.dark-mode .filter-btn.active {
  background: var(--primary-color-dark);
  color: var(--text-color-dark);
  border-color: var(--primary-color-dark);
}

body.dark-mode .action-btn {
  background: var(--card-background-dark);
  color: var(--text-color-dark);
  border-color: var(--border-color-dark);
}

body.dark-mode .action-btn:hover {
  background: var(--primary-color-dark);
  color: var(--text-color-dark);
}

body.dark-mode .legend-item {
  color: var(--text-color-dark);
}

body.dark-mode .info-panel {
  background: var(--card-background-dark);
  border-color: var(--border-color-dark);
}

body.dark-mode .info-header {
  background: var(--primary-color-dark);
  color: var(--text-color-dark);
}

body.dark-mode .info-content #infoDescription {
  color: var(--text-color-dark);
}

body.dark-mode .info-btn {
  background: var(--primary-color-dark);
  color: var(--text-color-dark);
}

body.dark-mode .map-loading {
  background: rgba(18, 18, 18, 0.9);
}

body.dark-mode .map-loading p {
  color: var(--text-color-dark);
}

body.dark-mode .loading-spinner {
  border-color: var(--border-color-dark);
  border-top-color: var(--primary-color-dark);
}


@media (max-width: 768px) {
  .map-main {
    flex-direction: column;
    /* Riduciamo l'offset dall'header per dare più spazio alla mappa */
    height: calc(100vh - 60px); /* da -80px a -60px = +20px per la mappa */
  }

  .map-controls {
    width: 100%;
    /* Riduciamo l'altezza massima dei controlli per dare più spazio alla mappa */
    max-height: 40vh; /* da 50vh a 40vh = +10vh per la mappa */
    position: relative;
    top: 0;
    margin-bottom: 8px; /* riduciamo da 10px a 8px */
    z-index: 1001;
    border-right: none;
    border-bottom: 2px solid var(--border-color-light);
    border-radius: 0 0 12px 12px;
  }

  .controls-content {
    /* Adattiamo anche l'altezza del contenuto dei controlli */
    max-height: calc(40vh - 70px); /* da 50vh a 40vh */
    overflow-y: auto;
  }

  .map-container {
    /* Assicuriamoci che la mappa utilizzi tutto lo spazio rimanente */
    flex: 1;
    min-height: calc(60vh - 8px); /* garantisce almeno il 60% della viewport per la mappa */
  }

  /* Nascondi azioni mappa e legenda su mobile per risparmiare spazio */
  .map-actions,
  .map-legend {
    display: none !important;
  }

  /* Ottimizziamo anche il pannello info per mobile */
  .info-panel {
    top: 5px;  /* riduciamo da 10px */
    right: 5px; /* riduciamo da 10px */
    left: 5px;  /* riduciamo da 10px */
    width: auto;
    transform: translateY(-150%);
    /* Riduciamo leggermente la dimensione per lasciare più spazio alla mappa */
    max-height: 30vh;
    overflow-y: auto;
  }
  
  .filter-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  
  .filter-btn {
    padding: 8px;
    font-size: 0.8em;
  }
  
  .filter-btn span {
    font-size: 0.95em;   /* leggermente più grande del precedente 0.75em */
  }
  
  .filter-btn i {
    font-size: 1.3em;    /* leggermente più grande del precedente 1em */
  }
  
  .info-panel.show {
    transform: translateY(0);
  }
  
  .action-buttons {
    flex-direction: row;
    gap: 5px;
  }
  
  .action-btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.8em;
  }
  
  .action-btn span {
    display: none;
  }
}


@media (max-width: 480px) {
  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .filter-btn span {
    font-size: 0.7em;
  }
  
  .info-actions {
    flex-direction: column;
    gap: 8px;
  }
}

/* Leaflet custom styles */
.leaflet-popup-content-wrapper {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
  margin: 15px;
  line-height: 1.4;
}

.leaflet-popup-content h4 {
  color: var(--primary-color-light);
  margin: 0 0 8px 0;
  font-size: 1.1em;
}

body.dark-mode .leaflet-popup-content h4 {
  color: var(--primary-color-dark);
}

.leaflet-control-zoom a {
  background-color: var(--card-background-light) !important;
  color: var(--text-color-light) !important;
  border: 1px solid var(--border-color-light) !important;
}

body.dark-mode .leaflet-control-zoom a {
  background-color: var(--card-background-dark) !important;
  color: var(--text-color-dark) !important;
  border-color: var(--border-color-dark) !important;
}

/* Custom marker pulse animation */
@keyframes marker-pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.marker-pulse {
  animation: marker-pulse 2s infinite;
}
/* Map Legend - VERSIONE AGGIORNATA */
.map-legend h3 {
  color: var(--primary-color-light);
  margin-bottom: 15px;
  font-size: 1.1em;
}

.map-legend ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.map-legend li {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.95em;
}

.map-legend img {
  width: 20px;
  height: 20px;
  margin-right: 8px;
}
#map {
    height: 100vh;
}