/* ===== DESA RAME v2 — Closer to Kampung Komen style ===== */
:root {
  --green-950: #0f2a1d;
  --green-900: #1a3c2a;
  --green-800: #234d36;
  --green-700: #2d6a4f;
  --green-600: #40916c;
  --green-500: #52b788;
  --green-100: #d8f3dc;
  --cream: #fefae0;
  --sand: #e9d8a6;
  --roof: #c94c2a;
  --roof-dark: #9c3a1f;
  --wall: #f4e4bc;
  --wall-dark: #e0c98a;
  --water: #5dade2;
  --path: #d4a373;
  --white: #ffffff;
  --gray-100: #f1f3f5;
  --gray-400: #868e96;
  --gray-700: #343a40;
  --shadow: 0 4px 24px rgba(0,0,0,0.15);
  --radius: 14px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --nav-h: 64px;
  --top-h: 48px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #3d6b4f;
  color: var(--gray-700);
  -webkit-tap-highlight-color: transparent;
}

/* ===== TOP BAR ===== */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--top-h);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  background: var(--green-950);
  color: white;
  font-size: 0.85rem;
}

.topbar-left { display: flex; align-items: center; gap: 8px; }
.brand { font-weight: 700; font-size: 1rem; letter-spacing: -0.3px; }
.day-badge {
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.topbar-right { display: flex; align-items: center; gap: 8px; font-size: 0.75rem; opacity: 0.9; }
.period {
  background: #e9c46a;
  color: var(--green-950);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.65rem;
}

/* ===== WARGA CARD ===== */
.warga-card {
  position: fixed;
  top: calc(var(--top-h) + 10px);
  left: 12px;
  z-index: 90;
  background: rgba(40, 60, 45, 0.88);
  backdrop-filter: blur(10px);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  min-width: 120px;
  box-shadow: var(--shadow);
}

.warga-label { font-size: 0.65rem; opacity: 0.8; letter-spacing: 0.5px; }
.warga-number { font-size: 1.6rem; font-weight: 800; line-height: 1.15; }
.warga-update { font-size: 0.6rem; opacity: 0.65; margin-top: 2px; }

/* ===== MAP ===== */
.map-area {
  position: fixed;
  inset: 0;
  padding-top: var(--top-h);
  padding-bottom: var(--nav-h);
  overflow: hidden;
  background: linear-gradient(180deg, #5a8f6a 0%, #3d6b4f 100%);
}

.map-viewport {
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  position: relative;
}

.map-viewport:active { cursor: grabbing; }

.map-world {
  position: absolute;
  width: 1400px;
  height: 1000px;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%) scale(0.72);
  transform-origin: center center;
  will-change: transform;
}

.terrain-grass {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(120,180,100,0.4) 0%, transparent 40%),
    radial-gradient(ellipse at 70% 60%, rgba(90,150,80,0.35) 0%, transparent 45%),
    linear-gradient(160deg, #6b9e5a 0%, #4a7c3f 40%, #3d6b4f 100%);
  border-radius: 40px;
}

.terrain-path {
  position: absolute;
  left: 18%;
  top: 25%;
  width: 64%;
  height: 50%;
  background:
    linear-gradient(90deg, transparent 0%, rgba(212,163,115,0.35) 15%, rgba(212,163,115,0.45) 50%, rgba(212,163,115,0.35) 85%, transparent 100%);
  border-radius: 80px;
  transform: rotate(-8deg);
  pointer-events: none;
}

.terrain-river {
  position: absolute;
  right: 8%;
  top: 15%;
  width: 90px;
  height: 70%;
  background: linear-gradient(180deg, #7ec8e3 0%, #5dade2 40%, #4a9fd4 100%);
  border-radius: 50px;
  opacity: 0.85;
  box-shadow: inset 0 0 20px rgba(255,255,255,0.25);
  pointer-events: none;
}

.building {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.18s ease, filter 0.18s;
  user-select: none;
  -webkit-user-select: none;
}

.building:active,
.building:hover {
  transform: scale(1.12) translateY(-6px);
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.3));
  z-index: 30;
}

.building-svg {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.25));
}

.building-label {
  margin-top: 2px;
  background: rgba(255,255,255,0.92);
  color: var(--green-900);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  pointer-events: none;
}

.tree {
  position: absolute;
  width: 36px;
  height: 42px;
  pointer-events: none;
  z-index: 5;
  opacity: 0.9;
}

.zoom-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
}

.zoom-controls button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: rgba(255,255,255,0.92);
  color: var(--green-800);
  font-size: 1.3rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.zoom-controls button:active { transform: scale(0.94); }

.map-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.45);
  color: white;
  font-size: 0.7rem;
  padding: 5px 12px;
  border-radius: 999px;
  white-space: nowrap;
  z-index: 40;
  pointer-events: none;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #1e2e24;
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  font-size: 0.65rem;
  text-decoration: none;
  padding: 6px 10px;
  cursor: pointer;
  transition: color 0.15s;
}

.nav-btn.active,
.nav-btn:hover { color: white; }

.nav-btn svg { opacity: 0.85; }

/* ===== SIDE PANEL ===== */
.side-panel {
  position: fixed;
  left: 0; right: 0;
  bottom: var(--nav-h);
  max-height: 55vh;
  background: white;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  z-index: 80;
  transform: translateY(110%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.side-panel.open { transform: translateY(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--gray-100);
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 1rem;
  color: var(--green-900);
}

.panel-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 50%;
  font-size: 1.3rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
}

.panel-body {
  padding: 12px 18px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.info-item, .history-item, .official-item {
  background: #f6f9f6;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--green-500);
}

.info-item h4 { font-size: 0.9rem; margin-bottom: 4px; color: var(--green-900); }
.info-item p, .history-item p { font-size: 0.8rem; color: var(--gray-400); line-height: 1.4; }

.history-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.history-icon-wrap {
  width: 40px; height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-icon-wrap svg { width: 32px; height: 32px; }

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

.official-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--green-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.official-avatar svg { width: 22px; height: 22px; color: var(--green-700); }

.official-info strong { display: block; font-size: 0.9rem; }
.official-info span { font-size: 0.75rem; color: var(--gray-400); }

.empty-state {
  font-size: 0.85rem;
  color: var(--gray-400);
  font-style: italic;
  padding: 16px 0;
  text-align: center;
}

.panel-footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-400);
}

.panel-footer a {
  color: var(--green-700);
  font-weight: 600;
  text-decoration: none;
}

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s, visibility 0.22s;
}

.modal.open { opacity: 1; visibility: visible; }

.modal-box {
  background: white;
  border-radius: 18px;
  max-width: 360px;
  width: 100%;
  padding: 24px 20px 20px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  transform: translateY(16px);
  transition: transform 0.22s;
}

.modal.open .modal-box { transform: translateY(0); }

.modal-close {
  position: absolute;
  top: 10px; right: 12px;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
}

.modal-icon {
  width: 80px; height: 80px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-icon svg { width: 72px; height: 72px; }

.modal-box h3 {
  text-align: center;
  color: var(--green-900);
  margin-bottom: 8px;
  font-size: 1.15rem;
}

.modal-box p {
  text-align: center;
  font-size: 0.88rem;
  color: var(--gray-400);
  line-height: 1.45;
}

.modal-meta {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
  font-size: 0.78rem;
  color: var(--gray-400);
  text-align: center;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green-900);
  color: white;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.85rem;
  z-index: 300;
  opacity: 0;
  transition: transform 0.28s, opacity 0.28s;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== ADMIN ===== */
.admin-body { background: var(--gray-100); overflow: auto; height: auto; min-height: 100%; }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(145deg, var(--green-900), var(--green-700));
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}

.login-logo-svg {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
}

.login-card h1 { font-size: 1.35rem; color: var(--green-900); }
.login-card > p { color: var(--gray-400); margin-bottom: 20px; font-size: 0.88rem; }

.login-card input {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
}

.login-card input:focus { border-color: var(--green-500); }

.login-hint { margin-top: 14px; font-size: 0.78rem; color: var(--gray-400); }
.back-link { display: inline-block; margin-top: 18px; color: var(--green-700); font-size: 0.85rem; text-decoration: none; }

.hidden { display: none !important; }

.admin-dashboard { min-height: 100vh; }

.admin-header {
  background: linear-gradient(135deg, var(--green-900), var(--green-700));
  color: white;
  padding: 18px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-header h1 { font-size: 1.25rem; }
.admin-header p { font-size: 0.8rem; opacity: 0.85; }
.admin-header-actions { display: flex; gap: 8px; }

.admin-nav {
  display: flex;
  overflow-x: auto;
  background: white;
  border-bottom: 1px solid #e9ecef;
  padding: 0 8px;
  gap: 2px;
  -webkit-overflow-scrolling: touch;
}

.nav-item {
  flex-shrink: 0;
  padding: 12px 14px;
  border: none;
  background: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.nav-item.active { color: var(--green-700); border-bottom-color: var(--green-500); }

.admin-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 12px 40px;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 520px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-icon-svg { width: 28px; height: 28px; margin: 0 auto 4px; color: var(--green-600); }
.stat-value { font-size: 1.4rem; font-weight: 700; color: var(--green-800); }
.stat-label { font-size: 0.7rem; color: var(--gray-400); }

.card {
  background: white;
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card h3 { font-size: 0.98rem; color: var(--green-800); margin-bottom: 10px; }
.hint { font-size: 0.78rem; color: var(--gray-400); margin-bottom: 10px; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 500; margin-bottom: 5px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #e9ecef;
  border-radius: 9px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--green-500); }

.form-row { display: flex; gap: 10px; align-items: flex-end; }
.form-row .form-group { flex: 1; }

.btn-primary {
  background: var(--green-600);
  color: white;
  border: none;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

.btn-primary:active { opacity: 0.9; }

.btn-secondary {
  background: rgba(255,255,255,0.18);
  color: white;
  border: 1px solid rgba(255,255,255,0.35);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
}

.btn-danger {
  background: #e63946;
  color: white;
  border: none;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-small {
  padding: 5px 10px;
  font-size: 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.btn-delete { background: #ffe5e5; color: #e63946; }

.admin-list { display: flex; flex-direction: column; gap: 8px; }

.admin-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 10px;
}

.admin-list-item .item-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.admin-list-item .item-icon-svg { width: 32px; height: 32px; flex-shrink: 0; }
.admin-list-item .item-text { min-width: 0; }
.admin-list-item .item-text strong { display: block; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-list-item .item-text span { font-size: 0.72rem; color: var(--gray-400); }
.admin-list-item .item-actions { flex-shrink: 0; }

.danger-zone { border: 1px solid #ffc9c9; background: #fff5f5; }
.danger-zone h3 { color: #e63946; }

@media (min-width: 768px) {
  .side-panel {
    left: auto;
    right: 16px;
    bottom: calc(var(--nav-h) + 16px);
    width: 360px;
    max-height: 70vh;
    border-radius: 16px;
  }
  .map-hint { bottom: 20px; }
  .warga-card { top: calc(var(--top-h) + 14px); left: 16px; }
}
