:root {
  --sidebar-width: 265px;
  --topbar-height: 58px;

  /* Palet PU: navy + gold */
  --pu-navy-dark: #0E3B6B;
  --pu-navy: #154C87;
  --pu-navy-light: #1E63A8;
  --pu-gold: #F2A900;
  --pu-gold-soft: rgba(242, 169, 0, .15);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: #f4f6f9;
}

/* ============ LAYOUT UTAMA ============ */
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============ TOPBAR ============ */
.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--pu-navy-dark) 0%, var(--pu-navy) 60%, var(--pu-navy-light) 100%);
  color: #fff;
  z-index: 1050;
  border-bottom: 3px solid var(--pu-gold);
}
.topbar .brand-title { font-size: 1rem; font-weight: 600; letter-spacing: .2px; }
.topbar .btn-toggle {
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  line-height: 1;
  padding: .35rem .5rem;
  border-radius: .5rem;
}
.topbar .btn-toggle:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ============ WRAPPER ============ */
.main-wrapper {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid #e4e8ee;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: margin-left .28s ease, transform .28s ease;
  z-index: 1040;
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }

.sidebar-brand-icon {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: .6rem;
  background: rgba(14,59,107,.10);
  color: var(--pu-navy);
  font-size: 1.15rem;
  flex-shrink: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .68rem .85rem;
  border-radius: .55rem;
  color: #4a5568;
  font-size: .92rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .18s, color .18s, box-shadow .18s;
}
.sidebar-link i { font-size: 1.08rem; width: 1.2rem; text-align: center; }
.sidebar-link:hover { background: #eef3fb; color: var(--pu-navy); }
.sidebar-link.active {
  background: var(--pu-navy);
  color: #fff;
  box-shadow: 0 3px 10px rgba(14,59,107,.35);
  border-left: 3px solid var(--pu-gold);
  padding-left: calc(.85rem - 3px);
}

/* ---- Submenu sidebar (mis. Perijinan > KKKPR / PKKPR) ---- */
.sidebar-link.has-submenu {
  justify-content: space-between;
  cursor: pointer;
}
.sidebar-link.has-submenu .submenu-left {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.sidebar-link.has-submenu .bi-chevron-down {
  font-size: .78rem;
  transition: transform .22s ease;
}
.sidebar-link.has-submenu[aria-expanded="true"] .bi-chevron-down {
  transform: rotate(180deg);
}
.sidebar-submenu {
  list-style: none;
  margin: .15rem 0 .25rem;
  padding-left: 0;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.sidebar-sublink {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .85rem .55rem 2.35rem;
  border-radius: .55rem;
  color: #5a6473;
  font-size: .86rem;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: background .18s, color .18s;
}
.sidebar-sublink i { font-size: .5rem; }
.sidebar-sublink:hover { background: #eef3fb; color: var(--pu-navy); }
.sidebar-sublink.active {
  background: rgba(14,59,107,.10);
  color: var(--pu-navy);
  font-weight: 600;
}

/* ---- Breadcrumb halaman ---- */
.page-breadcrumb {
  --bs-breadcrumb-divider: '/';
  font-size: .82rem;
  margin-bottom: .35rem;
}
.page-breadcrumb a { color: #6c757d; text-decoration: none; }
.page-breadcrumb a:hover { color: var(--pu-navy); text-decoration: underline; }
.page-breadcrumb .active { color: var(--pu-navy); font-weight: 600; }

/* ---- Label halaman sederhana (non-breadcrumb) ---- */
.page-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--pu-navy);
  margin-bottom: .35rem;
}

/* ============ CONTENT ============ */
.content {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  background: #f4f6f9;
}

.page-section {
  display: none;
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.page-section.active { display: block; }

/* Halaman peta: full screen tanpa padding */
#page-peta { overflow: hidden; }
#page-peta.active { display: block; }

#map {
  width: 100%;
  height: 100%;
  background: #e9eef5;
  position: relative;
}

.map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 1.5rem;
  gap: .35rem;
  color: #6c757d;
  pointer-events: none;
}
.map-placeholder .ph-icon {
  width: 76px; height: 76px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  font-size: 2rem;
  color: var(--pu-navy);
  margin-bottom: .75rem;
}

/* ============ OVERRIDE TOMBOL BOOTSTRAP ============ */
.btn-primary {
  --bs-btn-bg: var(--pu-navy);
  --bs-btn-border-color: var(--pu-navy);
  --bs-btn-hover-bg: var(--pu-navy-dark);
  --bs-btn-hover-border-color: var(--pu-navy-dark);
  --bs-btn-active-bg: var(--pu-navy-dark);
  --bs-btn-active-border-color: var(--pu-navy-dark);
  --bs-btn-focus-shadow-rgb: 14,59,107;
}

/* ============ TABEL ============ */
.card { border-radius: .75rem; }
.table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #5a6473;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid #e4e8ee;
}
.table td { font-size: .88rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f7faff; }

/* ============ BACKDROP (MOBILE) ============ */
.sidebar-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 1035;
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s ease, visibility .28s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
  .sidebar {
    position: absolute;
    top: 0; bottom: 0; left: 0;
    transform: translateX(-100%);
    box-shadow: 0 0 24px rgba(0,0,0,.18);
  }
  .sidebar.show { transform: translateX(0); }
  .sidebar.collapsed { margin-left: 0; } /* reset untuk mobile */
  .sidebar-backdrop { display: block; }
}

@media (max-width: 575.98px) {
  .page-section .p-3 { padding: .9rem !important; }
  .table td, .table th { font-size: .8rem; }
}

/* Scrollbar halus */
.sidebar::-webkit-scrollbar,
.page-section::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-thumb,
.page-section::-webkit-scrollbar-thumb {
  background: #cbd5e1; border-radius: 10px;
}
.sidebar::-webkit-scrollbar-thumb:hover,
.page-section::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   AUTH STATE — visibilitas elemen berdasarkan status login
   ============================================================ */
html.logged-in .guest-only            { display: none !important; }
html:not(.logged-in) .auth-only       { display: none !important; }
html:not(.logged-in) .col-aksi        { display: none !important; }

/* ============================================================
   TOPBAR — tombol Login & Logout
   ============================================================ */
.topbar .btn-login {
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  background: rgba(255,255,255,.12);
  font-weight: 600;
  padding: .32rem .7rem;
  border-radius: .45rem;
}
.topbar .btn-login:hover,
.topbar .btn-login:focus {
  background: var(--pu-gold);
  border-color: var(--pu-gold);
  color: #1a1a1a;
}

.topbar .btn-outline-light {
  --bs-btn-color: #fff;
  --bs-btn-border-color: rgba(255,255,255,.55);
  --bs-btn-hover-bg: var(--pu-gold);
  --bs-btn-hover-border-color: var(--pu-gold);
  --bs-btn-hover-color: #1a1a1a;
  --bs-btn-active-bg: var(--pu-gold);
  --bs-btn-active-border-color: var(--pu-gold);
  --bs-btn-active-color: #1a1a1a;
}

.topbar #authArea .bi-person-circle {
  color: rgba(255,255,255,.9);
}

.card-footer [data-pagination] .page-link {
  color: var(--pu-navy);
  border-color: #e4e8ee;
}
.card-footer [data-pagination] .page-item.active .page-link {
  background: var(--pu-navy);
  border-color: var(--pu-navy);
  color: #fff;
}
.card-footer [data-pagination] .page-item.disabled .page-link {
  color: #adb5bd;
}
@media (max-width: 575.98px) {
  .card-footer [data-page-info] { font-size: .75rem; }
  .card-footer .pagination { flex-wrap: wrap; }
}