/* PIBOHUB: gerak halus + tema pohon Hak Akses Menu. Dimuat setelah hub.css. */
:root {
  --ease: cubic-bezier(.22, .8, .3, 1);
  --t-fast: .16s;
  --t-mid: .28s;
  --shadow-2: 0 8px 24px rgba(120, 70, 10, .12);
}

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes pop  { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bar  { from { width: 0; } to { width: 88%; } }

/* Halaman masuk berurutan */
.content > * { animation: rise .42s var(--ease) both; }
.content > *:nth-child(2) { animation-delay: .05s; }
.content > *:nth-child(3) { animation-delay: .1s; }
.content > *:nth-child(4) { animation-delay: .15s; }
.kpis .kpi, .shortcuts .shortcut { animation: rise .45s var(--ease) both; }
.kpis .kpi:nth-child(2), .shortcuts .shortcut:nth-child(2) { animation-delay: .06s; }
.kpis .kpi:nth-child(3), .shortcuts .shortcut:nth-child(3) { animation-delay: .12s; }
.kpis .kpi:nth-child(4), .shortcuts .shortcut:nth-child(4) { animation-delay: .18s; }
.kpis .kpi:nth-child(n+5), .shortcuts .shortcut:nth-child(n+5) { animation-delay: .24s; }
.alert { animation: drop .35s var(--ease) both; transition: opacity .4s, transform .4s, max-height .4s, margin .4s, padding .4s; max-height: 120px; }
.alert.gone { opacity: 0; transform: translateY(-6px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }

/* Bar progres tipis saat berpindah halaman / mengirim formulir */
.nprog { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--yel), var(--pri)); z-index: 100; opacity: 0; pointer-events: none; }
.nprog.run { opacity: 1; animation: bar 6s cubic-bezier(.1, .6, .2, 1) forwards; }

/* Tombol */
.btn { transition: background var(--t-fast) var(--ease), color var(--t-fast), transform var(--t-fast) var(--ease), box-shadow var(--t-mid) var(--ease), opacity var(--t-fast); position: relative; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(120, 70, 10, .14); }
.btn:active { transform: translateY(0) scale(.97); box-shadow: none; }
.btn-primary:hover { box-shadow: 0 6px 14px rgba(244, 123, 32, .35); }
.btn:disabled { transform: none; box-shadow: none; }
.btn.loading { pointer-events: none; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn:not(.btn-primary):not(.btn-ok).loading::after { border-color: rgba(0, 0, 0, .2); border-top-color: var(--pri); }

/* Kolom isian */
.input { transition: border-color var(--t-fast), box-shadow var(--t-mid) var(--ease), background var(--t-fast); }
.input:hover:not(:focus):not([readonly]) { border-color: #cdbf9f; }
.input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(209, 55, 47, .16); }

/* Kartu, tabel, pintasan */
.card { transition: box-shadow var(--t-mid) var(--ease), border-color var(--t-mid); }
.kpi { transition: transform var(--t-mid) var(--ease), box-shadow var(--t-mid) var(--ease); }
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.shortcut { transition: border-color var(--t-fast), box-shadow var(--t-mid) var(--ease), transform var(--t-mid) var(--ease); }
.shortcut .badge-ico { transition: background var(--t-fast), color var(--t-fast), transform var(--t-mid) var(--ease); }
.shortcut:hover .badge-ico { background: var(--pri); color: #fff; transform: rotate(-6deg) scale(1.08); }
.tbl tbody tr { transition: background var(--t-fast), box-shadow var(--t-fast); }
.tbl:not(.rows-card) tbody tr:hover { box-shadow: inset 3px 0 0 var(--pri); }
.title-link { transition: color var(--t-fast); }
.badge { transition: transform var(--t-fast) var(--ease); }
.tbl tr:hover .badge { transform: scale(1.06); }
.pager li a { transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast); }
.pager li a:hover { transform: translateY(-1px); }

/* Sidebar */
.nav a, .nav summary { transition: background var(--t-fast), color var(--t-fast), padding var(--t-mid) var(--ease), box-shadow var(--t-mid); position: relative; }
.nav .ico { transition: transform var(--t-mid) var(--ease); }
.nav a:hover .ico, .nav summary:hover .ico { transform: scale(1.12); }
.nav summary .chev { transition: transform var(--t-mid) var(--ease); }
.nav details[open] > .sub { animation: drop .25s var(--ease); }
.brand-logo { transition: transform var(--t-mid) var(--ease); }
.brand:hover .brand-logo { transform: rotate(-4deg) scale(1.05); }
.scrim { display: block; position: fixed; inset: 0; background: rgba(20, 35, 15, .5); z-index: 25; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .3s, visibility .3s; }
.scrim.show { pointer-events: auto; }
.scrim.show { opacity: 1; visibility: visible; }

/* Bar atas */

/* Tab */
.tab-btn { transition: color var(--t-fast), border-color var(--t-mid) var(--ease), background var(--t-fast); }
.tab-btn:hover { color: var(--pri-d); background: #fff8ee; }
.tab-pane.active { animation: fade .3s var(--ease); }


/* =====================================================================
   Hak Akses Menu: Wunderbaum (pohon + kolom izin) bertema Darmi.
   ===================================================================== */
.access .toolbar { gap: 12px 16px; }
.role-pick { display: flex; align-items: center; gap: 8px; margin: 0; }
.role-pick label { font-weight: 600; }
.role-pick .input { width: auto; min-width: 220px; }
.access .search { max-width: 260px; }
.tool-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }

.tree-box {
  height: min(62vh, 640px); min-height: 320px;
  --wb-node-text-color: var(--ink);
  --wb-background-color: #fff;
  --wb-alternate-row-color: #fff;
  --wb-alternate-row-color-hover: #fffaf2;
  --wb-hover-color: #fffaf2;
  --wb-hover-border-color: transparent;
  --wb-header-color: #fff2e0;
  --wb-grid-color: var(--line);
  --wb-active-color: #fff1dd;
  --wb-active-hover-color: #ffe9cc;
  --wb-active-border-color: transparent;
  --wb-active-hover-border-color: transparent;
  --wb-active-cell-color: transparent;
  --wb-active-column-color: transparent;
  --wb-focus-border-color: var(--pri);
  --wb-filter-dim-color: #c9bfae;
  --wb-font-stack: "Segoe UI", Roboto, Arial, sans-serif;
  --wb-row-outer-height: 46px;
  --wb-row-inner-height: 44px;
  --wb-header-height: 40px;
  font-size: 14px;
}
.tree-box.wunderbaum { border: 0; background: #fff; font-family: inherit; }
.tree-box div.wb-header { background: #fff2e0; border-bottom: 1px solid var(--line); color: #7a4b12; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tree-box div.wb-header span.wb-col { color: #7a4b12; border-left: 0; display: flex; align-items: center; background: transparent; }
.tree-box div.wb-header span.wb-col.wb-perm { justify-content: center; }
.tree-box div.wb-row { border-bottom: 1px solid var(--line); transition: background var(--t-fast), box-shadow var(--t-fast), opacity .3s; animation: fade .3s var(--ease) both; }
.tree-box div.wb-row:hover { box-shadow: inset 3px 0 0 var(--pri); }
.tree-box div.wb-row span.wb-col { border-left: 0; display: flex; align-items: center; }
.tree-box span.wb-title { font-weight: 500; }
.tree-box div.wb-row span.wb-col.wb-perm { justify-content: center; }
.tree-box mark { background: #ffe2a8; color: inherit; border-radius: 3px; padding: 0 1px; }

/* Modul = pita hijau, grup = tebal, daun = biasa */
.tree-box .wb-t-module { background: #f3faf4; }
.tree-box .wb-t-module span.wb-title { font-weight: 700; color: var(--grn-d); text-transform: uppercase; letter-spacing: .04em; font-size: 12.5px; }
.tree-box .wb-t-module:hover { background: #eaf6ec !important; }
.tree-box .wb-t-group span.wb-title { font-weight: 700; }

/* Ikon pohon (tanpa font eksternal) */
.wbi { display: inline-block; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; transition: transform var(--t-mid) var(--ease), color var(--t-fast); }
.wbi-chev { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 6 6 6-6 6'/%3E%3C/svg%3E"); color: var(--pri-d); }
.wbi-chev.open { transform: rotate(90deg); }
.wbi-folder { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 6a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); color: var(--yel); }
.wbi-mod { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 3h8v8H3zm10 0h8v8h-8zM3 13h8v8H3zm10 0h8v8h-8z'/%3E%3C/svg%3E"); color: var(--grn); }
.wbi-doc { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 3v5h5'/%3E%3C/svg%3E"); color: var(--pri); }
.wbi-warn { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3C/svg%3E"); color: var(--bad); }
.wb-busy { animation: spin .8s linear infinite; }

/* Sakelar izin: kotak yang "mekar" saat dicentang */
.sw { position: relative; display: inline-flex; width: 22px; height: 22px; cursor: pointer; margin: 0; }
.sw input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.sw span { position: absolute; inset: 0; border-radius: 7px; border: 2px solid var(--field); background: #fff; transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-mid) var(--ease), transform var(--t-fast) var(--ease); }
.sw span::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) scale(0); transition: transform var(--t-fast) var(--ease); }
.sw:hover span { border-color: var(--pri); transform: scale(1.1); }
.sw input:checked + span { background: var(--grn); border-color: var(--grn); animation: pop .3s var(--ease); }
.sw input:checked + span::after { transform: rotate(45deg) scale(1); }
.sw input:indeterminate + span { background: var(--yel); border-color: var(--yel); }
.sw input:indeterminate + span::after { left: 4px; top: 8px; width: 10px; height: 0; border-width: 0 0 2.5px; border-color: #5a4300; transform: scale(1); }
.sw input:focus-visible + span { box-shadow: 0 0 0 3px rgba(244, 123, 32, .35); }
.sw input:disabled { cursor: not-allowed; }
.sw input:disabled + span { opacity: .55; }
.sw:has(input:disabled):hover span { transform: none; border-color: var(--field); }
.sw:has(input:checked:disabled):hover span { border-color: var(--grn); }

/* Bar simpan lengket di bawah kartu */
.save-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 22px; border-top: 1px solid var(--line); background: #fff; border-radius: 0 0 12px 12px; position: sticky; bottom: 0; transition: background var(--t-mid), box-shadow var(--t-mid); }
.save-bar.dirty { background: #fff7ea; box-shadow: 0 -6px 18px rgba(244, 123, 32, .12); }
.save-bar.dirty .btn-primary { animation: pop .4s var(--ease); }
.save-bar .warn { color: var(--pri-d); font-weight: 600; }
.save-bar .count { margin-left: auto; font-size: 12.5px; color: var(--mut); background: #f4ead9; padding: 3px 10px; border-radius: 20px; }

@media (max-width: 640px) {
  .tree-box div.wb-header { font-size: 9.5px; letter-spacing: 0; }
  .tree-box span.wb-title { font-size: 13px; }
  .tree-box span.wb-icon { display: none; }
  .tree-box span.wb-expander + span.wb-icon { display: none; }
  .sw { width: 20px; height: 20px; }
  .sw span::after { left: 5px; top: 1px; }
  .save-bar { padding: 12px 14px; }
  .save-bar .count { margin-left: 0; }
}

@media (max-width: 980px) {
  .tool-btns { margin-left: 0; }
  .access .search { max-width: none; }
  .tree-box { height: 60vh; }
}

/* Departemen di sidebar: grup yang bisa dilipat */
.nav details.dept { margin: 2px 0; border-radius: 10px; transition: background var(--t-mid); }
.nav details.dept[open] { background: rgba(255, 255, 255, .05); }
.nav details.dept > summary { text-transform: uppercase; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--yel); padding: 10px 12px; gap: 9px; }
.nav details.dept > summary .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pri); box-shadow: 0 0 0 3px rgba(244, 123, 32, .25); flex: none; transition: transform var(--t-mid) var(--ease), background var(--t-fast); }
.nav details.dept[open] > summary .dot { background: var(--yel); transform: scale(1.2); }
.nav details.dept > summary:hover { padding-left: 12px; background: rgba(255, 255, 255, .08); }
.nav details.dept[open] > summary .chev { transform: rotate(180deg); }
.nav details.dept > .dept-body { padding: 0 4px 6px; animation: drop .25s var(--ease); }
.nav details.dept .dept-body > a, .nav details.dept .dept-body > details > summary { font-size: 13.5px; padding: 8px 10px; }

/* Keadaan kosong (dashboard / modul / master / report yang belum berisi) */
.empty-state { text-align: center; padding: 56px 24px; }
.empty-state .big { width: 68px; height: 68px; border-radius: 20px; background: #fff1dd; color: var(--pri); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 14px; animation: pop .5s var(--ease) both; }
.empty-state .big .ico { width: 32px; height: 32px; }
.empty-state h2 { font-size: 18px; margin-bottom: 6px; color: var(--grn-d); }
.empty-state p { max-width: 460px; margin: 0 auto 16px; }
.dept-tabs { flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; transition-duration: .001ms !important; }
}
