:root {
  --bg: #0f1115;
  --card: #181b22;
  --card-hover: #1f242e;
  --border: #2a303d;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #f59e0b;
  --rist: #38bdf8;
  --piola: #34d399;
  --pill: #232834;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  min-height: 100vh;
}

/* === LANDING / SCELTA SEZIONE === */
.home-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
  max-width: 920px;
  margin: 0 auto;
}

.home-title {
  text-align: center;
  margin-bottom: 32px;
}

.home-title h1 {
  font-size: 1.9rem;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.home-title p {
  color: var(--muted);
  font-size: 0.95rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  width: 100%;
}

.choice-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.choice-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--card-hover);
}

.choice-icon {
  font-size: 2rem;
  line-height: 1;
}

.choice-card h2 {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.choice-card p {
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1;
}

.choice-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--accent);
  font-weight: 600;
}

/* === WORKSPACE PRINCIPALE === */
.app-shell {
  display: none;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.back-btn {
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
}

.back-btn:hover {
  border-color: var(--muted);
}

header h1 {
  font-size: 1.3rem;
  letter-spacing: -0.02em;
}

.switch-section-btn {
  padding: 6px 11px;
  border-radius: 8px;
  border: 1px dashed var(--accent);
  background: rgba(245, 158, 11, 0.08);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.switch-section-btn:hover {
  background: rgba(245, 158, 11, 0.16);
}

.stats {
  font-size: 0.88rem;
  color: var(--muted);
}

.stats strong {
  color: var(--text);
}

/* === SWITCHER MAPPA / SCHEDE AD ALTA VISIBILITÀ === */
.view-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.view-btn {
  padding: 12px 16px;
  border-radius: 11px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}

.view-btn:hover {
  border-color: var(--muted);
  background: var(--card-hover);
}

.view-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.25);
}

/* === FILTRI === */
.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

input[type="search"] {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

input[type="search"]:focus {
  border-color: var(--accent);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.filter-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-right: 4px;
}

.btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  border-color: var(--muted);
  color: var(--text);
}

.btn.active {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
  font-weight: 600;
}

.btn.random {
  border-color: rgba(245, 158, 11, 0.45);
  color: var(--accent);
  margin-left: auto;
}

/* === VISTA MAPPA === */
.map-wrapper {
  position: relative;
  width: 100%;
  height: calc(100vh - 295px);
  min-height: 450px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #14171d;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
  background: #14171d;
}

/* Tema scuro applicato SOLO ai tile OSM senza alterare i pin */
.leaflet-tile-pane {
  filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.leaflet-control-attribution {
  background: rgba(24, 27, 34, 0.85) !important;
  color: var(--muted) !important;
}

.leaflet-control-attribution a {
  color: var(--rist) !important;
}

.map-legend {
  position: absolute;
  bottom: 16px;
  left: 12px;
  z-index: 500;
  background: rgba(24, 27, 34, 0.92);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
  padding: 8px 12px;
  border-radius: 9px;
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-rist {
  background: var(--rist);
  box-shadow: 0 0 6px var(--rist);
}

.dot-piola {
  background: var(--piola);
  box-shadow: 0 0 6px var(--piola);
}

.recenter-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(24, 27, 34, 0.94);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.recenter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.map-empty-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 500;
  background: rgba(24, 27, 34, 0.95);
  border: 1px solid var(--border);
  padding: 18px 22px;
  border-radius: 12px;
  text-align: center;
  max-width: 360px;
  font-size: 0.88rem;
  color: var(--muted);
}

.map-empty-banner strong {
  color: var(--text);
  display: block;
  margin-bottom: 4px;
  font-size: 0.95rem;
}

/* Popup Leaflet Dark */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--card) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.55) !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  min-width: 220px;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--muted) !important;
}

.pop-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 4px;
}

.pop-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
}

.pop-addr {
  font-size: 0.76rem;
  color: var(--accent);
  margin-bottom: 6px;
}

.pop-desc {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.4;
}

.pop-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* === VISTA SCHEDE === */
.grid {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s;
}

.card.highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.name {
  font-size: 1.03rem;
  font-weight: 600;
}

.addr {
  font-size: 0.78rem;
  color: var(--accent);
}

.badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.b-ristorante {
  background: rgba(56, 189, 248, 0.15);
  color: var(--rist);
}

.b-piola {
  background: rgba(52, 211, 153, 0.15);
  color: var(--piola);
}

.desc {
  font-size: 0.85rem;
  color: var(--muted);
  flex: 1;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.cuisine-tag {
  font-size: 0.74rem;
  background: var(--pill);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 6px;
}

.maps-link {
  color: var(--rist);
  text-decoration: none;
  font-size: 0.83rem;
  font-weight: 500;
}

.maps-link:hover {
  text-decoration: underline;
}

.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
