/* ── Base ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #0f172a;
  color: #f1f5f9;
  height: 100dvh;
  overflow: hidden;
}

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

/* ── Topbar ───────────────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  z-index: 1100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #f1f5f9;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}
.topbar-logo-img { width: 26px; height: 26px; border-radius: 6px; }
.topbar-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #94a3b8;
}
.topbar-actions { display: flex; gap: 6px; flex-shrink: 0; }
.topbar-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 8px;
  color: #f1f5f9;
  width: 34px;
  height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.topbar-btn:hover { background: rgba(255,255,255,0.18); }

/* ── Lot-type filter chips ────────────────────────────────────────────────── */
.lot-type-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.lot-type-strip::-webkit-scrollbar { display: none; }

.lot-btn {
  border: none;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: rgba(255,255,255,0.1);
  color: #cbd5e1;
  transition: background .15s;
}
.lot-btn.active { background: #e2e8f0; color: #0f172a; }
.lot-btn[data-lot="C"].active  { background: #3b82f6; color: #fff; }
.lot-btn[data-lot="M"].active  { background: #8b5cf6; color: #fff; }
.lot-btn[data-lot="H"].active  { background: #f97316; color: #fff; }
.lot-btn[data-lot="Y"].active  { background: #10b981; color: #fff; }

/* ── Panel ────────────────────────────────────────────────────────────────── */
.panel {
  position: fixed;
  top: 52px;
  right: 0;
  bottom: 0;
  width: 360px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transform: translateX(0);
  transition: transform .3s ease;
}
.panel.hidden { transform: translateX(100%); }

.panel-header {
  padding: 12px 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.panel-close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 6px;
}
.panel-close {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 4px;
}
.panel-close:hover { color: #f1f5f9; }

.panel-tabs {
  display: flex;
  gap: 4px;
  padding-bottom: 10px;
}
.ptab {
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.ptab:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.ptab.active { background: rgba(255,255,255,0.12); color: #f1f5f9; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Panel open button ────────────────────────────────────────────────────── */
.panel-open-btn {
  position: fixed;
  top: 62px;
  right: 12px;
  z-index: 1049;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  color: #f1f5f9;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: none;
}
.panel-open-btn.visible { display: block; }

/* ── Carpark cards ────────────────────────────────────────────────────────── */
.cp-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s;
}
.cp-card:hover { background: rgba(255,255,255,0.09); }
.cp-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.cp-name { font-size: 12px; font-weight: 700; color: #e2e8f0; flex: 1; }
.cp-avail {
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}
.cp-avail.high  { color: #22c55e; }
.cp-avail.med   { color: #facc15; }
.cp-avail.low   { color: #f97316; }
.cp-avail.none  { color: #ef4444; }
.cp-meta { font-size: 11px; color: #64748b; }

/* Availability bar */
.cp-bar-bg {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.cp-bar-fill { height: 100%; border-radius: 2px; transition: width .3s; }

/* ── Summary bar ──────────────────────────────────────────────────────────── */
.summary-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.summary-stat {
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 8px 12px;
  flex: 1;
  min-width: 70px;
  text-align: center;
}
.summary-stat .val { font-size: 18px; font-weight: 800; color: #22d3ee; }
.summary-stat .lbl { font-size: 10px; color: #64748b; margin-top: 2px; }

/* ── Loading / empty states ───────────────────────────────────────────────── */
.pane-loading {
  font-size: 12px;
  color: #64748b;
  padding: 16px 0;
  text-align: center;
}

.cp-count {
  font-size: 11px;
  color: #64748b;
  margin-bottom: 10px;
}

/* ── Map legend ───────────────────────────────────────────────────────────── */
.map-legend {
  position: fixed;
  bottom: 90px;
  left: 12px;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.8;
}
.legend-row { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ── Leaflet overrides ────────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.96) !important;
  color: #f1f5f9 !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5) !important;
  min-width: 180px;
}
.leaflet-popup-content { margin: 12px 14px !important; }
.leaflet-popup-tip { background: rgba(15, 23, 42, 0.96) !important; }
.leaflet-popup-close-button { color: #94a3b8 !important; }
.leaflet-popup-close-button:hover { color: #f1f5f9 !important; }

.popup-cp-name { font-size: 13px; font-weight: 700; color: #e2e8f0; margin-bottom: 6px; }
.popup-cp-row { display: flex; justify-content: space-between; font-size: 11px; color: #94a3b8; margin-bottom: 2px; }
.popup-cp-val { color: #22d3ee; font-weight: 700; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .panel { width: 100%; top: 52px; }
  .topbar-title { display: none; }
}
