/* ============================================================
   India Heat Pump Alliance — Installation Dashboard
   Design language: "thermal imaging" — the map itself reads like
   a thermal camera view, cool blue -> amber -> hot red mapped to
   installed capacity, tying the visual directly to the subject.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --bg:          #0d1a1b;
  --panel:       #142728;
  --panel-alt:   #1a3234;
  --line:        #24413f;
  --text:        #eaf2f1;
  --text-muted:  #8fa8a6;
  --cool:        #3fa7d6;
  --warm:        #e8873a;
  --hot:         #e0483e;
  --good:        #59b98a;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cool); }

/* ---------------- Layout shell ---------------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #0f2021 0%, #0d1a1b 100%);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand__mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cool), var(--warm) 60%, var(--hot));
  flex-shrink: 0;
}

.brand__text h1 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.01em;
}

.brand__text p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 rgba(89,185,138,0.7);
  animation: pulse 2s infinite;
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(89,185,138,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(89,185,138,0); }
  100% { box-shadow: 0 0 0 0 rgba(89,185,138,0); }
}

.container {
  padding: 20px 28px 48px;
  max-width: 1500px;
  margin: 0 auto;
}

/* ---------------- Filters ---------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
  align-items: center;
}

.filters select,
.filters input {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: var(--font-body);
  font-size: 0.82rem;
}

.filters select:focus,
.filters input:focus {
  outline: 2px solid var(--cool);
  outline-offset: 1px;
}

.filters label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.btn:hover { border-color: var(--cool); }
.btn:focus-visible { outline: 2px solid var(--cool); outline-offset: 2px; }

/* ---------------- KPI row ---------------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--cool));
}

.kpi-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 600;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------------- Main grid ---------------- */

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
  gap: 18px;
}

@media (max-width: 980px) {
  .main-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0 0 4px;
}

.panel .panel-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 14px;
}

/* ---------------- Map (Leaflet) ---------------- */

#leaflet-map {
  width: 100%;
  height: 520px;
  border-radius: 10px;
  background: var(--panel-alt);
}

.hp-pin-icon {
  background: none;
  border: none;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.45));
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-note {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* Leaflet chrome restyled to match the dark "thermal" theme */

.leaflet-container {
  background: var(--panel-alt);
  font-family: var(--font-body);
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
}

.leaflet-popup-content {
  font-size: 0.82rem;
  margin: 10px 12px;
}

.pin-popup strong { font-family: var(--font-display); }
.pin-popup__sector { color: var(--text-muted); font-size: 0.75rem; margin: 2px 0 6px; }
.pin-popup ul { list-style: none; margin: 0 0 8px; padding: 0; font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.6; }
.pin-popup__btn { padding: 6px 10px; font-size: 0.75rem; }

.leaflet-control-attribution {
  background: rgba(13,26,27,0.75) !important;
  color: var(--text-muted) !important;
}
.leaflet-control-attribution a { color: var(--cool) !important; }

.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--line) !important;
}
.leaflet-bar a:hover { background: var(--panel-alt) !important; }

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(63,167,214,0.35);
}
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(63,167,214,0.7);
  color: #fff;
}

/* ---------------- Side panel (state detail) ---------------- */

#state-panel .state-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  margin: 0 0 2px;
}

#state-panel .state-region {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stat-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-list li {
  background: var(--panel-alt);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-list .stat-num {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  display: block;
}

.stat-list .stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.74rem;
  margin: 0 6px 6px 0;
}

.tier-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.tier-Platinum { background: #cfd8e3; }
.tier-Gold { background: #e8c34a; }
.tier-Silver { background: #a9b6b5; }
.tier-Associate { background: var(--cool); }

.empty-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 30px 10px;
  text-align: center;
}

/* ---------------- Charts row ---------------- */

.charts-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .charts-row { grid-template-columns: 1fr; }
}

canvas { max-width: 100%; }

/* ---------------- Table ---------------- */

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

thead th {
  text-align: left;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
}

tbody tr:hover { background: var(--panel-alt); }

.status-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-family: var(--font-body);
}
.status-Commissioned { background: rgba(89,185,138,0.18); color: var(--good); }
.status-InProgress   { background: rgba(232,135,58,0.18); color: var(--warm); }
.status-Planned      { background: rgba(63,167,214,0.18); color: var(--cool); }

footer.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 24px;
}
