/* =====================================================
   ARGOPURO WALIDA — frontend-gis styles
   Token selaras oracle (argopuro-webgis.html) + Nexus
   ===================================================== */
:root {
  --forest:     #16301C;
  --forest-soft:#1F4228;
  --green:      #4CAF2E;
  --green-dark: #2E7D1E;
  --green-pale: #EAF4E1;
  --orange:     #C75B23;
  --orange-pale:#FBF1E9;
  --paper:      #F4F6F0;
  --card:       #FFFFFF;
  --ink:        #1B241D;
  --ink-soft:   #5C6B5F;
  --line:       #DCE3D8;
  --display:    'Space Grotesk', sans-serif;
  --body:       'IBM Plex Sans', sans-serif;
  --mono:       'IBM Plex Mono', monospace;
  /* Status semantik (selaras admin) */
  --status-pembibitan: #6B4E9B;
  --status-berbuah:    #D9A521;
  --status-panen:      #57A05C;
  --status-pasca:      #3A6E8F;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--paper);
  height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
::selection { background: #CDE7C0; }
h1,h2,h3,h4 { font-family: var(--display); }
button { font-family: inherit; cursor: pointer; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
input, select { font-family: var(--body); }
img { display: block; }

/* ===== NAV ===== */
nav {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  background: var(--forest);
  color: #DFF0D4;
  z-index: 1300;
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .06em;
  line-height: 1.15;
  color: #fff;
}
.brand-sub {
  font-family: var(--mono);
  font-size: .54rem;
  letter-spacing: .16em;
  color: #8FB585;
}
.nav-right { display: flex; gap: 10px; margin-left: auto; align-items: center; }
.nav-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(143,181,133,.3);
  color: #DFF0D4;
  font-size: .72rem;
  font-family: var(--mono);
  letter-spacing: .06em;
  padding: 7px 13px;
  border-radius: 9px;
}
.nav-btn:hover { background: rgba(255,255,255,.15); }
.nav-btn.cta {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  font-weight: 600;
  font-family: var(--display);
  letter-spacing: .02em;
  font-size: .78rem;
}
.nav-btn.cta:hover { background: #A84B1B; }
.lang-tg {
  display: flex;
  border: 1px solid rgba(143,181,133,.35);
  border-radius: 9px;
  overflow: hidden;
}
.lang-tg button {
  background: transparent;
  border: none;
  color: #9DB496;
  font-family: var(--mono);
  font-size: .66rem;
  letter-spacing: .08em;
  padding: 7px 10px;
}
.lang-tg button.active { background: var(--green-dark); color: #fff; }

/* ===== LAYOUT ===== */
.app { flex: 1; display: flex; min-height: 0; position: relative; }

/* SIDEBAR KIRI */
#sidebar {
  width: 258px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  transition: margin-left .25s;
  z-index: 1100;
}
#sidebar.collapsed { margin-left: -258px; }
.sb-section { border-bottom: 1px solid var(--line); }
.sb-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 17px;
  background: none;
  border: none;
  font-family: var(--display);
  font-weight: 600;
  font-size: .8rem;
  color: var(--ink);
  text-align: left;
}
.sb-head .chev { transition: transform .2s; color: var(--ink-soft); font-size: .68rem; }
.sb-section.open .chev { transform: rotate(90deg); }
.sb-body { display: none; padding: 2px 17px 15px; }
.sb-section.open .sb-body { display: block; }

/* Ringkasan */
.sum-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sum { background: var(--paper); border-radius: 11px; padding: 9px 11px; }
.sum span {
  display: block;
  font-family: var(--mono);
  font-size: .55rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.sum b { font-family: var(--display); font-size: 1rem; color: var(--forest); }
.sum.loading b { color: var(--ink-soft); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Layer toggles */
.lyr { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; font-size: .83rem; }
.lyr .lab { display: flex; align-items: center; gap: 9px; }
.lyr .dot { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }
.sw {
  width: 34px; height: 19px;
  border-radius: 999px;
  background: var(--line);
  border: none;
  position: relative;
  transition: background .15s;
  flex-shrink: 0;
}
.sw::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: #fff;
  transition: left .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.sw.on { background: var(--green-dark); }
.sw.on::after { left: 17px; }

/* Legenda */
.leg-row { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: .78rem; }
.leg-row i { width: 13px; height: 13px; border-radius: 4px; flex-shrink: 0; }
.leg-row small { font-family: var(--mono); font-size: .56rem; color: var(--ink-soft); margin-left: auto; }

/* Basemap grid */
.bm-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.bm {
  padding: 8px 4px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: .66rem;
  font-family: var(--mono);
  color: var(--ink-soft);
}
.bm.active {
  border-color: var(--green-dark);
  background: var(--green-pale);
  color: var(--green-dark);
  font-weight: 600;
}

/* ===== PETA ===== */
#mapWrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #0F231A; }
.leaflet-container { font-family: var(--body); }
.coord {
  position: absolute;
  left: 12px; bottom: 12px;
  z-index: 1000;
  background: rgba(22,48,28,.88);
  color: #9CCB8B;
  font-family: var(--mono);
  font-size: .64rem;
  padding: 5px 11px;
  border-radius: 8px;
  pointer-events: none;
}
.map-fabs {
  position: absolute;
  top: 12px; left: 12px;
  z-index: 1000;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.fab {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .7rem;
  font-family: var(--mono);
  box-shadow: 0 4px 14px rgba(22,48,28,.14);
}
.fab:hover { background: var(--paper); }

/* ===== PANEL KANAN ===== */
#panel {
  width: 320px;
  flex-shrink: 0;
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: margin-right .25s;
  z-index: 1100;
  overflow-y: auto;
}
#panel.collapsed { margin-right: -320px; }
.panel-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.panel-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: .9rem;
  color: var(--forest);
}
.panel-sub {
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .1em;
  color: var(--ink-soft);
  margin-top: 2px;
}
.panel-body { padding: 14px 16px; flex: 1; }

/* Hint (state awal panel) */
.panel-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 200px;
  text-align: center;
  color: var(--ink-soft);
  font-size: .8rem;
  line-height: 1.5;
}
.panel-hint svg { opacity: .35; }

/* Stat cards di panel (ringkasan per blok) */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.detail-badge {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}
.detail-title { font-family: var(--display); font-weight: 700; font-size: 1rem; }
.detail-sub { font-family: var(--mono); font-size: .6rem; color: var(--ink-soft); letter-spacing: .06em; margin-top: 2px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.info-cell { background: var(--paper); border-radius: 10px; padding: 9px 11px; }
.info-cell span {
  display: block;
  font-family: var(--mono);
  font-size: .54rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 3px;
}
.info-cell b { font-size: .82rem; }
.info-cell.full { grid-column: 1 / -1; }

.status-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .1em;
  padding: 3px 10px;
  border-radius: 999px;
}

.lot-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  text-decoration: none;
  color: var(--ink);
  font-size: .8rem;
  margin-bottom: 8px;
  transition: border-color .15s, background .15s;
}
.lot-link:hover { border-color: var(--orange); background: var(--orange-pale); }
.lot-link .go { font-family: var(--mono); font-size: .6rem; color: var(--orange); }
.lot-link.off { opacity: .5; pointer-events: none; }

.btn-back {
  width: 100%;
  padding: 9px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: .7rem;
  margin-top: 12px;
}
.btn-back:hover { background: var(--paper); }

/* Daftar blok di panel */
.blok-list { display: flex; flex-direction: column; gap: 7px; }
.blok-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  text-align: left;
  width: 100%;
}
.blok-item:hover { border-color: var(--green); box-shadow: 0 4px 14px rgba(22,48,28,.1); }
.blok-item.active { border-color: var(--green-dark); background: var(--green-pale); }
.blok-item .bi-badge {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: .82rem;
  flex-shrink: 0;
}
.blok-item .bi-info { flex: 1; min-width: 0; }
.blok-item .bi-nama { font-family: var(--display); font-weight: 600; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blok-item .bi-meta { font-family: var(--mono); font-size: .58rem; color: var(--ink-soft); margin-top: 1px; }
.blok-item .bi-status { font-family: var(--mono); font-size: .56rem; padding: 2px 7px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }

/* Error / loading state */
.state-msg {
  text-align: center;
  padding: 28px 16px;
  font-size: .8rem;
  color: var(--ink-soft);
}
.state-msg.error { color: #C13B2A; }

/* Popup Leaflet */
.leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: 0 10px 30px rgba(22,48,28,.22); overflow: hidden; }
.leaflet-popup-content { margin: 0; width: 220px !important; font-family: var(--body); }
.pp-head { background: var(--forest); color: #fff; padding: 10px 14px; }
.pp-head .t { font-family: var(--display); font-weight: 700; font-size: .88rem; }
.pp-head .s { font-family: var(--mono); font-size: .56rem; letter-spacing: .12em; color: #8FD96B; margin-top: 2px; }
.pp-body { padding: 9px 14px 12px; }
.pp-row { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: .74rem; }
.pp-row:last-child { border-bottom: none; }
.pp-row .l { color: var(--ink-soft); }
.pp-row .v { font-weight: 600; text-align: right; }
.pp-click { font-family: var(--mono); font-size: .6rem; color: var(--green-dark); letter-spacing: .06em; margin-top: 8px; text-align: center; }

/* Fasilitas popup */
.fac-head { background: var(--forest-soft); color: #fff; padding: 10px 14px; }
.fac-head .t { font-family: var(--display); font-weight: 700; font-size: .84rem; }
.fac-head .s { font-family: var(--mono); font-size: .54rem; color: #8FD96B; margin-top: 2px; }

@media (max-width: 980px) {
  #sidebar { position: absolute; inset: 0 auto 0 0; box-shadow: 14px 0 40px rgba(22,48,28,.18); }
  #panel { position: absolute; inset: 0 0 0 auto; box-shadow: -14px 0 40px rgba(22,48,28,.18); width: min(320px, 92vw); }
}
