/* ════════════════════════════════════════════════════════════════
   Bottom nav — mobile-only (≤900px)
   Fixed di bawah, support safe-area iOS, theme-aware
   ════════════════════════════════════════════════════════════════ */

#bn-root {
  display: none; /* sembunyi di desktop */
}

@media (max-width: 900px) {
  #bn-root {
    display: grid;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 150;
    grid-template-columns: repeat(var(--bn-cols, 5), 1fr);
    align-items: stretch;
    background: var(--surface, #fff);
    border-top: 1px solid var(--border, #e2e8f0);
    box-shadow: 0 -4px 14px -8px rgba(0, 0, 0, 0.18);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  /* Beri padding-bottom otomatis pada body supaya konten tidak ketutupan */
  body.has-bn {
    padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  text-decoration: none;
  color: var(--text3, #64748b);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1px;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: color .12s, background .12s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bn-item .ico {
  font-size: 19px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
}
.bn-item .lbl {
  font-size: 10.5px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bn-item .badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 99px; background: #dc2626; color: white;
  font-size: 9.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--surface, #fff);
}
.bn-item .badge.hide { display: none; }

.bn-item:hover {
  color: var(--text, #0f172a);
  background: var(--surface2, #f1f5f9);
}
.bn-item.active {
  color: var(--primary, #2563eb);
}
.bn-item.active .ico {
  transform: translateY(-2px);
}
.bn-item.active::before {
  content: '';
  position: absolute; top: 0; left: 30%; right: 30%; height: 2.5px;
  background: var(--primary, #2563eb);
  border-radius: 0 0 3px 3px;
}

/* Saat printing — sembunyi */
@media print {
  #bn-root { display: none !important; }
  body.has-bn { padding-bottom: 0 !important; }
}

/* ════════════════════════════════════════════════════════════════
   MOBILE MODAL FIX — tombol aksi di footer modal selalu terlihat,
   tidak tertimpa bottom-nav.
   Konvensi naming yg dipakai di repo:
   - Overlay: .modal-overlay (pipeline/admin/analis/pemutus/karyawan/dokumen)
              .modal-bg      (hrd/kakantor/direksi)
   - Inner:   .modal         (hrd/kakantor/direksi/pipeline/admin/analis/pemutus)
              .modal-card    (karyawan/dokumen)
   - Footer:  .modal-footer  (pipeline/admin/analis)
              .modal-foot    (dokumen/kredit/karyawan)
   Footer di-sticky-kan + safe-area padding agar selalu di atas nav.
   ════════════════════════════════════════════════════════════════ */
.modal-footer,
.modal-foot {
  position: sticky;
  bottom: 0;
  background: var(--surface, #ffffff);
  z-index: 2;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important;
}
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .modal-foot {
  background: var(--surface, #0f172a);
}

@media (max-width: 900px) {
  /* Reserve area di bawah overlay supaya modal tercentered tidak overlap nav */
  body.has-bn .modal-overlay,
  body.has-bn .modal-bg {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px)) !important;
  }
  /* Cap tinggi modal supaya seluruh modal (termasuk tombol di bawah) selalu
     terlihat di atas bottom-nav. Cover semua kombinasi overlay × inner. */
  body.has-bn .modal-overlay > .modal,
  body.has-bn .modal-overlay > .modal-card,
  body.has-bn .modal-bg > .modal,
  body.has-bn .modal-bg > .modal-card {
    max-height: calc(100vh - 90px - env(safe-area-inset-bottom, 0px)) !important;
  }
}
