/* ==========================================================================
   Portal SiBakul Jogja - Menu navigasi mobile (penyegaran UI/UX)
   Berkas TERPISAH dari bundel Vite supaya bisa diubah tanpa build ulang.
   Laci mobile memakai breakpoint yang sama dengan gaya bawaan portal.

   Cara pakai: panggil dari index.html SETELAH CSS bundel:
     <link rel="stylesheet" href="/umkm/apps/assets/portal-nav-modern.css?v=1">
     <script src="/umkm/apps/assets/portal-nav-modern.js?v=1" defer></script>
   ========================================================================== */

@media (min-width: 901px) {
  .navbar #navMenu .nav-laci-judul { display: none; }

  .navbar #navMenu li > a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
}

@media (max-width: 900px) {

  /* ---------- tombol pemicu (hamburger) ---------- */
  .navbar .menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(148, 163, 184, .38);
    border-radius: 12px;
    background: #ffffff;
    color: #0f172a;
    font-size: 17px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: background .18s ease, color .18s ease, transform .18s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .navbar .menu-toggle:hover { background: #f1f5f9; }
  .navbar .menu-toggle:active { transform: scale(.94); }

  /* saat laci terbuka, tombol berubah jadi tombol tutup di sudut laci */
  body.nav-terbuka .navbar {
    z-index: 10000;
    overflow: visible;
  }

  body.nav-terbuka .navbar .menu-toggle {
    position: fixed;
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 14px;
    z-index: 130;
    border-color: transparent;
    background: #f1f5f9;
  }

  /* ---------- laci menu ---------- */
  .navbar-nav.active {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: min(86vw, 350px);
    height: 100vh;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: calc(74px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
    background: #ffffff;
    border: 0;
    border-radius: 22px 0 0 22px;
    box-shadow: -18px 0 48px rgba(15, 23, 42, .22);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 10001;
    animation: navLaciMasuk .28s cubic-bezier(.22, .61, .36, 1) both;
  }

  @keyframes navLaciMasuk {
    from { transform: translateX(100%); opacity: .35; }
    to   { transform: translateX(0);    opacity: 1; }
  }

  /* judul kecil di dalam laci */
  .navbar-nav.active .nav-laci-judul {
    padding: 0 10px 10px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #94a3b8;
  }

  /* ---------- baris menu ---------- */
  .navbar-nav.active li { width: 100%; }

  .navbar-nav.active li > a {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 52px;
    padding: 0 14px;
    border-radius: 14px;
    font-size: 15.5px;
    font-weight: 600;
    color: #1e293b;
    background: transparent;
    text-decoration: none;
    transition: background .16s ease, color .16s ease, transform .16s ease;
    animation: navBarisMasuk .3s ease both;
    -webkit-tap-highlight-color: transparent;
  }

  .navbar-nav.active li > a:hover,
  .navbar-nav.active li > a:focus-visible {
    background: var(--green-50, #f0fdf4);
    color: var(--green, #16a34a);
  }

  .navbar-nav.active li > a:active { transform: scale(.985); }

  /* ikon kotak di kiri tiap baris */
  .navbar-nav.active li > a .nav-ikon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #f1f5f9;
    color: #475569;
    font-size: 14.5px;
    transition: background .16s ease, color .16s ease;
  }

  .navbar-nav.active li > a:hover .nav-ikon,
  .navbar-nav.active li > a:focus-visible .nav-ikon {
    background: #dcfce7;
    color: var(--green, #16a34a);
  }

  /* tanda panah di kanan */
  .navbar-nav.active li > a::after {
    content: "\f054";
    margin-left: auto;
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 11px;
    color: #cbd5e1;
  }

  /* halaman yang sedang dibuka */
  .navbar-nav.active li > a.nav-aktif {
    background: var(--green-50, #f0fdf4);
    color: var(--green, #16a34a);
  }

  /* masuk berurutan (stagger) */
  .navbar-nav.active li:nth-child(2) > a { animation-delay: .04s; }
  .navbar-nav.active li:nth-child(3) > a { animation-delay: .08s; }
  .navbar-nav.active li:nth-child(4) > a { animation-delay: .12s; }
  .navbar-nav.active li:nth-child(5) > a { animation-delay: .16s; }
  .navbar-nav.active li:nth-child(6) > a { animation-delay: .20s; }

  @keyframes navBarisMasuk {
    from { opacity: 0; transform: translateX(18px); }
    to   { opacity: 1; transform: none; }
  }

  /* ---------- tombol Login di dasar laci ---------- */
  .navbar-nav.active li:last-child { margin-top: auto; }

  .navbar-nav.active .btn-login {
    justify-content: center;
    min-height: 52px;
    margin-top: 0;
    border-radius: 14px;
    font-size: 15.5px;
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(22, 163, 74, .28);
  }

  .navbar-nav.active .btn-login::after { content: none; }

  .navbar-nav.active .btn-login .nav-ikon {
    background: rgba(255, 255, 255, .18);
    color: #ffffff;
  }

  .navbar-nav.active .btn-login:hover,
  .navbar-nav.active .btn-login:focus-visible {
    background: linear-gradient(135deg, #16a34a, #166534);
    color: #ffffff;
    transform: none;
  }

  /* ---------- latar gelap ---------- */
  .nav-latar {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .48);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .24s ease, visibility .24s ease;
    z-index: 9990;
  }

  .nav-latar.tampil { opacity: 1; visibility: visible; }

  /* kunci gulir halaman saat laci terbuka */
  body.nav-terbuka { overflow: hidden; }
}

/* hormati preferensi "kurangi gerak" */
@media (prefers-reduced-motion: reduce) {
  .navbar-nav.active,
  .navbar-nav.active li > a,
  .navbar-nav.active li > a .nav-ikon,
  .nav-latar {
    animation: none !important;
    transition: none !important;
  }
}
