/* Jaipur BTL Micro-Catchment — mobile-first. Map fills viewport; everything else
   floats over it. Designed for ≥360px width, readable on 4G mid-range Android. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1f2937;
  overflow: hidden;
}
#map { position: absolute; inset: 0; }

/* ---- Top bar ---- */
#topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.12);
  flex-wrap: wrap;
}
.brand {
  font-weight: 800; font-size: 14px; color: #1A3C6B; line-height: 1; white-space: nowrap;
}
.brand-sub {
  display: block; font-size: 9px; font-weight: 700; letter-spacing: 0.08em;
  color: #E8651A; text-transform: uppercase;
}
#store-select {
  flex: 1 1 160px; min-width: 140px;
  padding: 9px 10px; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: #1f2937;
}
.toggles { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 9px; font-size: 12px; font-weight: 600;
  background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 999px; cursor: pointer;
  user-select: none;
}
.chip input { margin: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.temple { background: #E8651A; }
.dot.park { background: #2e9e4f; }

/* ---- Subtle legend: a thin density gradient bar ---- */
#legend {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 4;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4px);
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.82); border-radius: 999px; padding: 4px 10px;
  font-size: 10px; color: #64748b; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
.legend-cap { white-space: nowrap; font-weight: 600; }
#legend-bar {
  width: 90px; height: 7px; border-radius: 4px;
  background: linear-gradient(90deg, #ffffb2, #fed976, #feb24c, #fd8d3c, #f03b20, #bd0026);
}
.dot.density { background: linear-gradient(135deg, #fed976, #bd0026); }
.dot.photo { background: #ff1744; }

/* ---- Camera FAB (replaces Suggest-POI) ---- */
#camera-btn {
  position: absolute; right: 12px; z-index: 5;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 150px);
  width: 46px; height: 46px; font-size: 21px; line-height: 1;
  background: #fff; color: #1A3C6B; border: 1px solid #e2e8f0; border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
#camera-btn:active { background: #f1f5f9; }

/* ---- Tap action popup + marker image popup ---- */
.tap-pop .maplibregl-popup-content,
.img-pop .maplibregl-popup-content { padding: 10px 12px; }
.tp-info { font-weight: 800; color: #1A3C6B; font-size: 14px; margin-bottom: 8px; }
.tp-actions { display: flex; gap: 6px; }
.tp-actions button {
  flex: 1; padding: 8px 6px; font-size: 12px; font-weight: 700; cursor: pointer;
  border-radius: 7px; border: 1px solid #e2e8f0; background: #f8fafc; color: #1A3C6B; white-space: nowrap;
}
.tp-actions button.primary { background: #1A3C6B; color: #fff; border-color: #1A3C6B; }
.img-pop img { display: block; width: 200px; max-width: 60vw; border-radius: 8px; }
.img-pop .img-cap { font-size: 11px; color: #64748b; margin-top: 5px; }
.img-pop .img-dir { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 700; color: #1A3C6B; cursor: pointer; }
#camera-btn.busy { opacity: 0.6; pointer-events: none; }

/* ---- Stats panel (bottom sheet) ---- */
#stats {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
  background: #fff; border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 14px rgba(0, 0, 0, 0.18);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: transform 0.25s ease;
}
#stats.collapsed #stats-body { display: none; }
#stats.collapsed #stats-chevron { transform: rotate(180deg); }
#stats-handle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px; background: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 800; color: #1A3C6B;
}
#stats-handle::before {
  content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%);
  width: 36px; height: 4px; border-radius: 2px; background: #cbd5e1;
}
#stats-chevron { color: #94a3b8; font-size: 16px; transition: transform 0.2s; }
#stats-body { padding: 0 16px 16px; max-height: 46vh; overflow-y: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: #f8fafc; border: 1px solid #eef2f7; border-radius: 10px; padding: 9px 6px; text-align: center; }
.stat-num { font-size: 18px; font-weight: 800; color: #1A3C6B; line-height: 1.1; }
.stat-lbl { font-size: 10px; color: #64748b; margin-top: 3px; line-height: 1.25; }
.stat-lbl em { color: #94a3b8; font-style: normal; }

.dense-head { font-size: 12px; font-weight: 800; color: #E8651A; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 6px; }
#dense-list { list-style: none; margin: 0; padding: 0; }
#dense-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 10px; margin-bottom: 5px;
  background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px;
  font-size: 13px; cursor: pointer;
}
#dense-list li:active { background: #ffedd5; }
#dense-list .rank { font-weight: 800; color: #E8651A; margin-right: 8px; }
#dense-list .dl-pop { font-weight: 700; color: #1A3C6B; white-space: nowrap; }
#dense-list .dl-hh { font-size: 11px; color: #64748b; }

/* ---- Hint / empty state ---- */
#hint {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 3;
  background: rgba(26, 60, 107, 0.92); color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-align: center; max-width: 80%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.hidden { display: none !important; }

/* ---- Add/Edit store ---- */
#add-store-btn {
  flex: 0 0 auto; padding: 9px 11px; font-size: 13px; font-weight: 700;
  background: #1A3C6B; color: #fff; border: none; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.edit-store { width: 100%; margin-bottom: 12px; }

#store-modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-card {
  background: #fff; border-radius: 14px; width: 100%; max-width: 360px;
  padding: 18px 18px 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}
.modal-title { font-size: 16px; font-weight: 800; color: #1A3C6B; margin-bottom: 14px; }
.fld { display: block; font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 12px; }
.fld input {
  display: block; width: 100%; margin-top: 5px; padding: 10px;
  font-size: 15px; font-weight: 400; color: #1f2937;
  border: 1px solid #cbd5e1; border-radius: 8px; background: #fff;
}
.fld input:focus { outline: none; border-color: #1A3C6B; box-shadow: 0 0 0 3px rgba(26, 60, 107, 0.12); }
.fld-row { display: flex; gap: 10px; }
.fld-row .fld { flex: 1; }
.sf-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 12px; padding: 8px 10px; border-radius: 8px; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.ghost-btn {
  padding: 10px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
  background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; border-radius: 8px;
}
.primary-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 700; cursor: pointer;
  background: #1A3C6B; color: #fff; border: none; border-radius: 8px;
}
.primary-btn:disabled { opacity: 0.6; cursor: default; }
#sf-use-center { width: 100%; margin-bottom: 12px; }

/* ---- MapLibre popups ---- */
.maplibregl-popup-content { font-size: 13px; padding: 9px 12px; border-radius: 8px; }
.popup-title { font-weight: 800; color: #1A3C6B; margin-bottom: 2px; }
.popup-sub { color: #64748b; font-size: 12px; }
.popup-pop { font-weight: 700; color: #bd0026; }

/* ---- Desktop: stats becomes a floating card, legend repositions ---- */
@media (min-width: 760px) {
  #stats {
    left: auto; right: 10px; bottom: 10px; width: 340px; border-radius: 14px;
  }
  #stats-handle::before { display: none; }
  #suggest-poi { bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); right: 360px; }
  #stats-body { max-height: 60vh; }
}
