/* Pull to Refresh — do NOT break side-menu / nested scroll */

/* Only dampen document overscroll at top; never lock pan-y on the whole app */
html.ptr-at-top:not(:has(body.side-menu-open)):not(:has(body.modal-open)) {
  overscroll-behavior-y: none;
}

/* While actively pulling to refresh */
html.ptr-dragging {
  overscroll-behavior-y: none;
}

html.ptr-dragging body:not(.side-menu-open):not(.modal-open) {
  overscroll-behavior-y: none;
}

/* Side menu scroll — لا تعطّل أزرار اللمس؛ pan-y داخل الدرج فقط */
body.side-menu-open .side-menu-drawer {
  touch-action: pan-y !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

#open-side-menu,
[data-open-side-menu],
#close-side-menu,
.side-menu-close,
#side-menu-backdrop {
  touch-action: manipulation !important;
}

/* Admin sidebar scroll safety */
body.admin-sidebar-open .admin-sidebar,
body.admin-sidebar-open .admin-sidebar * {
  touch-action: pan-y !important;
}

.ptr {
  --ptr-y: 0px;
  --ptr-progress: 0;
  --ptr-accent: var(--primary-color, var(--primary, #7c3aed));
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2147482000;
  display: flex;
  justify-content: center;
  pointer-events: none;
  transform: translate3d(0, calc(var(--ptr-y) - 52px), 0);
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  padding-top: max(8px, env(safe-area-inset-top, 0px));
}

.ptr.is-instant {
  transition: none !important;
}

.ptr.is-visible {
  opacity: 1;
}

.ptr__hint {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--page-shell-bg, #0f172a) 86%, transparent);
  border: 1px solid color-mix(in srgb, var(--ptr-accent) 30%, transparent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

html:not(.dark) body:not(.theme-dark) .ptr__hint {
  background: color-mix(in srgb, #fff 90%, transparent);
}

.ptr__ring {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--ptr-accent) 22%, transparent);
  border-top-color: var(--ptr-accent);
  transform: rotate(calc(var(--ptr-progress) * 280deg));
  box-sizing: border-box;
}

.ptr.is-armed .ptr__ring {
  border-color: color-mix(in srgb, #22c55e 22%, transparent);
  border-top-color: #22c55e;
}

@media (prefers-reduced-motion: reduce) {
  .ptr {
    transition: opacity 0.1s ease;
  }
}
