/* ============================================================
   style.css — Modern Light Theme
   WebGIS Jalan Rawan — Asam Kumbang, Medan Selayang
   ============================================================ */

:root {
  --bg:      #F0F4F8;
  --bg2:     #FFFFFF;
  --bg3:     #F8FAFC;
  --border:  #E2E8F0;
  --text:    #1A202C;
  --text2:   #718096;
  --accent:  #E53E3E;
  --accent2: #3182CE;
  --warning: #D69E2E;
  --danger:  #E53E3E;
  --success: #38A169;
  --shadow:  0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius: 10px;
}

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

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---- HEADER ---- */
header {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}
.logo-main { font-size: 15px; font-weight: 700; color: var(--text); }
.logo-sub  { font-size: 10px; color: var(--text2); font-family: 'DM Mono', monospace; }

nav { display: flex; align-items: center; gap: 2px; }
nav a {
  padding: 7px 14px;
  border-radius: 8px;
  color: var(--text2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
nav a:hover { background: var(--bg3); color: var(--text); }
nav a.active { background: #EBF4FF; color: var(--accent2); font-weight: 600; }

/* ---- ROLE BADGE ---- */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  font-family: 'DM Mono', monospace;
}
.role-admin { background: #FFF5F5; color: #C53030; border: 1px solid #FEB2B2; }
.role-user  { background: #EBF8FF; color: #2B6CB0; border: 1px solid #BEE3F8; }

.logout-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text2);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  margin-left: 6px;
}
.logout-btn:hover { border-color: var(--danger); color: var(--danger); background: #FFF5F5; }

/* ---- LAYOUT PETA ---- */
.main { display: flex; height: calc(100vh - 60px); min-height: 0; overflow: hidden; }

.sidebar {
  width: 300px;
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sb-head {
  padding: 1rem 1.25rem .875rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #667eea10, #764ba210);
  flex-shrink: 0;
}
.sb-label { font-size: 11px; font-weight: 700; color: var(--accent2); text-transform: uppercase; letter-spacing: 1px; }
.sb-body { padding: .875rem; flex: 1; overflow-y: auto; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 1rem; }
.stat-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-lbl { font-size: 10px; color: var(--text2); margin-bottom: 4px; font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-val { font-size: 22px; font-weight: 700; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
  text-transform: uppercase;
  font-family: 'DM Mono', monospace;
  letter-spacing: 0.3px;
}
.b-gelap  { background: #FFF3E0; color: #E65100; border: 1px solid #FFCC80; }
.b-rusak  { background: #FFFDE7; color: #F57F17; border: 1px solid #FFF176; }
.b-rawan  { background: #FFEBEE; color: #C62828; border: 1px solid #EF9A9A; }
.b-rendah { background: #E8F5E9; color: #2E7D32; border: 1px solid #A5D6A7; }
.b-sedang { background: #FFF8E1; color: #F57F17; border: 1px solid #FFE082; }
.b-tinggi { background: #FFEBEE; color: #C62828; border: 1px solid #EF9A9A; }

/* ---- LEGEND ---- */
.sec-title { font-size: 11px; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }
.leg-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
  cursor: pointer; transition: background 0.1s;
  font-size: 13px; margin-bottom: 2px; font-weight: 500;
}
.leg-item:hover, .leg-item.on { background: var(--bg3); }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(0,0,0,0.1); }
.leg-cnt { margin-left: auto; font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text2); background: var(--bg); padding: 1px 7px; border-radius: 10px; border: 1px solid var(--border); }

/* ---- DATA LIST ---- */
.data-list { display: flex; flex-direction: column; gap: 6px; }
.data-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.data-item:hover { border-color: var(--accent2); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.data-row { display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.d-name { font-size: 13px; font-weight: 600; color: var(--text); }
.d-loc  { font-size: 11px; color: var(--text2); font-family: 'DM Mono', monospace; }
.risk-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.risk-fill { height: 100%; border-radius: 2px; }

/* ---- MAP ---- */
.map-wrap { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }

.map-ctrl {
  position: absolute; top: 1rem; right: 1rem;
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.mc-btn {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 8px 16px; cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 6px;
  box-shadow: var(--shadow-md);
}
.mc-btn:hover { background: var(--bg3); border-color: var(--accent2); color: var(--accent2); }
.mc-btn.prim { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.mc-btn.prim:hover { background: #2B6CB0; opacity: 1; }

.add-banner {
  position: absolute; top: 1rem; left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  background: var(--accent2); color: #fff;
  font-size: 13px; font-weight: 600;
  padding: 10px 20px; border-radius: 10px;
  display: none; gap: 12px; align-items: center;
  box-shadow: var(--shadow-lg);
}
.add-banner.show { display: flex; }
.cancel-btn {
  background: rgba(255,255,255,.25);
  border: 1px solid rgba(255,255,255,.4);
  color: #fff; font-size: 12px;
  padding: 3px 10px; border-radius: 6px; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
}

/* ---- FORMS ---- */
.page-wrap { max-width: 620px; margin: 2rem auto; padding: 0 1.5rem; }
.page-wrap.wide { max-width: 980px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 5px; color: var(--text); }
.page-sub   { font-size: 13px; color: var(--text2); margin-bottom: 1.5rem; }

.card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 12px; font-weight: 700; color: var(--accent2);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 1rem;
}

label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }

input, select, textarea {
  width: 100%;
  background: var(--bg3);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  transition: all .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent2);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(49,130,206,0.1);
}
select option { background: #fff; }
textarea { resize: vertical; min-height: 80px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.gps-btn {
  width: 100%; background: #EBF8FF;
  border: 1.5px dashed #90CDF4; border-radius: 8px;
  color: var(--accent2); font-family: 'Space Grotesk', sans-serif;
  font-size: 13px; font-weight: 600; padding: 11px; cursor: pointer;
  transition: all .15s; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.gps-btn:hover { background: #BEE3F8; border-color: var(--accent2); }

.risk-sel { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.ro {
  background: var(--bg3); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 12px; text-align: center;
  cursor: pointer; transition: all .15s; font-size: 13px; font-weight: 600;
}
.ro:hover { border-color: var(--text2); background: #fff; box-shadow: var(--shadow-md); }
.ro.sel-rendah { border-color: #38A169; color: #276749; background: #F0FFF4; }
.ro.sel-sedang { border-color: #D69E2E; color: #744210; background: #FFFFF0; }
.ro.sel-tinggi { border-color: #E53E3E; color: #742A2A; background: #FFF5F5; }

.btn-primary {
  width: 100%; background: var(--accent2); border: none;
  border-radius: 10px; color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px; font-weight: 700;
  padding: 14px; cursor: pointer; transition: all .15s;
  box-shadow: 0 4px 14px rgba(49,130,206,0.4);
}
.btn-primary:hover { background: #2B6CB0; box-shadow: 0 6px 20px rgba(49,130,206,0.5); transform: translateY(-1px); }

.btn-danger {
  background: #FFF5F5; border: 1px solid #FEB2B2;
  border-radius: 6px; color: var(--danger);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px; padding: 4px 12px; cursor: pointer; transition: all .15s; font-weight: 600;
}
.btn-danger:hover { background: #FED7D7; }

.msg { margin-top: 1rem; font-size: 14px; text-align: center; font-weight: 500; }
.msg.ok  { color: var(--success); }
.msg.err { color: var(--danger); }

/* ---- DASHBOARD ---- */
.dash-stats {
  display: grid; grid-template-columns: repeat(4,1fr);
  gap: 12px; margin-bottom: 1.5rem;
}
.ds {
  background: #FFFFFF; border: 1px solid var(--border);
  border-radius: 14px; padding: 1.25rem;
  box-shadow: var(--shadow); transition: box-shadow 0.15s;
}
.ds:hover { box-shadow: var(--shadow-md); }
.ds-lbl  { font-size: 11px; color: var(--text2); margin-bottom: 8px; font-family: 'DM Mono', monospace; text-transform: uppercase; letter-spacing: 0.5px; }
.ds-val  { font-size: 28px; font-weight: 700; }
.ds-note { font-size: 11px; color: var(--text2); margin-top: 4px; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.dc {
  background: #FFFFFF; border: 1px solid var(--border);
  border-radius: 14px; padding: 1.25rem; box-shadow: var(--shadow);
}
.dc-title { font-size: 11px; font-weight: 700; color: var(--accent2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 1rem; }

.cb { margin-bottom: 10px; }
.cb-lbl { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; font-weight: 500; }
.cb-lbl span:last-child { color: var(--text2); font-family: 'DM Mono', monospace; }
.cb-track { height: 8px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.cb-fill  { height: 100%; border-radius: 4px; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.8px;
  font-family: 'DM Mono', monospace; background: var(--bg3);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ---- POPUP ---- */
.leaflet-popup-content-wrapper {
  background: #FFFFFF !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text) !important;
}
.leaflet-popup-tip { background: #FFFFFF !important; }

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 1.5rem;
}
.login-box {
  width: 100%; max-width: 420px;
  background: #FFFFFF;
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  margin: 0 auto 1.5rem;
  box-shadow: 0 8px 20px rgba(102,126,234,0.4);
}
.login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; color: var(--text); }
.login-sub   { font-size: 13px; color: var(--text2); text-align: center; margin-bottom: 2rem; }

.tab-switch {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--bg3); border-radius: 10px;
  padding: 4px; gap: 4px; margin-bottom: 1.5rem;
  border: 1px solid var(--border);
}
.tab-btn {
  padding: 8px; border-radius: 8px;
  border: none; background: transparent;
  color: var(--text2); font-family: 'Space Grotesk', sans-serif;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.tab-btn.active {
  background: #FFFFFF; color: var(--accent2);
  box-shadow: var(--shadow);
}

.fg { margin-bottom: 1rem; }

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: 2rem; right: 2rem;
  background: #FFFFFF; border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 18px;
  font-size: 13px; font-weight: 600;
  z-index: 9999; opacity: 0;
  transform: translateY(10px);
  transition: all .3s; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---- ACCESS DENIED ---- */
.denied-wrap {
  display: flex; align-items: center; justify-content: center;
  height: calc(100vh - 60px); flex-direction: column; gap: 12px;
}
.denied-icon  { font-size: 56px; }
.denied-title { font-size: 20px; font-weight: 700; color: var(--text); }
.denied-sub   { font-size: 14px; color: var(--text2); }

/* ---- USER CARD ---- */
.user-card {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem;
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 8px;
  transition: box-shadow 0.15s;
}
.user-card:hover { box-shadow: var(--shadow-md); }
.user-email { font-size: 14px; font-weight: 600; color: var(--text); }
.user-meta  { font-size: 11px; color: var(--text2); font-family: 'DM Mono', monospace; }

/* ---- MODAL ---- */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal {
  background: #FFFFFF;
  border-radius: 16px;
  padding: 2rem;
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}
.modal-title { font-size: 18px; font-weight: 700; margin-bottom: 1.5rem; color: var(--text); }
.modal-actions { display: flex; gap: 8px; margin-top: 1.5rem; }
.btn-sec {
  flex: 1; padding: 11px; border-radius: 8px;
  background: var(--bg3); border: 1.5px solid var(--border);
  color: var(--text); font-family: 'Space Grotesk', sans-serif;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.btn-sec:hover { background: var(--bg); }

@media(max-width:768px){
  .sidebar { display: none; }
  .dash-stats { grid-template-columns: 1fr 1fr; }
  .dash-grid  { grid-template-columns: 1fr; }
}
