:root {
  --blu-navy: #14243a;
  --blu-navy-2: #1a2f4a;
  --arancio: #ff8a00;
  --arancio-hover: #ffa733;
}
* { box-sizing: border-box; }
.nascosto { display: none !important; }
html, body { height: 100%; margin: 0; font-family: 'Inter Tight', system-ui, -apple-system, "Segoe UI", sans-serif; }
#app { display: flex; flex-direction: column; height: 100%; }

/* ---------------- Header ---------------- */
#app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.9rem; background: var(--blu-navy); color: #fff;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 0.5rem; text-decoration: none; color: inherit; }
.brand .logo-img { height: 30px; width: 30px; border-radius: 6px; display: block; }
.brand .logo-placeholder {
  height: 30px; width: 30px; border-radius: 6px; background: var(--arancio);
  color: var(--blu-navy); font-weight: 800; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.brand .nome { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }

.header-azioni { display: flex; align-items: center; gap: 0.1rem; }

.icona-header {
  background: none; border: none; cursor: pointer; padding: 0.4rem;
  display: flex; align-items: center; justify-content: center; color: #fff;
  border-radius: 6px;
}
.icona-header svg { width: 22px; height: 22px; }
.icona-header:hover { background: rgba(255,255,255,0.12); }
.icona-header:active { background: rgba(255,255,255,0.2); }

#btn-menu {
  background: none; border: none; cursor: pointer; padding: 0.4rem;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
#btn-menu svg { width: 24px; height: 24px; color: #fff; }
#btn-menu .linea { transition: transform 0.2s ease, opacity 0.2s ease; transform-origin: center; }
#btn-menu[aria-expanded="true"] .linea-1 { transform: translateY(6px) rotate(45deg); }
#btn-menu[aria-expanded="true"] .linea-2 { opacity: 0; }
#btn-menu[aria-expanded="true"] .linea-3 { transform: translateY(-6px) rotate(-45deg); }

.puntino-notifica {
  position: absolute; top: 4px; right: 4px; width: 9px; height: 9px;
  border-radius: 50%; background: #e0245e; border: 1.5px solid var(--blu-navy);
}
.puntino-notifica.nascosto { display: none; }
.puntino-notifica-inline {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #e0245e; margin-left: 0.35rem; vertical-align: middle;
}
.puntino-notifica-inline.nascosto { display: none; }

/* ---------------- Menu laterale ---------------- */
#overlay-menu {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 2000;
}
#overlay-menu.aperto { opacity: 1; pointer-events: auto; }

#menu-laterale {
  position: fixed; top: 0; right: 0; height: 100%; width: min(280px, 80%);
  background: #fff; box-shadow: -2px 0 12px rgba(0,0,0,0.2);
  transform: translateX(100%); transition: transform 0.25s ease;
  z-index: 2001; display: flex; flex-direction: column;
}
#menu-laterale.aperto { transform: translateX(0); }
#menu-laterale .menu-intestazione {
  padding: 1rem; background: var(--blu-navy); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between;
}
#menu-laterale ul { list-style: none; margin: 0; padding: 0.5rem 0; }
#menu-laterale li { border-bottom: 1px solid #eee; }
#menu-laterale li.attiva button, #menu-laterale li.attiva a { background: #f0f4f8; font-weight: 600; }
#menu-laterale li.nascosto { display: none; }
#menu-laterale li.separatore-sopra { border-top: 8px solid #f5f5f5; }

/* ---------------- Pannello "Supporta il progetto" ---------------- */
#overlay-supporta {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 2000;
}
#overlay-supporta.aperto { opacity: 1; pointer-events: auto; }

#pannello-supporta {
  position: fixed; left: 50%; bottom: 0; width: min(360px, 92%);
  transform: translate(-50%, 100%); transition: transform 0.25s ease;
  background: #fff; border-radius: 12px 12px 0 0; box-shadow: 0 -2px 16px rgba(0,0,0,0.25);
  z-index: 2001; padding-bottom: 1rem;
}
#pannello-supporta.aperto { transform: translate(-50%, 0); }
#pannello-supporta .pannello-intestazione {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; font-weight: 700; border-bottom: 1px solid #eee;
}
#pannello-supporta .pannello-intestazione button {
  background: none; border: none; font-size: 1.4rem; line-height: 1; cursor: pointer; color: #888;
}
#pannello-supporta .pannello-testo { padding: 0.8rem 1rem 0.4rem; color: #555; font-size: 0.9rem; }
#pannello-supporta .pannello-bottoni { display: flex; gap: 0.6rem; padding: 0.6rem 1rem 0; }
.bottone-supporto {
  flex: 1; text-align: center; padding: 0.7rem; border-radius: 8px;
  text-decoration: none; font-weight: 700; color: #fff;
}
.bottone-supporto.paypal { background: #003087; }
.bottone-supporto.satispay { background: #ff3d00; }

/* ---------------- Popup automatico "Installa l'app" ---------------- */
#overlay-popup-installa {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 2000;
}
#overlay-popup-installa.aperto { opacity: 1; pointer-events: auto; }

#popup-installa {
  position: fixed; left: 50%; bottom: 0; width: min(380px, 92%);
  transform: translate(-50%, 100%); transition: transform 0.25s ease;
  background: #fff; border-radius: 12px 12px 0 0; box-shadow: 0 -2px 16px rgba(0,0,0,0.25);
  z-index: 2001; padding: 1.2rem 1.2rem 1.6rem;
}
#popup-installa.aperto { transform: translate(-50%, 0); }
#popup-installa h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
#popup-installa p { margin: 0 0 0.6rem; color: #555; font-size: 0.9rem; line-height: 1.5; }
.popup-installa-chiudi {
  position: absolute; top: 0.6rem; right: 0.8rem; background: none; border: none;
  font-size: 1.4rem; line-height: 1; cursor: pointer; color: #888;
}
.popup-installa-passi { padding-left: 1.3rem; color: #333; font-size: 0.9rem; line-height: 1.7; }
.icona-inline { width: 18px; height: 18px; vertical-align: -4px; color: var(--blu-navy-2); }
.bottone-installa {
  width: 100%; padding: 0.7rem; border-radius: 8px; border: none;
  background: var(--arancio); color: var(--blu-navy); font-weight: 700; font-size: 0.95rem; cursor: pointer;
}
.bottone-installa:hover { background: var(--arancio-hover); }
#menu-laterale button, #menu-laterale a {
  all: unset; display: flex; align-items: center; gap: 0.7rem; width: 100%;
  padding: 0.8rem 1rem; font-size: 0.95rem; color: #222; cursor: pointer; box-sizing: border-box;
}
#menu-laterale button:hover, #menu-laterale a:hover { background: #f5f5f5; }
#menu-laterale svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--blu-navy-2); }
#menu-feedback { padding: 0.6rem 1rem; font-size: 0.8rem; color: #0a7a0a; min-height: 1.2rem; }
.menu-made-with {
  display: flex; align-items: center; gap: 0.25rem;
  font-size: 0.72rem; font-weight: 400; color: #b8c4d4;
}
.icona-cuore { width: 12px; height: 12px; }

/* ---------------- Toolbar filtri (usata dalla pagina mappa) ---------------- */
#barra {
  display: flex; flex-wrap: nowrap; align-items: stretch; gap: 0.6rem;
  padding: 0.5rem 0.7rem; background: var(--blu-navy-2); color: #fff;
  flex-shrink: 0;
}
#barra label {
  display: flex; flex-direction: column; gap: 0.15rem;
  flex: 1 1 0; min-width: 0; /* min-width:0 è ciò che permette a un figlio
                                  flex di restringersi sotto la sua larghezza
                                  "naturale" invece di forzare il wrap */
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: #b8c4d4;
}
#barra select {
  width: 100%; min-width: 0;
  font-size: 0.88rem; padding: 0.35rem 0.4rem; border-radius: 4px; border: none;
}

.toggle-convenienti {
  display: flex; align-items: center; gap: 0.5rem; color: #fff;
  font-size: 0.85rem; cursor: pointer; user-select: none; width: fit-content;
}
.toggle-convenienti input {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.toggle-slider {
  position: relative; width: 36px; height: 20px; border-radius: 999px; flex-shrink: 0;
  background: rgba(255,255,255,0.28); transition: background 0.15s ease;
}
.toggle-slider::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform 0.15s ease;
}
.toggle-convenienti input:checked + .toggle-slider { background: #2e7d32; }
.toggle-convenienti input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle-convenienti input:disabled + .toggle-slider { opacity: 0.4; cursor: not-allowed; }
.toggle-convenienti input:disabled ~ * { cursor: not-allowed; }

#stato {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.9rem; font-size: 0.85rem; color: #444; background: #f5f5f5; flex-shrink: 0;
}
.stato-punto {
  width: 8px; height: 8px; border-radius: 50%; background: #2e7d32; flex-shrink: 0;
  opacity: 0; transition: opacity 0.15s ease;
}
.stato-punto.attivo { opacity: 1; animation: lampeggia-punto 1s ease-in-out infinite; }
@keyframes lampeggia-punto {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
#stato.errore { color: #b00020; }

#mappa { flex: 1; min-height: 0; }

.marker-personalizzato { background: transparent; border: none; }
.marker-personalizzato svg { display: block; }

/* Leaflet applica il proprio font-family con una regola più specifica
   (.leaflet-container) della nostra su html/body: senza questo override
   esplicito popup e tooltip restano nel font di default di Leaflet. */
.leaflet-container,
.leaflet-popup-content,
.leaflet-tooltip {
  font-family: 'Inter Tight', system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------------- Banner affiliato ---------------- */
#banner-affiliato {
  flex-shrink: 0; position: relative; background: #fff7ec; border-top: 1px solid #f0dcb8;
}
.banner-etichetta {
  position: absolute; top: 3px; right: 6px; font-size: 0.62rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: #a98a4e; font-weight: 700;
}
.banner-link {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.9rem;
  text-decoration: none; color: inherit;
}
.banner-immagine, .banner-immagine-placeholder {
  width: 52px; height: 52px; border-radius: 6px; flex-shrink: 0; object-fit: cover;
  background: #e8dcc2;
}
.banner-testo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.banner-titolo { font-weight: 700; font-size: 0.88rem; color: #222; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-descrizione { font-size: 0.78rem; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-cta {
  flex-shrink: 0; font-size: 0.78rem; font-weight: 700; color: var(--blu-navy);
  background: var(--arancio); padding: 0.4rem 0.7rem; border-radius: 6px; white-space: nowrap;
}

/* ---------------- Footer ---------------- */
#app-footer {
  flex-shrink: 0; padding: 0.5rem 0.9rem; background: #eef1f4; color: #555;
  font-size: 0.78rem; text-align: center; line-height: 1.4;
}
#app-footer a { color: var(--blu-navy-2); }
#app-footer .tagline { font-style: italic; color: #888; margin-top: 0.15rem; }

/* ---------------- Marker "sei qui" pulsante ---------------- */
.marker-utente { position: relative; width: 22px; height: 22px; }
.marker-utente-punto {
  position: absolute; top: 50%; left: 50%; width: 14px; height: 14px;
  margin: -7px 0 0 -7px; background: #4285f4; border: 2px solid #fff;
  border-radius: 50%; box-shadow: 0 0 4px rgba(0,0,0,0.45); z-index: 2;
}
.marker-utente-alone {
  position: absolute; top: 50%; left: 50%; width: 22px; height: 22px;
  margin: -11px 0 0 -11px; background: rgba(66, 133, 244, 0.55);
  border-radius: 50%; animation: polso-utente 1.8s ease-out infinite;
}
@keyframes polso-utente {
  0%   { transform: scale(0.4); opacity: 0.9; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ---------------- Etichetta prezzo sopra i marker stazione ---------------- */
.leaflet-tooltip.prezzo-tooltip {
  background: #fff; border: 1px solid #ccc; border-radius: 4px;
  padding: 1px 6px; font-size: 0.72rem; font-weight: 700; color: #222;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.leaflet-tooltip.prezzo-tooltip::before { border-top-color: #ccc; }

/* ---------------- Pagine di contenuto (informazioni, novità, privacy) ---------------- */
.pagina-contenuto { flex: 1; overflow-y: auto; padding: 1.2rem 1.2rem 2rem; max-width: 640px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.pagina-contenuto h1 { font-size: 1.4rem; margin: 0 0 0.3rem; }
.pagina-contenuto h2 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }
.pagina-contenuto p { line-height: 1.6; color: #333; margin: 0 0 0.8rem; }
.pagina-contenuto ul { padding-left: 1.2rem; line-height: 1.6; color: #333; }
.pagina-contenuto .novita-voce { margin-bottom: 1.4rem; padding-bottom: 1.4rem; border-bottom: 1px solid #eee; }
.pagina-contenuto .novita-voce:last-child { border-bottom: none; }
.pagina-contenuto .novita-data { font-size: 0.78rem; color: #888; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.3rem; }

#barra-secondaria {
  padding: 0.4rem 0.7rem; background: var(--blu-navy-2); flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
}
.cambio-vista { display: flex; gap: 0.2rem; flex-shrink: 0; }
.icona-vista {
  background: none; border: none; cursor: pointer; padding: 0.3rem;
  color: rgba(255,255,255,0.5); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.icona-vista svg { width: 20px; height: 20px; }
.icona-vista.attiva { color: #fff; background: rgba(255,255,255,0.15); }
.icona-vista:hover { color: #fff; }

#barra-ordinamento {
  display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
  padding: 0.4rem 0.9rem; background: #eef1f4; font-size: 0.82rem; color: #444;
  flex-shrink: 0;
}
#barra-ordinamento label { display: flex; align-items: center; gap: 0.25rem; cursor: pointer; }

#vista-elenco { flex: 1; overflow-y: auto; padding: 0.6rem; background: #f5f5f5; }
.elenco-vuoto { text-align: center; color: #888; padding: 2rem 1rem; font-size: 0.9rem; }
.elenco-card {
  background: #fff; border: 1px solid #e6e6e6; border-radius: 8px;
  padding: 0.7rem 0.9rem; margin-bottom: 0.6rem; display: flex; align-items: center;
  justify-content: space-between; gap: 0.7rem; cursor: pointer;
}
.elenco-card:hover { border-color: #c7ccd1; }
.elenco-card .elenco-info { min-width: 0; }
.elenco-card .elenco-titolo { display: flex; align-items: center; font-weight: 700; gap: 0.4rem; }
.elenco-card .elenco-titolo .logo { height: 18px; flex-shrink: 0; }
.elenco-card .elenco-indirizzo { color: #666; font-size: 0.82rem; margin-top: 0.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.elenco-card .elenco-prezzo {
  font-size: 1.15rem; font-weight: 800; flex-shrink: 0; padding: 0.3rem 0.6rem;
  border-radius: 6px; color: #fff;
}
.elenco-card .elenco-stella {
  background: none; border: none; cursor: pointer; padding: 0.1rem; flex-shrink: 0;
  color: #b0b4b9; display: flex; align-items: center;
}
.elenco-card .elenco-stella svg { width: 18px; height: 18px; fill: none; }
.elenco-card .elenco-stella.attivo { color: #f5a623; }
.elenco-card .elenco-stella.attivo svg { fill: #f5a623; }

/* ---------------- Lista preferiti ---------------- */
#lista-preferiti { flex: 1; overflow-y: auto; padding: 0.6rem; }
.preferito-card {
  background: #fff; border: 1px solid #e6e6e6; border-radius: 8px;
  padding: 0.7rem 0.9rem; margin-bottom: 0.6rem;
}
.preferito-riga { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.preferito-titolo { display: flex; align-items: center; font-weight: 700; min-width: 0; }
.preferito-titolo .logo { height: 20px; margin-right: 0.4rem; flex-shrink: 0; }
.preferito-indirizzo { color: #666; font-size: 0.85rem; margin-top: 0.15rem; }
.preferito-prezzi { list-style: none; margin: 0.5rem 0 0; padding: 0.5rem 0 0; border-top: 1px solid #eee; font-size: 0.85rem; }
.preferito-prezzi li { display: flex; justify-content: space-between; padding: 0.1rem 0; }
.preferito-prezzi .self { color: #0a7a0a; font-size: 0.8em; }
.preferito-prezzi .servito { color: #888; font-size: 0.8em; }
.preferito-prezzi-stato { margin-top: 0.5rem; padding-top: 0.5rem; border-top: 1px solid #eee; font-size: 0.8rem; color: #999; font-style: italic; }
.preferito-rimuovi {
  background: none; border: none; cursor: pointer; padding: 0.15rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.preferito-rimuovi svg { width: 22px; height: 22px; fill: #f5a623; color: #f5a623; }

/* ---------------- Popup marker mappa ---------------- */
.popup-stazione { font-size: 0.9rem; min-width: 190px; }
.popup-stazione .logo { height: 20px; vertical-align: middle; margin-right: 0.3rem; }
.popup-stazione h3 {
  margin: 0 0 0.2rem 0; font-size: 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 0.4rem;
}
.popup-stazione .popup-titolo { display: flex; align-items: center; min-width: 0; }
.popup-preferito {
  background: none; border: none; cursor: pointer; padding: 0.15rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  color: #b0b4b9; /* stella vuota: grigio discreto */
}
.popup-preferito svg { width: 20px; height: 20px; fill: none; transition: fill 0.15s ease, color 0.15s ease; }
.popup-preferito.attivo { color: #f5a623; }
.popup-preferito.attivo svg { fill: #f5a623; }
.popup-stazione .indirizzo { color: #555; margin-bottom: 0.4rem; }
.popup-freschezza {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em;
  padding: 0.15rem 0.4rem; border-radius: 3px; display: inline-block; margin-bottom: 0.3rem;
}
.popup-freschezza.live { background: #e6f7ec; color: #0a7a2f; }
.popup-freschezza.archivio { background: #f2f2f2; color: #777; text-transform: none; font-weight: 600; }
.popup-stazione ul { list-style: none; margin: 0; padding: 0; }
.popup-stazione li { display: flex; justify-content: space-between; padding: 0.1rem 0; }
.popup-stazione li.selezionato { font-weight: 700; }
.popup-stazione .self { color: #0a7a0a; font-size: 0.8em; }
.popup-stazione .servito { color: #888; font-size: 0.8em; }
.popup-indicazioni {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  margin-top: 0.65rem; padding: 0.45rem 0.7rem; border-radius: 6px;
  background: #fff; border: 1.5px solid #dadce0; color: #3c4043;
  text-decoration: none; font-weight: 600; font-size: 0.85rem;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.popup-indicazioni:hover { background: #f1f3f4; border-color: #b0b4b9; }
.popup-indicazioni svg { width: 17px; height: 17px; flex-shrink: 0; color: #4285f4; }
