/* Bintang Motor public UX layer: page loading bar, tap feedback, toasts, connection banner.
   Kept small and dependency-free; everything respects prefers-reduced-motion. */
:root { --bm-red: #e31e24; --bm-red-dark: #c41a1f; --bm-ease: cubic-bezier(.2, .8, .2, 1); }

/* ---------- Page loading bar (navigation & form submit) ---------- */
#bm-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000; pointer-events: none;
  background: transparent; opacity: 0; transition: opacity .2s ease;
}
#bm-progress::before {
  content: ""; position: absolute; inset: 0; transform-origin: left; transform: scaleX(0);
  background: linear-gradient(90deg, var(--bm-red), #ff6b6b); box-shadow: 0 0 8px rgba(227, 30, 36, .45);
}
#bm-progress.is-active { opacity: 1; }
#bm-progress.is-active::before { animation: bm-progress 8s var(--bm-ease) forwards; }
#bm-progress.is-done::before { animation: none; transform: scaleX(1); transition: transform .2s ease; }
@keyframes bm-progress { 0% { transform: scaleX(0); } 10% { transform: scaleX(.35); } 40% { transform: scaleX(.7); } 100% { transform: scaleX(.92); } }

/* Busy state for the element that started a navigation / submit */
.bm-busy { position: relative; pointer-events: none; }
.bm-busy::after {
  content: ""; width: 1em; height: 1em; margin-left: .45em; display: inline-block; vertical-align: -.15em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: bm-spin .7s linear infinite;
}
@keyframes bm-spin { to { transform: rotate(360deg); } }

/* Simple skeleton shimmer for lazy content containers (opt-in: class="bm-skeleton") */
.bm-skeleton { position: relative; overflow: hidden; background: #eef0f3; border-radius: 10px; min-height: 1em; }
.bm-skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent); animation: bm-shimmer 1.2s infinite;
}
@keyframes bm-shimmer { to { transform: translateX(100%); } }

/* Images fade in once decoded (prevents a hard "pop" on slow mobile networks) */
img.bm-fade { opacity: 0; transition: opacity .35s ease; }
img.bm-fade.is-loaded { opacity: 1; }

/* ---------- Tap / press feedback ---------- */
html { -webkit-tap-highlight-color: transparent; }
.btn, button, [role="button"], a.nav-link, .navbar a, .bottom-nav a, .mobile-bottom-nav a, .dropdown-item,
.page-link, .card a, a.card, .badge a, .list-group-item-action, [data-bm-press] {
  transition: transform .12s var(--bm-ease), box-shadow .15s ease, background-color .15s ease, color .15s ease, opacity .15s ease;
  touch-action: manipulation;
}
.btn:active, button:not(:disabled):active, [role="button"]:active, a.nav-link:active, .navbar a:active,
.bottom-nav a:active, .mobile-bottom-nav a:active, .dropdown-item:active, .page-link:active,
.list-group-item-action:active, [data-bm-press]:active { transform: scale(.96); }
.card a:active img, a.card:active { transform: scale(.985); }
/* Ripple added by bm-ux.js on pointerdown */
.bm-ripple-host { position: relative; overflow: hidden; }
.bm-ripple {
  position: absolute; border-radius: 50%; pointer-events: none; transform: scale(0); opacity: .32;
  background: currentColor; animation: bm-ripple .5s ease-out forwards;
}
@keyframes bm-ripple { to { transform: scale(2.6); opacity: 0; } }
/* Visible keyboard focus everywhere */
:focus-visible { outline: 2px solid var(--bm-red); outline-offset: 2px; }

/* Comfortable touch targets on phones */
@media (max-width: 767.98px) {
  .btn, .page-link, .form-select, .form-control { min-height: 44px; }
  .btn-sm { min-height: 38px; }
}

/* ---------- Toasts ---------- */
#bm-toasts {
  position: fixed; z-index: 2100; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 24px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
@media (min-width: 992px) { #bm-toasts { left: auto; right: 20px; transform: none; bottom: 20px; } }
.bm-toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 12px;
  background: #fff; color: #222; box-shadow: 0 10px 30px rgba(0, 0, 0, .14), 0 2px 6px rgba(0, 0, 0, .06);
  border-left: 4px solid #6c757d; font-size: .9rem; line-height: 1.4;
  animation: bm-toast-in .28s var(--bm-ease);
}
.bm-toast.is-leaving { animation: bm-toast-out .22s ease forwards; }
.bm-toast__icon { flex: 0 0 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: .72rem; font-weight: 700; background: #6c757d; }
.bm-toast__body { flex: 1; min-width: 0; }
.bm-toast__title { font-weight: 600; margin-bottom: 1px; }
.bm-toast__close { border: 0; background: transparent; color: #888; font-size: 1.1rem; line-height: 1; padding: 2px 4px; min-height: 0; }
.bm-toast--success { border-left-color: #198754; } .bm-toast--success .bm-toast__icon { background: #198754; }
.bm-toast--error { border-left-color: #dc3545; } .bm-toast--error .bm-toast__icon { background: #dc3545; }
.bm-toast--warning { border-left-color: #f59f00; } .bm-toast--warning .bm-toast__icon { background: #f59f00; }
.bm-toast--info { border-left-color: #0d6efd; } .bm-toast--info .bm-toast__icon { background: #0d6efd; }
@keyframes bm-toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes bm-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ---------- Connection banner ---------- */
#bm-net {
  position: fixed; left: 0; right: 0; top: 0; z-index: 2050; text-align: center; font-size: .82rem; font-weight: 500;
  padding: 6px 12px calc(6px); color: #fff; background: #343a40; transform: translateY(-100%); transition: transform .25s var(--bm-ease);
}
#bm-net.is-offline { background: #b02a37; transform: none; }
#bm-net.is-slow { background: #9a6700; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .bm-ripple, .bm-toast, #bm-progress::before, .bm-skeleton::after, img.bm-fade { animation: none !important; transition: none !important; }
  img.bm-fade { opacity: 1; }
  .btn:active, button:active, [data-bm-press]:active { transform: none; }
}

/* ---------- Small responsive guards (mobile first) ---------- */
.breadcrumb { flex-wrap: wrap; row-gap: 2px; }
.breadcrumb-item { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 575.98px) {
  .breadcrumb-item.active { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
video, iframe { max-width: 100%; }
