/* =====================================================================
   Peta Sebaran Asuransi Umum — stylesheet
   Palet   : ink navy + emas (finance/insurance), latar cool off-white
   Type    : Plus Jakarta Sans (display) + Inter (data)
   ===================================================================== */

:root {
  --ink:        #0B1B2B;
  --ink-2:      #13293D;
  --slate:      #1E3A52;
  --bg:         #EDF1F6;
  --surface:    #FFFFFF;
  --surface-2:  #F7F9FC;
  --line:       #E3E9F1;
  --line-2:     #D3DCE7;
  --text:       #10263A;
  --muted:      #5E7186;
  --muted-2:    #8497A9;

  --gold:       #E5A013;
  --gold-deep:  #C9820A;
  --gold-soft:  #FCEFCB;

  /* warna per-metrik (dipakai kartu, diagram, aksen) */
  --c-premi:    #0E9F6E;
  --c-polis:    #2563EB;
  --c-klaim:    #E5484D;
  --c-pklaim:   #E5A013;
  --c-nilai:    #7C3AED;

  --shadow-sm:  0 1px 2px rgba(11,27,43,.06), 0 1px 3px rgba(11,27,43,.05);
  --shadow-md:  0 4px 16px rgba(11,27,43,.08), 0 2px 6px rgba(11,27,43,.05);
  --radius:     14px;
  --radius-sm:  10px;

  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -.01em; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 1200;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: .85rem clamp(1rem, 3vw, 2rem);
  background: linear-gradient(120deg, var(--ink) 0%, var(--ink-2) 55%, var(--slate) 100%);
  color: #EAF1F8;
  box-shadow: var(--shadow-md);
}

.brand { display: flex; align-items: center; gap: .85rem; min-width: 0; }
.brand-mark { color: var(--gold); flex: none; display: grid; place-items: center; }
.brand-text h1 { font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 800; color: #fff; }
.brand-text p  { margin: .15rem 0 0; font-size: .78rem; color: #9DB2C6; letter-spacing: .01em; }

.scope { display: flex; align-items: center; gap: .6rem; }
.scope-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #7E93A8;
}
.scope-chip {
  font-family: var(--font-display); font-weight: 700; font-size: .9rem;
  color: var(--ink); background: var(--gold);
  padding: .38rem .8rem; border-radius: 999px; white-space: nowrap;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.btn-reset {
  font-family: var(--font-body); font-weight: 600; font-size: .82rem;
  color: #EAF1F8; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  padding: .38rem .8rem; cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-reset:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.35); }

/* ---------------------------------------------------------------- layout */
.wrap {
  max-width: 1200px; margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 1.75rem) clamp(1rem, 3vw, 2rem) 3rem;
  display: flex; flex-direction: column; gap: 1.4rem;
}

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}

.section-head { display: flex; align-items: baseline; gap: .9rem; flex-wrap: wrap; margin-bottom: -.4rem; }
.section-head h2 { font-size: 1.12rem; font-weight: 700; color: var(--ink); }
.section-head p  { margin: 0; font-size: .82rem; color: var(--muted); }

/* ---------------------------------------------------------------- peta */
.map-panel { position: relative; overflow: hidden; }
#map {
  height: clamp(360px, 52vh, 540px); width: 100%;
  border-radius: var(--radius); background: #DCE5EE;
}
.map-hint {
  position: absolute; left: 14px; bottom: 14px; z-index: 500;
  max-width: 260px; font-size: .74rem; line-height: 1.45; color: var(--text);
  background: rgba(255,255,255,.94); backdrop-filter: blur(4px);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: .6rem .75rem; box-shadow: var(--shadow-sm);
}
.map-hint strong { color: var(--ink); }
.map-hint em { color: var(--c-nilai); font-style: normal; font-weight: 600; }
.map-loading {
  position: absolute; inset: 0; z-index: 600; display: grid; place-items: center;
  background: #DCE5EE; color: var(--muted); font-weight: 600; font-size: .9rem;
}

/* marker nilai (divIcon) */
.value-marker {
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(124,58,237,.28); border: 2px solid var(--c-nilai);
  color: var(--ink); font-weight: 700; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s;
  box-shadow: 0 2px 6px rgba(11,27,43,.25);
}
.value-marker:hover { transform: scale(1.12); background: rgba(124,58,237,.42); }
.value-marker.is-active {
  background: var(--gold); border-color: var(--gold-deep);
  box-shadow: 0 0 0 4px var(--gold-soft), 0 3px 10px rgba(11,27,43,.3);
  transform: scale(1.15);
}
.value-marker.is-zero { background: rgba(148,163,175,.25); border-color: #94A3B8; }

/* popup Leaflet */
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-md); }
.leaflet-popup-content { margin: .7rem .9rem; font-family: var(--font-body); }
.pop-title { font-family: var(--font-display); font-weight: 800; font-size: .95rem; color: var(--ink); margin-bottom: .35rem; }
.pop-row { display: flex; justify-content: space-between; gap: 1.2rem; font-size: .8rem; padding: .12rem 0; }
.pop-row span:first-child { color: var(--muted); }
.pop-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.pop-cta { margin-top: .45rem; font-size: .72rem; color: var(--gold-deep); font-weight: 600; }

/* tooltip peta (hover marker) */
.leaflet-tooltip.value-tooltip {
  padding: .55rem .7rem; border-radius: 12px; border-color: var(--line-2);
  box-shadow: var(--shadow-md);
}
.value-tooltip .pop-row { min-width: 196px; }

/* ---------------------------------------------------------------- stat cards */
.stats {
  display: grid; gap: .9rem;
  grid-template-columns: repeat(5, 1fr);
}
.stat {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  padding: .95rem 1rem .95rem 1.15rem; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: var(--accent, var(--gold));
}
.stat-label {
  display: flex; align-items: center; gap: .4rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600;
}
.stat-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.stat-value {
  font-family: var(--font-display); font-weight: 800; letter-spacing: -.02em;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem); color: var(--ink); margin-top: .3rem;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat-sub { font-size: .72rem; color: var(--muted-2); margin-top: .15rem; }

/* ---------------------------------------------------------------- charts */
.charts {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.chart-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  padding: 1rem; display: flex; flex-direction: column;
}
.chart-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .2rem; }
.chart-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chart-title { font-family: var(--font-display); font-weight: 700; font-size: .92rem; color: var(--ink); }
.chart-total { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; margin: 0 0 .5rem 1rem; }
.chart-canvas-wrap { position: relative; height: 190px; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted-2); font-size: .8rem; text-align: center;
}

/* ---------------------------------------------------------------- table */
.table-panel { padding: 0; overflow: hidden; }
.table-controls {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .9rem 1rem; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.field { position: relative; display: flex; align-items: center; }
.field .i { position: absolute; left: .65rem; color: var(--muted-2); pointer-events: none; }
.search-field { flex: 1 1 240px; min-width: 200px; }
#search {
  width: 100%; font-family: var(--font-body); font-size: .88rem; color: var(--text);
  padding: .55rem .8rem .55rem 2.1rem;
  border: 1px solid var(--line-2); border-radius: 999px; background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
#provinceSelect {
  font-family: var(--font-body); font-size: .88rem; color: var(--text);
  padding: .55rem 2rem .55rem .8rem; border: 1px solid var(--line-2);
  border-radius: 999px; background: #fff; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E7186' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}
#provinceSelect:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.row-count { margin-left: auto; font-size: .78rem; color: var(--muted); white-space: nowrap; }

.table-wrap { overflow-x: auto; }
#dataTable { width: 100%; border-collapse: collapse; font-size: .86rem; }
#dataTable thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--ink); color: #DCE6F0;
  font-family: var(--font-display); font-weight: 600; font-size: .74rem;
  letter-spacing: .04em; text-transform: uppercase;
  text-align: left; padding: .7rem .9rem; white-space: nowrap;
}
#dataTable thead th.num { text-align: right; }
#dataTable thead th.col-no { width: 42px; text-align: center; }
#dataTable th.sortable { cursor: pointer; user-select: none; }
#dataTable th.sortable:hover { color: #fff; }
#dataTable th.sortable::after {
  content: "⇅"; font-size: .8em; opacity: .35; margin-left: .35em;
}
#dataTable th.sortable.asc::after  { content: "↑"; opacity: 1; color: var(--gold); }
#dataTable th.sortable.desc::after { content: "↓"; opacity: 1; color: var(--gold); }

#dataTable tbody td {
  padding: .58rem .9rem; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
#dataTable tbody tr:nth-child(even) { background: var(--surface-2); }
#dataTable tbody tr:hover { background: var(--gold-soft); }
#dataTable td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#dataTable td.col-no { text-align: center; color: var(--muted-2); font-variant-numeric: tabular-nums; }
.company { font-weight: 600; color: var(--ink); }
.neg { color: var(--c-klaim); }

#dataTable tfoot td {
  padding: .7rem .9rem; border-top: 2px solid var(--line-2);
  font-family: var(--font-display); font-weight: 700; color: var(--ink);
  background: var(--surface-2);
}
#dataTable tfoot td.num { text-align: right; font-variant-numeric: tabular-nums; }

.table-empty { text-align: center; color: var(--muted); padding: 2rem 1rem; margin: 0; }

/* ---------------------------------------------------------------- footer */
.foot {
  font-size: .74rem; color: var(--muted-2); text-align: center;
  padding-top: .5rem; line-height: 1.6;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .scope { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .map-hint { display: none; }
  .row-count { width: 100%; margin: .2rem 0 0; }
}

/* accessibility */
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
