/* Tollvera Fuel Network — mobile-first dark map UI */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  background: #0a0a0a; color: #fff;
  -webkit-tap-highlight-color: transparent;
}
#map { position: fixed; inset: 0; z-index: 1; }
.leaflet-container { background: #0a0a0a; font: inherit; }

/* ── Top bar ─────────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 10px;
  background: linear-gradient(180deg, rgba(10,10,10,0.92), rgba(10,10,10,0.55) 70%, transparent);
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

#brandlock { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
#brandmark {
  width: 38px; height: 38px; border-radius: 11px;
  background: #fff; padding: 4px; object-fit: contain;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
#brandtext { display: none; }
#brandtext b { display: block; font-size: 15px; letter-spacing: 0.04em; }
#brandtext span { font-size: 10.5px; color: #999; }

#searchwrap {
  position: relative; flex: 1; max-width: 520px; margin-left: auto;
  display: flex; align-items: center;
}
#searchicon {
  position: absolute; left: 13px; width: 16px; height: 16px;
  color: #888; pointer-events: none;
}
#search {
  width: 100%; height: 44px;
  background: rgba(18,18,20,0.92); backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px; padding: 0 40px 0 38px;
  color: #fff; font-size: 15px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus { border-color: rgba(230,57,70,0.6); box-shadow: 0 0 0 3px rgba(230,57,70,0.18); }
#search::placeholder { color: #777; }
#search::-webkit-search-cancel-button { display: none; }
#clearsearch {
  position: absolute; right: 8px; width: 28px; height: 28px;
  border: 0; border-radius: 50%; background: rgba(255,255,255,0.1);
  color: #bbb; font-size: 18px; line-height: 1; cursor: pointer;
}

/* Search results dropdown */
#results {
  position: absolute; top: 50px; left: 0; right: 0;
  background: rgba(16,16,18,0.97); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px; overflow: hidden auto;
  max-height: min(52vh, 380px);
  box-shadow: 0 14px 44px rgba(0,0,0,0.65);
}
.rrow {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.rrow:last-child { border-bottom: 0; }
.rrow:active, .rrow:hover { background: rgba(255,255,255,0.06); }
.rrow img {
  width: 30px; height: 30px; border-radius: 8px; background: #fff;
  object-fit: contain; padding: 2px; flex-shrink: 0;
}
.rrow .rtxt { min-width: 0; flex: 1; }
.rrow .rname {
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.rrow .raddr { font-size: 11.5px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow .rbrand { font-size: 10px; font-weight: 700; color: #888; text-transform: uppercase; letter-spacing: 0.06em; flex-shrink: 0; }
.rnone { padding: 16px; text-align: center; color: #888; font-size: 13px; }

/* ── Stats pill ──────────────────────────────────────────── */
#statpill {
  position: fixed; z-index: 900;
  top: calc(env(safe-area-inset-top, 0px) + 64px); left: 12px;
  background: rgba(16,16,18,0.85); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 999px; padding: 6px 13px;
  font-size: 11.5px; color: #aaa;
}
#statpill b { color: #fff; font-weight: 700; }

/* ── Locate button ───────────────────────────────────────── */
#locate {
  position: fixed; z-index: 900; right: 12px;
  bottom: 148px;
  width: 46px; height: 46px; border-radius: 14px;
  background: rgba(16,16,18,0.92); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  transition: background .15s;
}
#locate svg { width: 21px; height: 21px; }
#locate:active { background: rgba(230,57,70,0.85); }
#locate.searching { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ── Bottom sheet ────────────────────────────────────────── */
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 950;
  background: rgba(14,14,16,0.94); backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.09);
  border-radius: 20px 20px 0 0;
  padding: 8px 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  transition: transform .28s cubic-bezier(.32,.72,.35,1);
}
#sheet.collapsed { transform: translateY(calc(100% - 64px - env(safe-area-inset-bottom, 0px))); }
#grabber {
  width: 40px; height: 5px; border-radius: 999px;
  background: rgba(255,255,255,0.22); margin: 2px auto 8px;
}
#sheethead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
#sheettitle { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
#activecount { font-size: 11px; color: #888; flex: 1; }
#allbrands {
  border: 1px solid rgba(255,255,255,0.14); background: rgba(255,255,255,0.07);
  color: #ddd; font-size: 11px; font-weight: 600;
  padding: 5px 12px; border-radius: 999px; cursor: pointer;
}
#chips {
  display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
#chips::-webkit-scrollbar { display: none; }
.chip {
  display: flex; align-items: center; gap: 7px; flex-shrink: 0;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px; padding: 5px 11px 5px 5px;
  cursor: pointer; user-select: none; transition: all .15s;
}
.chip img {
  width: 26px; height: 26px; border-radius: 50%;
  background: #fff; object-fit: contain; padding: 2px;
}
.chip .cname { font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip .ccount { font-size: 10.5px; color: #888; }
.chip.off { opacity: 0.32; filter: grayscale(0.7); }
.chip:active { transform: scale(0.95); }

/* ── Attribution ─────────────────────────────────────────── */
#attribution {
  position: fixed; z-index: 900; right: 8px; bottom: 8px;
  font-size: 9px; color: #555; pointer-events: none;
  display: none;
}
.leaflet-control-attribution {
  background: rgba(10,10,10,0.6) !important; color: #666 !important;
  font-size: 9px !important; padding: 1px 6px;
}
.leaflet-control-attribution a { color: #888 !important; }
.leaflet-control-zoom {
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 12px !important; overflow: hidden;
  margin-bottom: 150px !important; margin-right: 12px !important;
}
.leaflet-control-zoom a {
  background: rgba(16,16,18,0.92) !important; color: #fff !important;
  border-bottom: 1px solid rgba(255,255,255,0.08) !important;
  width: 40px !important; height: 40px !important; line-height: 40px !important;
}

/* ── Brand logo markers ──────────────────────────────────── */
.logo-marker { background: none; border: none; }
.logo-marker .lm-pin {
  width: 34px; height: 34px; border-radius: 50%;
  background: #fff; padding: 3px;
  border: 2.5px solid var(--bc, #E63946);
  box-shadow: 0 2px 10px rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.logo-marker .lm-pin img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; }
.logo-marker .lm-pin:active { transform: scale(1.15); }

/* Clusters */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background: rgba(230,57,70,0.2) !important; background-clip: padding-box;
}
.marker-cluster div {
  background: #E63946 !important; color: #fff !important;
  font-weight: 700; font-size: 12.5px;
  box-shadow: 0 2px 10px rgba(230,57,70,0.4);
}

/* Popup */
.leaflet-fade-anim .leaflet-popup,
.leaflet-fade-anim .leaflet-tooltip { transition: none !important; }
.leaflet-popup-content-wrapper {
  background: #121214 !important; color: #fff !important;
  border-radius: 16px !important; border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 12px 40px rgba(0,0,0,0.6) !important;
}
.leaflet-popup-tip { background: rgba(18,18,20,0.97) !important; }
.leaflet-popup-content { margin: 13px 15px !important; }
.pop { min-width: 190px; }
.pop .phead { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.pop .phead img {
  width: 36px; height: 36px; border-radius: 9px;
  background: #fff; object-fit: contain; padding: 3px; flex-shrink: 0;
}
.pop .pname { font-size: 13.5px; font-weight: 700; line-height: 1.25; }
.pop .pbrand { font-size: 10px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; margin-top: 2px; }
.pop .paddr { font-size: 12px; color: #aaa; line-height: 1.45; }
.pop .pnav {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  background: #E63946; color: #fff; text-decoration: none;
  font-size: 12px; font-weight: 700; padding: 8px 14px; border-radius: 10px;
}
.leaflet-popup-close-button { color: #888 !important; }

/* Dark basemap: free OSM tiles, inverted via CSS */
.leaflet-tile-pane .leaflet-tile {
  filter: invert(100%) hue-rotate(180deg) brightness(0.95) contrast(0.88) saturate(0.32);
}

/* ── Desktop / larger screens ────────────────────────────── */
@media (min-width: 720px) {
  #brandtext { display: block; }
  #topbar { padding: calc(env(safe-area-inset-top, 0px) + 14px) 20px 14px; }
  #sheet {
    left: 20px; right: auto; bottom: 20px; width: 460px;
    border-radius: 20px; border: 1px solid rgba(255,255,255,0.09);
  }
  #sheet.collapsed { transform: translateY(calc(100% - 60px)); }
  #grabber { display: none; }
  #locate { bottom: auto; top: calc(env(safe-area-inset-top, 0px) + 70px); }
  .leaflet-control-zoom { margin-bottom: 20px !important; }
  #statpill { top: calc(env(safe-area-inset-top, 0px) + 72px); left: 20px; }
}
