/* ASDrive - animasi halus & profesional untuk panel admin.
   Prinsip: singkat (120-350 ms), hanya opacity/transform, tidak menghalangi klik, dan
   otomatis nonaktif bila pengguna memilih "kurangi gerakan" di sistemnya. */
:root { --ad-ease: cubic-bezier(.22, .61, .36, 1); }

@keyframes ad-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ad-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ad-pop  { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes ad-spin { to { transform: rotate(360deg); } }
@keyframes ad-toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* Halaman: isi muncul naik tipis, berurutan */
.ad-content > * { animation: ad-rise .35s var(--ad-ease) both; }
.ad-content > :nth-child(2) { animation-delay: .04s; }
.ad-content > :nth-child(3) { animation-delay: .08s; }
.ad-content > :nth-child(4) { animation-delay: .12s; }
.ad-content > :nth-child(n+5) { animation-delay: .16s; }

/* Kartu dan baris tabel (tundaan diisi skrip) */
[data-stagger] > * { animation: ad-rise .4s var(--ad-ease) both; animation-delay: calc(var(--i, 0) * 45ms + 60ms); }
.table-ad tbody tr { animation: ad-fade .3s var(--ad-ease) both; animation-delay: calc(var(--i, 0) * 18ms); }
.stat-card .value, .cal-badge { font-variant-numeric: tabular-nums; }

/* Kartu statistik: tampilan ringkas untuk 6 kartu sebaris */
.dash-title { font-size: .72rem; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ad-muted); margin: 0 0 .65rem .15rem; }
.stat-card.compact { flex-direction: column; align-items: flex-start; gap: .7rem; padding: 1rem 1.1rem; }
.stat-card.compact .icon { width: 40px; height: 40px; border-radius: 12px; font-size: 1.2rem; }
.stat-card.compact .value { font-size: 1.6rem; }
.stat-card .txt { min-width: 0; }
.stat-card { transition: transform .2s var(--ad-ease), box-shadow .2s var(--ad-ease), border-color .2s; }
a.stat-card:active { transform: translateY(0) scale(.99); }
.chart-box { position: relative; height: 300px; }
.recent-list { max-height: 362px; overflow-y: auto; }
.recent-list > a { transition: background-color .15s; }
.recent-list > a:hover { background: var(--ad-primary-softer); }
.recent-list > a:last-child { border-bottom: 0 !important; }

/* Tombol: tekan terasa, spinner saat memproses */
.btn { transition: transform .12s var(--ad-ease), box-shadow .2s, background-color .2s, border-color .2s, color .2s, opacity .2s; }
.btn:active:not(.disabled):not(:disabled) { transform: scale(.97); }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading > * { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 1.05rem; height: 1.05rem; margin: -.525rem 0 0 -.525rem;
  border: 2px solid var(--ad-spin, #fff); border-right-color: transparent; border-radius: 50%; animation: ad-spin .7s linear infinite;
}
.btn-outline-primary.is-loading, .btn-outline-secondary.is-loading, .btn-outline-danger.is-loading, .btn-light.is-loading, .btn-link.is-loading { --ad-spin: var(--ad-primary); }

/* Tautan dan menu samping */
.ad-nav a:not(.active):hover { transform: translateX(2px); }
.ad-icon-btn { transition: background-color .15s, color .15s, border-color .15s, transform .12s; }
.ad-icon-btn:active { transform: scale(.94); }

/* Dropdown, modal, peringatan */
.dropdown-menu.show { animation: ad-pop .16s var(--ad-ease); transform-origin: top right; }
.modal.fade .modal-dialog { transform: translateY(14px) scale(.98); transition: transform .25s var(--ad-ease); }
.modal.show .modal-dialog { transform: none; }
.alert { animation: ad-rise .3s var(--ad-ease) both; }
.form-control, .form-select { transition: border-color .15s, box-shadow .2s, background-color .2s; }
.badge { transition: background-color .2s, color .2s; }

/* Bilah kemajuan tipis di tepi atas saat berpindah halaman / mengirim formulir */
#ad-progress { position: fixed; z-index: 3000; top: 0; left: 0; height: 3px; width: 0; opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, #ff7a1f, #fc5f00, #fcc800); box-shadow: 0 0 8px rgba(252, 95, 0, .5);
  transition: width .4s var(--ad-ease), opacity .25s; }
#ad-progress.on { opacity: 1; }

/* Notifikasi kecil (mis. unduhan Excel) */
#ad-toasts { position: fixed; z-index: 2100; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.ad-toast { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; border-radius: 12px; background: var(--ad-card); color: var(--ad-text);
  border: 1px solid var(--ad-border); border-left-width: 4px; box-shadow: var(--ad-shadow-lg, 0 10px 30px rgba(0, 0, 0, .18)); animation: ad-toast-in .25s var(--ad-ease) both; font-size: .9rem; }
.ad-toast.ok { border-left-color: #19a86c; } .ad-toast.err { border-left-color: #ef4444; } .ad-toast.info { border-left-color: var(--ad-primary); }
.ad-toast.out { opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; }

/* Dialog konfirmasi & menu bunyi: menggantikan kotak bawaan peramban */
body.ad-dlg-open { overflow: hidden; }
.ad-dlg-backdrop { position: fixed; inset: 0; z-index: 2500; display: grid; place-items: center; padding: 1rem; background: rgba(10, 12, 18, .55);
  backdrop-filter: blur(3px); opacity: 0; transition: opacity .2s ease; }
.ad-dlg-backdrop.on { opacity: 1; }
.ad-dlg { width: min(420px, 100%); background: var(--ad-card); color: var(--ad-text); border: 1px solid var(--ad-border); border-radius: 18px; padding: 1.6rem 1.5rem 1.3rem;
  text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); transform: translateY(14px) scale(.96); opacity: 0; transition: transform .26s var(--ad-ease), opacity .2s; }
.ad-dlg-backdrop.on .ad-dlg { transform: none; opacity: 1; }
.ad-dlg-icon { width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto .9rem; font-size: 1.7rem; background: rgba(252, 95, 0, .12); color: var(--ad-primary); }
.ad-dlg-backdrop.on .ad-dlg-icon { animation: ad-dlg-pop .45s var(--ad-ease) .05s both; }
.ad-dlg-danger .ad-dlg-icon { background: rgba(239, 68, 68, .14); color: #ef4444; }
.ad-dlg-success .ad-dlg-icon { background: rgba(25, 168, 108, .14); color: #19a86c; }
.ad-dlg h2 { font-size: 1.15rem; font-weight: 800; margin: 0 0 .4rem; }
.ad-dlg p { margin: 0 0 1.3rem; color: var(--ad-muted, var(--ad-text)); font-size: .95rem; line-height: 1.5; }
.ad-dlg-actions { display: flex; gap: .6rem; justify-content: center; }
.ad-dlg-actions .btn { flex: 1; min-height: 42px; font-weight: 700; }
@keyframes ad-dlg-pop { 0% { transform: scale(.5); opacity: 0; } 70% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }

.ad-menu { position: fixed; z-index: 2400; width: 300px; max-width: calc(100vw - 1.5rem); background: var(--ad-card); color: var(--ad-text); border: 1px solid var(--ad-border);
  border-radius: 16px; box-shadow: 0 18px 44px rgba(0, 0, 0, .3); padding: .5rem; opacity: 0; transform: translateY(-6px) scale(.97); transform-origin: top right; transition: opacity .16s, transform .2s var(--ad-ease); }
.ad-menu.on { opacity: 1; transform: none; }
.ad-menu-head { display: flex; align-items: center; gap: .6rem; padding: .55rem .6rem .7rem; border-bottom: 1px solid var(--ad-border); margin-bottom: .35rem; }
.ad-menu-head .dotl { width: 10px; height: 10px; border-radius: 50%; background: #19a86c; box-shadow: 0 0 0 4px rgba(25, 168, 108, .18); }
.ad-menu-head b { display: block; font-size: .92rem; } .ad-menu-head small { color: var(--ad-muted, inherit); opacity: .8; }
.ad-menu button { display: flex; width: 100%; align-items: center; gap: .7rem; text-align: left; background: transparent; border: 0; color: inherit; padding: .6rem; border-radius: 11px; transition: background-color .15s; }
.ad-menu button:hover, .ad-menu button:focus-visible { background: var(--ad-primary-soft); outline: none; }
.ad-menu button .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--ad-primary-soft); color: var(--ad-primary); flex: 0 0 auto; }
.ad-menu button.off .ic { background: rgba(239, 68, 68, .12); color: #ef4444; }
.ad-menu button span b { display: block; font-size: .9rem; } .ad-menu button span small { opacity: .75; font-size: .78rem; }

/* Transisi keluar halaman: isi memudar tipis saat berpindah, memberi kesan responsif tanpa menunda */
.ad-content { transition: opacity .16s ease; }
body.ad-leaving .ad-content { opacity: .55; }

/* Kerangka "memuat" untuk daftar yang diisi lewat skrip */
@keyframes ad-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.trk-skel { display: grid; gap: .6rem; padding: 1rem 1.25rem; }
.trk-skel i { display: block; height: 58px; border-radius: 12px;
  background: linear-gradient(90deg, var(--ad-primary-softer) 25%, var(--ad-primary-soft) 50%, var(--ad-primary-softer) 75%); background-size: 200% 100%; animation: ad-shimmer 1.4s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  .trk-skel i { animation: none !important; }
  body.ad-leaving .ad-content { opacity: 1; }
  .ad-dlg, .ad-dlg-backdrop, .ad-menu { transition: opacity .01s !important; transform: none !important; }
  .ad-dlg-backdrop.on .ad-dlg-icon { animation: none !important; }
  .ad-content > *, [data-stagger] > *, .table-ad tbody tr, .alert, .dropdown-menu.show, .ad-toast { animation: none !important; }
  .btn:active, .ad-nav a:hover, a.stat-card:hover { transform: none !important; }
  #ad-progress { transition: none; }
}

/* Aplikasi web teknisi (/app): isi halaman muncul lembut dan memudar tipis saat berpindah, sama seperti panel admin */
.pt-content > * { animation: ad-rise .35s var(--ad-ease) both; }
.pt-content > :nth-child(2) { animation-delay: .04s; }
.pt-content > :nth-child(3) { animation-delay: .08s; }
.pt-content > :nth-child(n+4) { animation-delay: .12s; }
.pt-content { transition: opacity .16s ease; }
body.ad-leaving .pt-content { opacity: .55; }

/* Halaman masuk / lupa sandi: kartu dan panel kiri muncul lembut */
.auth-wrap .box { animation: ad-rise .45s var(--ad-ease) both; }
.auth-hero > * { animation: ad-fade .6s var(--ad-ease) both; }
.auth-hero > :nth-child(2) { animation-delay: .08s; }

@media (prefers-reduced-motion: reduce) {
  .pt-content > *, .auth-wrap .box, .auth-hero > * { animation: none !important; }
  body.ad-leaving .pt-content { opacity: 1; }
}

/* Mode gelap: logo ASNET (kuning) tampil langsung tanpa kotak putih */
[data-bs-theme="dark"] .ad-brand img,
[data-bs-theme="dark"] .auth-simple .logo,
[data-bs-theme="dark"] .auth-form .box .logo-sm { background: transparent; padding: 0; box-shadow: none; border-radius: 0; }
