/* =====================================================================
   PORPROVKu — BASE
   Reset ringan, tipografi dasar, kerangka aplikasi (sidebar/topbar/
   bottom-nav/drawer), dan utilitas tata letak.
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, p, figure, blockquote { margin: 0; }
h1, h2, h3, h4 { line-height: var(--lh-snug); font-weight: var(--fw-bold); letter-spacing: -.01em; }
a { color: inherit; text-decoration: none; }
img, svg, video { max-width: 100%; display: block; }
button { font-family: inherit; }
ul, ol { margin: 0; padding-left: 1.15em; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }

/* Fokus terlihat untuk semua elemen interaktif (WCAG 2.2 AA) */
:focus-visible {
  outline: 2px solid var(--c-blue-600);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus:not(:focus-visible) { outline: none; }

/* Hormati preferensi pengurangan gerak */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Hanya untuk pembaca layar */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: -9999px; z-index: var(--z-tooltip);
  background: var(--n-0); color: var(--brand); padding: 10px 16px;
  border-radius: var(--r-sm); font-weight: var(--fw-bold); box-shadow: var(--sh-lg);
}
.skip:focus { left: 12px; top: 12px; }

/* ============================== KERANGKA ============================== */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ------------------------------ Sidebar ------------------------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  color: #DCE9F7;
  background:
    radial-gradient(900px 380px at 110% -10%, rgba(22, 104, 179, .55), transparent 60%),
    linear-gradient(180deg, #062A50 0%, var(--c-navy-800) 60%, var(--c-navy-900) 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  z-index: var(--z-sidebar);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-4); }
.brand-mark { width: 44px; height: 44px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .3)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: var(--fs-xl); color: var(--n-0); letter-spacing: .2px; }
.brand-text small { font-size: var(--fs-2xs); letter-spacing: .18em; color: var(--c-gold-300); font-weight: var(--fw-bold); }

.side-scroll { flex: 1; overflow-y: auto; padding: var(--sp-1) var(--sp-3) var(--sp-4); overscroll-behavior: contain; }
.side-scroll::-webkit-scrollbar { width: 6px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: var(--r-pill); }
.side-label {
  font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: var(--tracking-wider);
  color: rgba(220, 233, 247, .5); padding: var(--sp-4) 10px var(--sp-2); font-weight: var(--fw-bold);
}
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  min-height: 40px; padding: 9px var(--sp-3);
  border-radius: var(--r-md); font-size: var(--fs-base); font-weight: var(--fw-medium);
  color: #C8DAEE;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link svg { opacity: .82; width: 19px; height: 19px; }
.nav-link:hover { background: rgba(255, 255, 255, .08); color: var(--n-0); }
.nav-link.active {
  background: rgba(255, 255, 255, .14); color: var(--n-0); font-weight: var(--fw-semibold);
  box-shadow: inset 3px 0 0 var(--c-gold-300);
}
.nav-link.active svg { opacity: 1; color: var(--c-gold-300); }
.nav-badge {
  margin-left: auto; background: var(--c-gold-300); color: var(--c-navy-900);
  font-size: var(--fs-xs); font-weight: var(--fw-black); border-radius: var(--r-pill); padding: 1px 7px;
}
.side-foot { padding: var(--sp-3); border-top: 1px solid rgba(255, 255, 255, .08); background: rgba(0, 0, 0, .14); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 6px 4px var(--sp-3); }
.side-user .avatar { background: var(--c-gold-300); color: var(--c-navy-900); }
.su-text { display: flex; flex-direction: column; min-width: 0; }
.su-text strong { font-size: var(--fs-sm); color: var(--n-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-text small { font-size: var(--fs-xs); color: var(--c-gold-300); }
.side-note { font-size: var(--fs-xs); color: rgba(220, 233, 247, .65); margin-top: 10px; text-align: center; }

/* ------------------------------- Konten ------------------------------- */
.main {
  flex: 1; min-width: 0; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: 10px var(--sp-7);
  color: var(--n-0);
  background:
    radial-gradient(700px 240px at 100% 0, rgba(22, 104, 179, .6), transparent 65%),
    linear-gradient(115deg, #062A50 0%, var(--c-navy-700) 62%, var(--c-navy-600) 100%);
  border-bottom: 3px solid var(--c-gold-300);
  box-shadow: 0 6px 20px rgba(5, 36, 66, .18);
}
.topbar-brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.topbar-mark { width: 38px; height: 38px; flex: 0 0 auto; }
.topbar-title { min-width: 0; }
.topbar-kicker { font-size: 9.5px; letter-spacing: .2em; color: var(--c-gold-300); font-weight: var(--fw-black); display: block; }
.topbar-page { font-size: var(--fs-xl); font-weight: var(--fw-bold); color: var(--n-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.topbar-title p { font-size: var(--fs-xs); color: rgba(255, 255, 255, .72); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: var(--sp-2); }

.icon-btn {
  position: relative; width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: var(--r-md); color: #EAF3FC; background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
  transition: background var(--dur-fast) var(--ease);
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .2); }
.icon-btn .dot {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px;
  background: var(--c-gold-300); color: var(--c-navy-900); font-size: 10px; font-weight: var(--fw-black);
  border-radius: 10px; display: grid; place-items: center; padding: 0 4px; border: 2px solid #062A50;
}
.profile-btn {
  display: flex; align-items: center; gap: 9px; padding: 4px var(--sp-2) 4px 4px;
  border-radius: var(--r-md); background: rgba(255, 255, 255, .1);
  border: 1px solid rgba(255, 255, 255, .14);
}
.profile-btn:hover { background: rgba(255, 255, 255, .18); }
.pb-text { display: flex; flex-direction: column; line-height: 1.25; }
.pb-text strong { font-size: var(--fs-sm); color: var(--n-0); }
.pb-text small { font-size: var(--fs-2xs); color: var(--c-gold-300); }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255, 255, 255, .18); color: var(--n-0);
  font-weight: var(--fw-black); font-size: var(--fs-sm);
  border: 1px solid rgba(255, 255, 255, .25); flex: 0 0 auto;
}
.avatar-sm { width: 26px; height: 26px; font-size: var(--fs-2xs); }

.content {
  flex: 1; width: 100%; max-width: var(--content-max);
  margin: 0 auto; padding: var(--sp-6) var(--sp-7) var(--sp-12);
}
.content-wide { max-width: var(--content-max-wide); }

/* ------------------------------- Footer ------------------------------- */
.footer { background: var(--surface); border-top: 1px solid var(--line); padding: var(--sp-5) var(--sp-7); }
.footer-in {
  max-width: var(--content-max); margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: var(--sp-4); align-items: center; justify-content: space-between;
}
.footer-brand { display: flex; align-items: center; gap: 10px; }
.footer-mark { width: 34px; height: 34px; }
.footer-brand strong { font-size: var(--fs-sm); color: var(--c-navy-800); }
.footer-brand p { font-size: var(--fs-xs); color: var(--muted); }
.footer-links { display: flex; gap: var(--sp-3); font-size: var(--fs-sm); color: var(--muted); flex-wrap: wrap; }
.footer-links a:hover { color: var(--brand); text-decoration: underline; }
.footer-copy { font-size: var(--fs-xs); color: var(--muted-2); width: 100%; margin: 0; }

/* ---------------------------- Bottom nav ------------------------------ */
.bottomnav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(7, 50, 96, .08);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 2px; font-size: var(--fs-2xs); font-weight: var(--fw-semibold);
  color: var(--n-500); border-radius: var(--r-md); min-height: var(--tap);
  transition: color var(--dur-fast) var(--ease);
}
.bn-item svg { width: 22px; height: 22px; }
.bn-item.active, .bn-item.active svg, .bn-item.active span { color: var(--brand); }
.bn-item:active { transform: scale(.96); }

/* ------------------------------ Drawer -------------------------------- */
.drawer { position: fixed; inset: 0; z-index: var(--z-drawer); }
.drawer[hidden] { display: none; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(5, 36, 66, .48); backdrop-filter: blur(2px); }
.drawer-panel {
  position: absolute; top: 0; bottom: 0; left: 0; width: min(86vw, 320px);
  background: var(--surface); display: flex; flex-direction: column;
  box-shadow: var(--sh-xl); animation: drawerIn var(--dur-base) var(--ease-out);
}
@keyframes drawerIn { from { transform: translateX(-16px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-3) var(--sp-2); border-bottom: 1px solid var(--line);
}
.drawer-head .icon-btn { background: var(--bg-subtle); border-color: var(--line); color: var(--ink-soft); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-3) var(--sp-3) var(--sp-6); overscroll-behavior: contain; }
.drawer-user {
  display: flex; gap: 10px; align-items: center; background: var(--bg-subtle);
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px; margin-bottom: var(--sp-2);
}
.drawer-user .avatar { background: linear-gradient(135deg, var(--c-navy-700), var(--c-blue-600)); }
.drawer-user b { display: block; font-size: var(--fs-sm); }
.drawer-user small { font-size: var(--fs-xs); color: var(--muted); }
.drawer-nav { display: flex; flex-direction: column; gap: 2px; }
.drawer-link {
  display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 10px 11px;
  border-radius: var(--r-md); font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--n-700);
}
.drawer-link svg { width: 18px; height: 18px; color: var(--n-500); }
.drawer-link:hover, .drawer-link.active { background: var(--c-blue-100); color: var(--brand); font-weight: var(--fw-bold); }
.drawer-link:hover svg { color: var(--brand); }
.drawer-foot { padding: var(--sp-3) var(--sp-1) 0; border-top: 1px solid var(--line); margin-top: var(--sp-3); }
.menu-btn { display: none; }

/* ============================== UTILITAS ============================== */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--sp-2); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: 6px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
/* Item grid tidak boleh melebar melebihi kolom (penyebab overflow di ponsel) */
.grid > *, .dash-grid > *, .stack > *, .stack-sm > *, .kpi-grid > *, .monitor-grid > * { min-width: 0; }

.center { text-align: center; }
.right { text-align: right; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.strong { font-weight: var(--fw-bold); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-4 { margin-top: var(--sp-1); } .mt-8 { margin-top: var(--sp-2); }
.mt-12 { margin-top: var(--sp-3); } .mt-16 { margin-top: var(--sp-4); }
.mt-24 { margin-top: var(--sp-6); }
.flex-1 { flex: 1; min-width: 0; }
.w-full { width: 100%; }

.divider { height: 1px; background: var(--line); margin: var(--sp-4) 0; }

/* ============================= RESPONSIF ============================== */
@media (max-width: 1180px) {
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .bottomnav { display: flex; }
  .topbar { padding: 10px var(--sp-4) 10px var(--sp-3); }
  .topbar-mark { width: 34px; height: 34px; }
  .topbar-page { font-size: var(--fs-lg); }
  .topbar-title p { display: none; }
  .topbar-actions .icon-btn { width: 36px; height: 36px; }
  .profile-btn .pb-text { display: none; }
  .profile-btn { padding: 3px; background: transparent; border-color: transparent; }
  .menu-btn { display: grid; }
  .hide-sm { display: none; }
  .content { padding: var(--sp-4) var(--sp-4) calc(var(--bottomnav-h) + var(--sp-8)); }
  .footer { display: none; }
  .grid, .stack { gap: var(--sp-3); }
  .grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}
@media (max-width: 420px) {
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* =============================== CETAK =============================== */
@media print {
  .sidebar, .topbar, .bottomnav, .footer, .drawer,
  .no-print, .page-head-actions, .tbl-toolbar, .tbl-filters, .tbl-foot,
  .filter-bar, .bulk-bar { display: none !important; }
  .main { margin: 0; }
  .content { max-width: none; padding: 0; }
  body { background: #fff; color: #000; }
  .card, .data-card { border: 0; box-shadow: none; break-inside: avoid; }
}

/* Pencarian pada layar kecil: ikon saja */
@media (max-width: 900px) {
  .search-trigger { display: none; }
  .search-mobile { display: grid !important; }
}
