/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-deep:   #1e3d1a;
  --green-main:   #2d5a27;
  --green-mid:    #4a8c3f;
  --green-light:  #7dba6f;
  --green-pale:   #d4edcc;
  --green-wash:   #f0f7ee;
  --cream:        #faf8f3;
  --earth:        #8b6914;
  --earth-light:  #c4962a;
  --text-primary: #1a2e17;
  --text-muted:   #5a7055;
  --text-light:   #8fad86;
  --white:        #ffffff;
  --shadow-sm:    0 2px 8px rgba(30,61,26,0.10);
  --shadow-md:    0 4px 20px rgba(30,61,26,0.15);
  --radius:       12px;
  --radius-sm:    8px;
  --header-h:     110px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'DM Sans', sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--text-primary);
}

/* ===== HEADER ===== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--green-main);
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-leaf { font-size: 22px; }
.logo-title {
  display: block;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  color: var(--white);
  line-height: 1.1;
}
.logo-sub {
  display: block;
  font-size: 11px;
  color: var(--green-pale);
  font-weight: 300;
  letter-spacing: 0.02em;
}

.btn-segnala {
  background: var(--earth-light);
  color: var(--white);
  border: none;
  border-radius: 20px;
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-segnala:hover { background: var(--earth); }
.btn-segnala:active { transform: scale(0.97); }

/* FILTRI */
.filtri {
  display: flex;
  gap: 6px;
  padding: 6px 12px 10px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filtri::-webkit-scrollbar { display: none; }

.filtro {
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  color: var(--green-pale);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 5px 13px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.18s;
}
.filtro:hover { background: rgba(255,255,255,0.25); }
.filtro.active {
  background: var(--white);
  color: var(--green-deep);
  border-color: var(--white);
  font-weight: 500;
}

/* ===== MAPPA ===== */
#map {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0; bottom: 0;
  z-index: 1;
}

/* ===== MARKER PERSONALIZZATI ===== */
.custom-marker {
  width: 36px; height: 36px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0,0,0,0.25);
  border: 2.5px solid white;
  cursor: pointer;
  transition: transform 0.15s;
}
.custom-marker .icon {
  transform: rotate(45deg);
  font-size: 16px;
  line-height: 1;
}
.custom-marker.parco     { background: #2d7a22; }
.custom-marker.cani      { background: #8b4f14; }
.custom-marker.giochi    { background: #d4821a; }
.custom-marker.fontanella{ background: #1a6fa8; }
.custom-marker.albero    { background: #1e5c1a; }
.custom-marker.panchina  { background: #5a7a40; }

/* ===== BOTTOM SHEET ===== */
.sheet-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 500;
}
.sheet-backdrop.open { display: block; }

.bottom-sheet {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--white);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
  z-index: 600;
  transform: translateY(100%);
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  max-height: 60vh;
  overflow-y: auto;
}
.bottom-sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 40px; height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 12px auto 0;
}

.sheet-content { padding: 16px 20px 32px; }

.sheet-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 10px;
  background: var(--green-pale);
  color: var(--green-deep);
}
.sheet-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 6px;
}
.sheet-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}
.sheet-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--green-pale);
  padding-top: 14px;
}
.sheet-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
}
.sheet-meta-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.sheet-meta-label { color: var(--text-muted); min-width: 80px; }
.sheet-meta-value { color: var(--text-primary); font-weight: 400; }

.btn-naviga {
  display: block;
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  background: var(--green-main);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-naviga:hover { background: var(--green-deep); }

/* ===== MODAL SEGNALAZIONE ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 900;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  width: 100%;
  max-width: 560px;
  border-radius: 20px 20px 0 0;
  padding: 0 0 env(safe-area-inset-bottom);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 10px;
  border-bottom: 1px solid var(--green-pale);
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--green-wash); }

#formSegnala {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px 24px;
}

#formSegnala label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

#formSegnala input,
#formSegnala select,
#formSegnala textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--green-pale);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--cream);
  transition: border-color 0.18s;
  outline: none;
}
#formSegnala input:focus,
#formSegnala select:focus,
#formSegnala textarea:focus {
  border-color: var(--green-mid);
}

.btn-submit {
  padding: 13px;
  background: var(--green-main);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-submit:hover { background: var(--green-deep); }
.btn-submit:disabled { background: var(--text-light); cursor: not-allowed; }

.form-note {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  line-height: 1.5;
}

.form-success {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 20px 36px;
  gap: 10px;
}
.form-success.show { display: flex; }
.success-icon {
  width: 56px; height: 56px;
  background: var(--green-main);
  color: var(--white);
  border-radius: 50%;
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 6px;
}
.form-success h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}
.form-success p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 280px;
}

/* ===== LOADER ===== */
.loader-overlay {
  position: fixed; inset: 0;
  background: var(--green-deep);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s;
}
.loader-overlay.hidden { opacity: 0; pointer-events: none; }
.loader-box { text-align: center; color: var(--green-pale); }
.loader-box p { margin-top: 14px; font-size: 14px; font-weight: 300; letter-spacing: 0.04em; }

.loader-spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--green-pale);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green-deep);
  color: var(--white);
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 400;
  z-index: 9000;
  transition: transform 0.3s;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ===== LEAFLET OVERRIDES ===== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-md) !important;
  font-family: var(--font-body) !important;
}
.leaflet-popup-content { font-size: 13px !important; }

/* ===== CONTATORE RISULTATI ===== */
.risultati-badge {
  position: fixed;
  bottom: 20px;
  right: 16px;
  background: var(--white);
  border: 1px solid var(--green-pale);
  color: var(--green-main);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  z-index: 400;
  pointer-events: none;
}

@media (min-width: 600px) {
  .modal { border-radius: 20px; margin: auto; max-height: 80vh; }
  .modal-overlay { align-items: center; padding: 20px; }
  .bottom-sheet { max-width: 480px; left: 50%; right: auto; transform: translateX(-50%) translateY(100%); }
  .bottom-sheet.open { transform: translateX(-50%) translateY(0); }
}
