/* =====================================================
   WEBGIS DBD OGAN ILIR - GLOBAL STYLESHEET
   ===================================================== */

:root {
  --navy:    #0A2342;
  --teal:    #0D7377;
  --teal-lt: #14A79D;
  --mint:    #D4F5F0;
  --white:   #FFFFFF;
  --off-wht: #F4F8F8;
  --slate:   #4A6470;
  --gray-lt: #E8EEF0;
  --red:     #C0392B;
  --orange:  #E67E22;
  --green:   #27AE60;
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
  background: var(--off-wht);
  color: #1a2a3a;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s;
}
.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo .app-name {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.sidebar-logo .app-sub {
  font-size: 10px;
  color: var(--teal-lt);
  margin-top: 3px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.nav-section {
  padding: 6px 16px 4px;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 13px;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}
.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #fff;
}
.nav-item.active {
  background: rgba(13,115,119,0.25);
  color: var(--teal-lt);
  border-left-color: var(--teal-lt);
  font-weight: 600;
}
.nav-item .icon { font-size: 16px; min-width: 20px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--teal);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff; font-weight: 700;
}
.user-name { font-size: 12px; color: #fff; font-weight: 600; }
.user-role { font-size: 10px; color: var(--teal-lt); }
.btn-logout {
  width: 100%;
  padding: 8px;
  background: rgba(192,57,43,0.2);
  border: 1px solid rgba(192,57,43,0.4);
  color: #e74c3c;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-logout:hover { background: rgba(192,57,43,0.4); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-lt);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar h1 { font-size: 18px; color: var(--navy); font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 24px; flex: 1; }

/* ===== CARDS ===== */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  overflow: hidden;
}
.card-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-body { padding: 20px; }

/* ===== STAT BOXES ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  border-left: 4px solid var(--teal);
  position: relative;
  overflow: hidden;
}
.stat-card.red   { border-left-color: var(--red); }
.stat-card.orange{ border-left-color: var(--orange); }
.stat-card.navy  { border-left-color: var(--navy); }
.stat-card.green { border-left-color: var(--green); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 11px; color: var(--slate); margin-top: 6px; }
.stat-icon  { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 32px; opacity: 0.12; }
.stat-trend { font-size: 11px; margin-top: 6px; font-weight: 600; }
.trend-up   { color: var(--red); }
.trend-dn   { color: var(--green); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 7px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none;
  text-decoration: none; transition: all 0.2s;
}
.btn-primary   { background: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-lt); }
.btn-secondary { background: var(--off-wht); color: var(--navy); border: 1px solid var(--gray-lt); }
.btn-secondary:hover { background: var(--gray-lt); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-sm        { padding: 6px 12px; font-size: 12px; }
.btn-block     { width: 100%; justify-content: center; }

/* ===== FORM ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--slate); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--gray-lt); border-radius: 7px;
  font-size: 13px; transition: border-color 0.2s;
  background: #fff;
}
.form-control:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,115,119,0.1); }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%234A6470' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--navy); color: #fff; padding: 11px 14px; text-align: left; font-weight: 600; font-size: 12px; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--gray-lt); transition: background 0.15s; }
tbody tr:hover { background: var(--off-wht); }
tbody td { padding: 10px 14px; vertical-align: middle; }

/* ===== BADGE ===== */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-tinggi  { background: #fdedec; color: var(--red); }
.badge-sedang  { background: #fef9e7; color: #9a7d0a; }
.badge-rendah  { background: #eafaf1; color: var(--green); }

/* ===== MAP ===== */
#map { width: 100%; height: calc(100vh - 180px); min-height: 500px; border-radius: 0 0 10px 10px; }

/* Leaflet popup custom */
.leaflet-popup-content-wrapper { border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.popup-header { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 6px 6px 0 0; font-weight: 700; font-size: 13px; }
.popup-body { padding: 10px 14px; font-size: 12px; }
.popup-row { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--gray-lt); }
.popup-row:last-child { border: none; }

/* ===== LEGEND ===== */
.map-legend {
  background: white; border-radius: 8px; padding: 12px 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15); font-size: 12px;
}
.legend-title { font-weight: 700; margin-bottom: 8px; color: var(--navy); }
.legend-item  { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.legend-color { width: 16px; height: 16px; border-radius: 3px; flex-shrink: 0; }

/* ===== LOADER ===== */
.loader {
  display: flex; align-items: center; justify-content: center;
  height: 200px; color: var(--slate); font-size: 13px; gap: 10px;
}
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--gray-lt);
  border-top-color: var(--teal); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== ALERT ===== */
.alert { padding: 12px 16px; border-radius: 7px; font-size: 13px; margin-bottom: 16px; }
.alert-danger  { background: #fdedec; color: #922b21; border: 1px solid #f1948a; }
.alert-success { background: #eafaf1; color: #1e8449; border: 1px solid #82e0aa; }
.alert-info    { background: #eaf4fb; color: #1a5276; border: 1px solid #85c1e9; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, #0D4F6B 50%, var(--teal) 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.login-header {
  background: var(--navy); padding: 32px 32px 24px; text-align: center;
}
.login-logo { font-size: 40px; margin-bottom: 8px; }
.login-title { font-size: 18px; font-weight: 700; color: #fff; }
.login-sub { font-size: 12px; color: var(--teal-lt); margin-top: 4px; }
.login-body { padding: 28px 32px; }
.login-tabs { display: flex; margin-bottom: 24px; border-radius: 7px; overflow: hidden; border: 1px solid var(--gray-lt); }
.login-tab {
  flex: 1; padding: 9px; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; background: var(--off-wht); color: var(--slate); transition: all 0.2s;
}
.login-tab.active { background: var(--teal); color: #fff; }
