/* ═══════════════════════════════════════
   PrezziCarburanti — Ultra Minimal
   Mobile-first, mappa protagonista
   ═══════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --surface2: #242424;
  --border:   rgba(255,255,255,0.08);
  --text:     #f0f0f0;
  --muted:    #666;
  --accent:   #ff4d00;
  --green:    #00c853;
  --amber:    #ffab00;
  --red:      #ff1744;
  --blue:     #2979ff;
  --r:        12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
}

/* ── MAPPA FULL SCREEN ── */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.leaflet-control-attribution { display: none !important; }
.leaflet-control-zoom { display: none !important; }

/* ── TOP BAR ── */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: env(safe-area-inset-top, 0) 0 0;
}

#topbar-inner {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(to bottom, rgba(15,15,15,0.98) 0%, rgba(15,15,15,0) 100%);
  padding-bottom: 20px;
}

#logo {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}

#logo span { color: var(--accent); }

#search-wrap {
  flex: 1;
  position: relative;
}

#search-input {
  width: 100%;
  background: rgba(26,26,26,0.96);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 16px 10px 36px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  outline: none;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

#search-input::placeholder { color: var(--muted); }
#search-input:focus { border-color: rgba(255,255,255,0.2); }

.search-ico {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  color: var(--muted);
  pointer-events: none;
}

#autocomplete {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  z-index: 200;
  display: none;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
}

.ac-item {
  padding: 13px 16px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ac-item:last-child { border-bottom: none; }
.ac-item:active { background: var(--surface2); }
.ac-ico { color: var(--muted); font-size: 11px; }

/* ── FILTRI ── */
#filters {
  position: fixed;
  top: 64px;
  left: 0; right: 0;
  z-index: 100;
  padding: 4px 16px 12px;
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
}
#filters::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  background: rgba(20,20,20,0.95);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.18s;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  white-space: nowrap;
  user-select: none;
}

.chip.on { color: #0f0f0f; border-color: transparent; }
.chip.on.c-benzina { background: #ff6b35; }
.chip.on.c-diesel  { background: #ffa726; }
.chip.on.c-gpl     { background: #42a5f5; }
.chip.on.c-metano  { background: #66bb6a; }
.chip.on.c-aperto  { background: #f0f0f0; }

/* ── TASTO POSIZIONE ── */
#locate-btn {
  position: fixed;
  right: 16px;
  bottom: 190px;
  z-index: 100;
  width: 46px; height: 46px;
  background: rgba(20,20,20,0.96);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 19px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
  transition: transform 0.15s;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}

#locate-btn:active { transform: scale(0.9); }

/* ── BARRA MEDIA PREZZI ── */
#bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 100;
  background: rgba(15,15,15,0.98);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(30px);
  backdrop-filter: blur(30px);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0));
}

#bar-label {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 12px;
}

#bar-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.avg-item { text-align: center; }

.avg-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  margin: 0 auto 5px;
}

.avg-fuel {
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 3px;
}

.avg-val {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
}

/* ── CUSTOM MARKER ── */
.pin-wrap {
  position: relative;
}

.pin {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,0.85);
  box-shadow: 0 2px 10px rgba(0,0,0,0.6);
  cursor: pointer;
  transition: transform 0.15s;
}

/* ── SHEET DETTAGLIO ── */
#sheet {
  position: fixed;
  bottom: -100%;
  left: 0; right: 0;
  z-index: 300;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--border);
  transition: bottom 0.32s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

#sheet.open { bottom: 0; }

.sh-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  margin: 12px auto 0;
}

#sh-close {
  position: absolute;
  top: 14px; right: 16px;
  width: 28px; height: 28px;
  background: var(--surface2);
  border-radius: 50%;
  border: none;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sh-body { padding: 16px 20px 8px; }

.sh-brand {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 4px;
}

.sh-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin-bottom: 6px;
}

.sh-addr {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 14px;
}

.sh-open {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 50px;
  margin-bottom: 16px;
}

.sh-open.y { background: rgba(0,200,83,0.1); color: var(--green); }
.sh-open.n { background: rgba(255,23,68,0.1); color: var(--red); }
.sh-open .d { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.sh-prezzi {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.sh-p {
  background: var(--surface2);
  border-radius: var(--r);
  padding: 14px;
  position: relative;
}

.sh-p-name {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.sh-p-val {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: 6px;
}

.sh-p-diff {
  font-size: 11px;
  font-weight: 500;
}

.diff-low  { color: var(--green); }
.diff-high { color: var(--red); }
.diff-mid  { color: var(--muted); }

.sh-p-badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255,255,255,0.06);
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
}

#sh-maps {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.15s;
  margin-top: 4px;
}

#sh-maps:active { opacity: 0.7; }

/* ── OVERLAY POSIZIONE ── */
#loc-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  text-align: center;
}

.ov-icon { font-size: 52px; margin-bottom: 28px; }

.ov-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.ov-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 36px;
  max-width: 260px;
}

#allow-btn {
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: 50px;
  padding: 16px 0;
  width: 100%;
  max-width: 280px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 14px;
  transition: opacity 0.15s;
}

#allow-btn:active { opacity: 0.85; }

#skip-btn {
  background: none;
  border: none;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
}

/* ── TOAST ── */
#toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 9px 18px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  z-index: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── DESKTOP ── */
@media (min-width: 700px) {
  #sheet {
    left: auto;
    width: 360px;
    right: 20px;
    bottom: -100%;
    border-radius: 20px;
    border: 1px solid var(--border);
    max-height: 80vh;
  }
  #sheet.open { bottom: 20px; }

  #bar {
    left: 20px;
    right: auto;
    bottom: 20px;
    width: 280px;
    border-radius: 16px;
    border: 1px solid var(--border);
  }

  #locate-btn { bottom: 80px; }
}
