/* ============================================================
   ChandaWatch — Map Page  (Professional Light)
   ============================================================ */

/* ── Page shell ─────────────────────────────────────────────── */
.map-page {
  display: flex;
  height: 100vh;
  padding-top: var(--header-h);
  background: #f0f2f5;
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────────────────────────── */
.sidebar {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-right: 1px solid #e5e9ef;
  overflow: hidden;
  z-index: 10;
  box-shadow: 2px 0 16px rgba(0,0,0,0.06);
}

/* Header */
.sidebar-header {
  padding: 16px 16px 12px;
  background: #fff;
  border-bottom: 1px solid #eef0f3;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-toprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-title {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 700;
  color: #9ca3af;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#report-count-label {
  font-size: 0.72rem;
  color: #9ca3af;
  font-weight: 500;
}

/* Search */
.search-box { position: relative; }
.search-box .search-icon {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 0.85rem;
  pointer-events: none;
}
.search-box input {
  padding-left: 34px;
  background: #f8f9fb;
  border: 1px solid #e5e9ef;
  border-radius: 8px;
  font-size: 0.86rem;
  height: 38px;
}
.search-box input:focus { background: #fff; border-color: #d63031; box-shadow: 0 0 0 3px rgba(214,48,49,0.08); }

/* ── Filter Panel ─────────────────────────────────────────── */
.filter-panel {
  padding: 10px 14px;
  border-bottom: 1px solid #eef0f3;
  background: #fafbfc;
}
.filter-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 2px 0;
}
.filter-toggle-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: #6b7280;
}
.filter-body { padding-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.filter-body.collapsed { display: none; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.sort-tabs {
  display: flex;
  gap: 3px;
  background: #f0f2f5;
  padding: 3px;
  border-radius: 8px;
}
.sort-tab {
  flex: 1;
  padding: 5px 4px;
  font-size: 0.71rem;
  font-weight: 600;
  color: #9ca3af;
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-bn);
  transition: all 0.15s;
}
.sort-tab.active {
  background: #fff;
  color: #1a1d23;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.view-toggle { display: flex; gap: 6px; }
.view-btn {
  flex: 1; padding: 7px;
  font-size: 0.78rem; font-weight: 600;
  color: #6b7280; background: #fff;
  border: 1.5px solid #e5e9ef;
  border-radius: 8px; cursor: pointer;
  font-family: var(--font-bn);
  transition: all 0.15s;
}
.view-btn.active { background: #fff1f0; color: #d63031; border-color: #d63031; }

/* ── Report List ─────────────────────────────────────────── */
.report-list { flex: 1; overflow-y: auto; padding: 10px 10px 0; background: #f8f9fb; }
.report-list::-webkit-scrollbar { width: 4px; }
.report-list::-webkit-scrollbar-track { background: transparent; }
.report-list::-webkit-scrollbar-thumb { background: #dde1e7; border-radius: 4px; }

.report-card {
  background: #fff;
  border: 1.5px solid #eef0f3;
  border-radius: 10px;
  padding: 12px 14px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
/* Left status stripe */
.report-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.report-card[data-status="verified"]::before     { background: #00b894; }
.report-card[data-status="published"]::before    { background: #0984e3; }
.report-card[data-status="disputed"]::before     { background: #d63031; }
.report-card[data-status="locked"]::before       { background: #e17055; }
.report-card[data-status="under_review"]::before { background: #b2bec3; }

.report-card:hover { border-color: #d1d5db; box-shadow: 0 4px 16px rgba(0,0,0,0.07); transform: translateY(-1px); }
.report-card.active { border-color: #d63031; background: #fffafa; box-shadow: 0 4px 16px rgba(214,48,49,0.1); }

.rc-top { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 7px; }
.rc-left { flex: 1; min-width: 0; }
.rc-right { flex-shrink: 0; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.rc-ref { font-family: var(--font-ui); font-size: 0.62rem; font-weight: 700; color: #b2bec3; letter-spacing: 0.08em; margin-bottom: 2px; }
.rc-area { font-size: 0.9rem; font-weight: 600; color: #1a1d23; line-height: 1.3; margin-bottom: 3px; }
.rc-meta { font-size: 0.72rem; color: #9ca3af; }
.rc-amount { font-family: var(--font-ui); font-size: 0.92rem; font-weight: 700; color: #e17055; white-space: nowrap; }
.rc-desc {
  font-size: 0.8rem; color: #6b7280; line-height: 1.55;
  overflow: hidden; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  margin-bottom: 8px;
}
.rc-votes { display: flex; gap: 6px; }
.rv {
  font-size: 0.69rem; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
}
.rv.confirm { background: #e6faf6; color: #00b894; }
.rv.dispute { background: #fef0f0; color: #d63031; }

.list-empty { padding: 48px 20px; text-align: center; color: #9ca3af; }
.list-empty p { font-size: 0.84rem; margin-top: 8px; }

/* ─────────────────────────────────────────────────────────────
   MAP
───────────────────────────────────────────────────────────── */
.map-wrap { flex: 1; position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; background: #e8eaed; }

/* Leaflet control overrides */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12) !important;
  border-radius: 10px !important;
  overflow: hidden;
  margin-right: 14px !important;
  margin-bottom: 14px !important;
}
.leaflet-control-zoom a {
  background: #fff !important;
  color: #374151 !important;
  border: none !important;
  border-bottom: 1px solid #f0f2f5 !important;
  font-size: 1.1rem !important;
  line-height: 32px !important;
  width: 34px !important;
  height: 34px !important;
}
.leaflet-control-zoom a:last-child { border-bottom: none !important; }
.leaflet-control-zoom a:hover { background: #f8f9fb !important; }
.leaflet-control-attribution {
  background: rgba(255,255,255,0.82) !important;
  font-size: 9px !important;
  border-radius: 6px 0 0 0 !important;
  color: #9ca3af !important;
}

/* ── Popup ──────────────────────────────────────────────────── */
.cw-popup .leaflet-popup-content-wrapper {
  background: #fff;
  border: none;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.14), 0 1px 4px rgba(0,0,0,0.06);
  padding: 0;
  overflow: hidden;
}
.cw-popup .leaflet-popup-content { margin: 0 !important; }
.cw-popup .leaflet-popup-tip { background: #fff !important; box-shadow: none !important; }

.cw-popup-inner { padding: 14px 16px; min-width: 180px; }
.cp-tag {
  font-size: 0.63rem; font-weight: 700; color: #9ca3af;
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 3px;
}
.cp-area { font-size: 0.9rem; font-weight: 700; color: #1a1d23; margin-bottom: 4px; line-height: 1.3; }
.cp-amount { font-family: var(--font-ui); font-size: 1.1rem; font-weight: 700; color: #e17055; margin-bottom: 10px; }
.cp-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 9px; border-top: 1px solid #f0f2f5; font-size: 0.72rem;
}
.cp-footer span:first-child { color: #9ca3af; }
.cp-link { color: #d63031; font-weight: 700; cursor: pointer; }
.cp-link:hover { text-decoration: underline; }

/* ── Stats pill ──────────────────────────────────────────────── */
.map-stats {
  position: absolute;
  top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 500;
  background: rgba(255,255,255,0.96);
  border: 1px solid #e5e9ef;
  border-radius: 99px;
  padding: 8px 24px;
  display: flex;
  gap: 28px;
  box-shadow: 0 2px 14px rgba(0,0,0,0.09);
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
.map-stat { display: flex; align-items: center; gap: 8px; }
.map-stat-num {
  font-family: var(--font-ui); font-size: 1rem; font-weight: 700; color: #1a1d23;
}
.map-stat-label { font-size: 0.7rem; color: #9ca3af; font-weight: 500; }
.map-stat + .map-stat { padding-left: 28px; border-left: 1px solid #e5e9ef; }

/* ── FAB ─────────────────────────────────────────────────────── */
.map-fab {
  position: absolute;
  bottom: 28px; right: 16px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.fab-report {
  display: flex; align-items: center; gap: 8px;
  background: #d63031; color: #fff;
  border: none; border-radius: 99px;
  padding: 13px 22px;
  font-size: 0.9rem; font-weight: 700;
  font-family: var(--font-bn); cursor: pointer;
  box-shadow: 0 4px 20px rgba(214,48,49,0.38);
  transition: all 0.2s;
}
.fab-report:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(214,48,49,0.48); background: #b71c1c; }

.fab-btn {
  width: 40px; height: 40px;
  background: #fff; border: 1px solid #e5e9ef;
  border-radius: 50%; color: #6b7280;
  font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: all 0.15s;
}
.fab-btn:hover { border-color: #b2bec3; color: #374151; }
.fab-btn.active { color: #d63031; border-color: #d63031; background: #fff1f0; }

/* ── Detail Panel ────────────────────────────────────────────── */
.detail-panel {
  position: absolute;
  top: 60px; left: 16px;
  width: 330px;
  background: #fff;
  border: 1px solid #e5e9ef;
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.13);
  z-index: 500;
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.detail-panel.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}
.detail-panel-header {
  background: linear-gradient(160deg, #fff 60%, #fef9f9 100%);
  padding: 16px 46px 14px 18px;
  border-bottom: 1px solid #f0f2f5;
}
.detail-ref {
  font-family: var(--font-ui); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.1em; color: #b2bec3; margin-bottom: 3px;
}
.detail-area {
  font-size: 1.05rem; font-weight: 700; color: #1a1d23;
  line-height: 1.3; margin-bottom: 8px;
}
.detail-amount-large {
  font-family: var(--font-ui); font-size: 1.6rem; font-weight: 700;
  color: #e17055; line-height: 1;
}

.detail-panel-body {
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 50vh;
  overflow-y: auto;
}
.detail-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.detail-meta-item {
  background: #f8f9fb;
  border-radius: 8px;
  padding: 8px 10px;
}
.detail-meta-label { font-size: 0.63rem; color: #9ca3af; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.detail-meta-value { font-size: 0.85rem; color: #1a1d23; font-weight: 600; }

.detail-desc {
  font-size: 0.84rem; color: #4b5563; line-height: 1.7;
  padding: 10px 12px;
  background: #f8f9fb;
  border-radius: 8px;
  border-left: 3px solid #e5e9ef;
}

.detail-votes-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.detail-vote-box {
  border-radius: 8px; padding: 10px; text-align: center;
}
.detail-vote-box.confirm { background: #e6faf6; border: 1px solid #b2dfdb; }
.detail-vote-box.dispute { background: #fef0f0; border: 1px solid #ffcdd2; }
.detail-vote-num { font-family: var(--font-ui); font-size: 1.4rem; font-weight: 700; display: block; }
.detail-vote-box.confirm .detail-vote-num { color: #00b894; }
.detail-vote-box.dispute .detail-vote-num { color: #d63031; }
.detail-vote-label { font-size: 0.68rem; color: #9ca3af; }

.detail-verify {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid #f0f2f5;
}
.verify-btn {
  padding: 10px; border-radius: 8px;
  font-size: 0.82rem; font-weight: 700;
  font-family: var(--font-bn);
  border: 1.5px solid; cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 5px;
}
.verify-btn.confirm { background: #e6faf6; color: #00b894; border-color: #b2dfdb; }
.verify-btn.confirm:hover { background: #00b894; color: #fff; }
.verify-btn.dispute { background: #fef0f0; color: #d63031; border-color: #ffcdd2; }
.verify-btn.dispute:hover { background: #d63031; color: #fff; }

.detail-close {
  position: absolute; top: 14px; right: 14px;
  width: 26px; height: 26px;
  background: #f0f2f5; border: none;
  border-radius: 50%; color: #6b7280;
  font-size: 0.75rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.detail-close:hover { background: #e5e9ef; color: #1a1d23; }

/* ── Loading ─────────────────────────────────────────────────── */
#app-loading {
  position: fixed; inset: 0;
  background: #f5f6f8;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 16px;
  z-index: 9999;
  transition: opacity 0.5s;
}
#app-loading.hidden { opacity: 0; pointer-events: none; }
.loading-logo { font-size: 2.5rem; animation: ldpulse 1.2s ease-in-out infinite; }
.loading-text { font-family: 'Syne', sans-serif; font-size: 0.95rem; color: #9ca3af; }
@keyframes ldpulse { 0%,100%{opacity:0.4;transform:scale(0.94)} 50%{opacity:1;transform:scale(1)} }

/* ── Mobile overlay & toggle ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 450;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.sidebar-toggle { display: none; }

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar-toggle {
    display: flex; align-items: center; gap: 8px;
    position: fixed;
    top: calc(var(--header-h) + 10px); left: 10px;
    z-index: 600;
    background: #fff; border: 1px solid #e5e9ef;
    border-radius: 10px; padding: 9px 14px;
    color: #374151; font-size: 0.85rem; font-weight: 700;
    font-family: var(--font-bn); cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
  }
  .sidebar {
    position: fixed !important;
    top: var(--header-h) !important; left: 0 !important; bottom: 0 !important;
    width: 88vw !important; max-width: 340px !important;
    z-index: 500 !important;
    transform: translateX(-110%) !important;
    transition: transform 0.26s cubic-bezier(0.4,0,0.2,1) !important;
    box-shadow: 8px 0 40px rgba(0,0,0,0.15) !important;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .map-wrap { flex: 1 !important; width: 100% !important; }
  .map-stats {
    top: auto !important; left: 10px !important; right: 10px !important;
    bottom: 90px !important; transform: none !important;
    border-radius: 12px !important; padding: 8px 14px !important;
    gap: 14px !important; justify-content: space-around;
  }
  .map-stat + .map-stat { padding-left: 14px; }
  .detail-panel {
    top: calc(var(--header-h) + 10px) !important;
    left: 10px !important; right: 10px !important;
    width: auto !important; max-height: 72vh; overflow-y: auto;
  }
  .map-fab { bottom: 20px; right: 12px; }
  .fab-report { font-size: 0.85rem; padding: 11px 16px; }
}