/* ── Modul Ekonomi (Teras 3) — Peta Analisis ──────────────────────────
   Melanjutkan peta.css: susun atur tiga lajur (kawalan · peta · profil),
   jadual firma, kad profil daerah dan bahagian metodologi.
   ------------------------------------------------------------------- */

/* ── Susun atur utama ─────────────────────────────────────────────── */
.eko-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr) 300px;
  gap: 14px;
  height: clamp(520px, calc(100vh - 340px), 760px);
}
.eko-shell .peta-panel,
.eko-shell .info-panel {
  overflow-y: auto;
  overflow-x: hidden;
}
.info-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.eko-shell .peta-map-wrap { height: 100%; }
#eko-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--surface-2);
}

@media (max-width: 1280px) {
  /* Panel profil berpindah ke baris kedua — tinggi tetap dilepaskan supaya
     baris peta tidak dihimpit menjadi jalur nipis. */
  .eko-shell {
    grid-template-columns: 232px minmax(0, 1fr);
    grid-template-rows: minmax(420px, 58vh) auto;
    height: auto;
  }
  .eko-shell .info-panel { grid-column: 1 / -1; max-height: 340px; }
}
@media (max-width: 860px) {
  .eko-shell { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  .eko-shell .peta-map-wrap { height: 460px; }
  .eko-shell .peta-panel { max-height: 340px; }
}

/* ── Kawalan panel kiri ───────────────────────────────────────────── */
.eko-mod { flex-wrap: wrap; }
.pp-mini {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 10px;
  letter-spacing: .4px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}
.pp-mini:hover { text-decoration: underline; }
.pp-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.eko-medan { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.eko-medan > span {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 700;
  color: var(--ink-3);
}
.eko-medan.tumbuh { flex: 1 1 220px; }
.eko-medan select,
.eko-medan input {
  width: 100%;
  padding: 7px 9px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.eko-medan select:focus-visible,
.eko-medan input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

/* ── Legenda hexbin di atas peta ──────────────────────────────────── */
.eko-legend {
  position: absolute;
  left: 12px;
  bottom: 34px;
  z-index: 2;
  width: 158px;
  padding: 9px 11px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.eko-legend .tl {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.eko-legend .ramp {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #ffffb2, #fed976, #fd8d3c, #bd0026);
}
.eko-legend .ramp-lbl {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 3px;
}

.eko-lq-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.eko-lq-legend span {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.eko-lq-legend.kecil span { font-size: 10px; padding: 2px 7px; }

/* ── Popup firma ──────────────────────────────────────────────────── */
.peta-pop-row > span { color: var(--ink-3); }
.peta-pop-row > b { color: var(--ink-2); font-weight: 600; text-align: right; }
.peta-pop-nota {
  display: block;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--ink-3);
  font-style: italic;
}

/* ── Profil daerah ────────────────────────────────────────────────── */
.ip-pilih {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.ip-hint {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 8px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-3);
}
.ip-hint-ikon {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, .16);
}
/* Isyarat halus semasa profil ditukar melalui HTMX. */
#profil-daerah { transition: opacity .15s ease; }
#profil-daerah.ip-muat { opacity: .4; }

.eko-profil-head .kod {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .7px;
  font-weight: 700;
  color: var(--primary);
}
.eko-profil-head h3 { font-size: 16px; margin: 3px 0 4px; color: var(--ink); }
.eko-profil-stat {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.eko-profil-stat > div {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}
.eko-profil-stat dt {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--ink-3);
  font-weight: 700;
}
.eko-profil-stat dd {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
}
.eko-profil-tajuk {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 700;
  color: var(--ink-3);
  margin: 14px 0 6px;
}
.eko-profil-senarai { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.eko-profil-senarai li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--ink-2);
}
.eko-profil-senarai .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eko-profil-senarai .bil { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--ink); }
.eko-profil-senarai .lq { font-size: 10px; padding: 2px 6px; border-radius: 999px; font-weight: 700; }

.eko-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ── Tab jadual ───────────────────────────────────────────────────── */
.eko-jadual-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.eko-jadual-aksi { display: flex; align-items: center; gap: 8px; }
.htmx-indicator { opacity: 0; font-size: 11px; color: var(--ink-3); transition: opacity .18s }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1 }

.eko-carian {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}
.eko-carian .badge { align-self: center; flex-shrink: 0; white-space: nowrap }
.eko-muka { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; color: var(--ink-2) }

/* ── Jadual teks (Senarai MSIC) — bukan matriks nombor ────────────── */
.tbl-msic th,
.tbl-msic td {
  white-space: normal;
  text-align: left;
  font-variant-numeric: normal;
  vertical-align: top;
  line-height: 1.45;
  min-width: 130px;
}
.tbl-msic thead th { text-align: left; vertical-align: middle }
.tbl-msic thead th:first-child,
.tbl-msic tbody th { min-width: 90px }

@media (max-width: 640px) {
  .eko-carian { flex-direction: column; align-items: stretch }
  .eko-carian .badge { align-self: flex-start }
  .eko-firma-kawal { flex-direction: column; align-items: stretch }
  .eko-firma-kawal .eko-medan { width: 100% }
  .tbl-msic,
  .eko-tbl-firma { font-size: 11.5px }
  .tbl-msic th,
  .tbl-msic td { padding: 7px 9px; min-width: 110px }
}

/* ── Jadual firma ─────────────────────────────────────────────────── */
.eko-firma { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 18px }
.eko-firma-kawal {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}
.eko-firma-kira { font-size: 12px; color: var(--ink-2); margin: 0 0 8px }
.eko-firma-lagi { display: flex; justify-content: center; margin-top: 12px }
.eko-tbl-firma { font-size: 12px }
.eko-tbl-firma th[scope="row"] {
  font-weight: 600;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eko-tbl-firma td { white-space: nowrap }

/* ── Metodologi ───────────────────────────────────────────────────── */
.eko-metod { display: flex; flex-direction: column; gap: 16px }
.eko-kaveat-senarai { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 9px }
.eko-kaveat-senarai li { font-size: 13px; line-height: 1.65; color: var(--ink-2) }
.eko-salasilah { margin: 0; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 8px 16px }
.eko-salasilah dt { font-size: 12px; font-weight: 700; color: var(--ink) }
.eko-salasilah dd { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.6 }
.eko-naratif h3 { font-size: 14px; margin: 16px 0 6px; color: var(--ink) }
.eko-naratif h3:first-child { margin-top: 0 }
.eko-naratif p { font-size: 13px; line-height: 1.7; color: var(--ink-2); margin: 0 0 8px }

@media (max-width: 700px) {
  .eko-salasilah { grid-template-columns: 1fr; gap: 2px 0 }
  .eko-salasilah dd { margin-bottom: 10px }
}

/* ── Utiliti ──────────────────────────────────────────────────────── */
.mut { color: var(--ink-3); font-weight: 400 }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
