html, body {
  margin: 0;
  height: 100%;
  font-family: 'Inter', Arial, sans-serif;
  overflow: hidden;
}
/* ===== Top navbar ===== */
#topbar {
  height: 56px;
  background: #e65100;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-sizing: border-box;
  z-index: 2000;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 26px; }
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: 1px; line-height: 1.2; text-shadow: 1px 1px 2px rgba(0,0,0,0.15); }
.brand-text p { margin: 0; font-size: 12px; font-weight: 500; letter-spacing: 0.5px; opacity: 0.95; }
.nav-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
#nav-clock { opacity: 0.9; }
.nav-link {
  color: #fff;
  text-decoration: none;
  background: rgba(255,255,255,0.18);
  padding: 6px 12px;
  border-radius: 6px;
}
.nav-link:hover { background: rgba(230,81,0,0.25); }

/* ===== Layout: sidebar kiri + peta ===== */
#layout {
  position: relative;
  width: 100%;
  height: calc(100% - 56px);
}
#sidebar {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: 280px;
  max-width: calc(100vw - 40px);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  box-sizing: border-box;
  z-index: 1000;
}
/* Scrollbar styling for sidebar */
#sidebar::-webkit-scrollbar { width: 5px; }
#sidebar::-webkit-scrollbar-track { background: transparent; }
#sidebar::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

#bottom-panel {
  position: absolute;
  bottom: 20px;
  left: 320px; /* aside width(280) + left(20) + gap(20) */
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}


#widgets {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
/* Push Leaflet controls so they aren't hidden behind the floating sidebar */
@media (min-width: 600px) {
  .leaflet-left { margin-left: 300px !important; }
}

/* Kartu widget tersusun di sidebar */
.widget {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  width: auto;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.widget:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.widget h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #444;
}
.widget h3 .chart-toggle {
  float: right;
  margin-top: -2px;
  padding: 0 7px;
  border: 1px solid #d1d5db;
  background: #eef2f5;
  color: #333;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.6;
}
.widget-body.collapsed { display: none; }
.widget-body { font-size: 13px; line-height: 1.4; }
.widget-body ul { list-style: none; padding: 0; margin: 0; }
.widget-body li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}
.widget-body li:last-child { border-bottom: none; }
.widget-body .status {
  padding: 3px 8px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}
.widget-update { font-size: 12px; color: #888; text-align: center; }
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
/* Widget grafik ketinggian air */
.widget-wide { width: auto; }
.chart-controls { display: flex; gap: 6px; margin-bottom: 8px; }
.chart-controls button {
  flex: 1; padding: 5px; font-size: 12px;
  background: #eef2f5; color: #333; border: 1px solid #d1d5db; border-radius: 4px; cursor: pointer;
}
.chart-controls button.active { background: #e65100; color: #fff; border-color: #e65100; }
.chart-wrap { position: relative; height: 140px; margin-top: 12px; margin-bottom: 4px; }
.chart-wrap canvas { width: 100% !important; height: 100% !important; }
.chart-empty { font-size: 12px; color: #888; padding: 8px 0; text-align: center; }
/* Widget curah hujan (Open-Meteo) */
.weather-card {
  position: relative;
  overflow: hidden;
  padding: 10px 10px 8px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 12px;
  background: linear-gradient(180deg, #f5faff 0%, #edf4fc 100%);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.08);
}
.weather-source {
  display: flex;
  align-items: center;
  font-size: 10.5px;
  color: #334155;
  letter-spacing: 0.3px;
}
.weather-source b { font-weight: 700; color: #0f766e; }
.weather-hero { display: flex; align-items: center; gap: 10px; margin-top: 5px; }
.weather-icon { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
.weather-hero-main { flex: 1; min-width: 0; }
.weather-today-mm { font-size: 24px; font-weight: 800; line-height: 1; letter-spacing: -0.5px; }
.weather-today-mm span { font-size: 12px; font-weight: 600; margin-left: 3px; opacity: 0.7; }
.weather-today-sub { font-size: 10.5px; color: #64748b; margin-top: 3px; }
.weather-chip {
  text-align: center;
  background: rgba(15, 118, 110, 0.08);
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 8px;
  padding: 5px 8px;
  line-height: 1.15;
}
.weather-chip span { font-size: 9.5px; color: #64748b; display: block; }
.weather-chip b { font-size: 13.5px; color: #0f766e; font-weight: 800; }
.weather-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  margin-top: 8px;
  height: 58px;
}
.weather-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  height: 100%;
}
.wd-mm { font-size: 10px; font-weight: 700; line-height: 1; }
.wd-bar {
  width: 100%;
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: height 0.3s ease;
}
.wd-label { font-size: 9px; color: #64748b; white-space: nowrap; }
.weather-day.today .wd-label { font-weight: 700; color: #0f766e; }
.weather-day.today .wd-bar { box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.55); }
.weather-day:hover .wd-bar { filter: brightness(1.12); }
.weather-foot { font-size: 9.5px; color: #94a3b8; margin-top: 6px; text-align: right; }
/* Keterangan kecil: skala intensitas hujan */
.weather-scale {
  margin-top: 6px;
  border-top: 1px dashed rgba(15, 118, 110, 0.2);
  padding-top: 4px;
  font-size: 10px;
  color: #64748b;
}
.weather-scale summary {
  cursor: pointer;
  user-select: none;
  font-size: 10px;
  color: #334155;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 2px;
}
.weather-scale summary::-webkit-details-marker { display: none; }
.weather-scale[open] summary { margin-bottom: 4px; }
.ws-row { display: flex; align-items: center; gap: 5px; font-size: 10px; color: #475569; line-height: 1.7; }
.ws-row b { font-weight: 700; color: #334155; }
.ws-dot { flex: none; width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.08); }
.weather-error { font-size: 12px; color: #b91c1c; padding: 8px 0; text-align: center; }
/* Widget basemap */
.basemap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.basemap-btn {
  padding: 6px; font-size: 12px; background: #eef2f5; color: #333;
  border: 1px solid #d1d5db; border-radius: 4px; cursor: pointer;
}
.basemap-btn.active { background: #e65100; color: #fff; border-color: #e65100; }
/* Denyut sensor saat ada data baru masuk */
.leaflet-overlay-pane path.sensor-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: sensor-pulse 0.9s ease-out;
}
@keyframes sensor-pulse {
  0%   { transform: scale(1.7); fill-opacity: 0.9; }
  60%  { transform: scale(1.1); fill-opacity: 1; }
  100% { transform: scale(1);  fill-opacity: 1; }
}
/* Denyut cepat berkelanjutan untuk status bahaya */
.leaflet-overlay-pane path.sensor-pulse-fast {
  transform-box: fill-box;
  transform-origin: center;
  animation: sensor-pulse 0.7s ease-in-out infinite;
}
/* Animasi aliran sungai */
.river-flow {
  stroke-dasharray: 8 8;
  animation: flow 1s linear infinite;
}
@keyframes flow {
  to { stroke-dashoffset: -16; }
}
