/* ════════════════════════════════════════════════════════════════
   Shared Image / PDF Viewer
   - Zoom (wheel / pinch / buttons)
   - Rotate (-90° / +90°)
   - Pan saat zoomed
   - Keyboard: Esc, ← →, +/-, R/L, 0 reset
   ════════════════════════════════════════════════════════════════ */

#vw-root {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.94);
  display: none; flex-direction: column;
  -webkit-user-select: none; user-select: none;
}
#vw-root.open { display: flex; }
@media print { #vw-root { display: none !important; } }

/* Toolbar atas */
.vw-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  flex-shrink: 0;
  padding-top: max(10px, env(safe-area-inset-top, 0px));
}
.vw-toolbar .vw-title {
  flex: 1; font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.vw-toolbar .vw-idx {
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.7);
  padding: 0 8px;
}
.vw-tb-group {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 3px; border-radius: 8px;
  background: rgba(255,255,255,0.06);
}
.vw-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px; padding: 0 10px;
  background: transparent; color: #fff; border: 0;
  border-radius: 6px; cursor: pointer; font-size: 14px;
  transition: background .12s;
}
.vw-btn:hover { background: rgba(255,255,255,0.12); }
.vw-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.vw-btn.vw-close {
  background: rgba(239,68,68,0.7); padding: 0 14px;
}
.vw-btn.vw-close:hover { background: rgba(239,68,68,0.9); }
.vw-btn .lbl { font-size: 12px; font-weight: 600; margin-left: 4px; }

/* Stage area */
.vw-stage {
  flex: 1; position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.vw-canvas-wrap {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  cursor: grab;
  touch-action: none;
}
.vw-canvas-wrap.dragging { cursor: grabbing; }
.vw-canvas-wrap.zoomed { cursor: grab; }

.vw-img, .vw-iframe {
  max-width: 95vw; max-height: 100%;
  transform-origin: center center;
  transition: transform .15s ease-out;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.vw-canvas-wrap.dragging .vw-img,
.vw-canvas-wrap.dragging .vw-iframe { transition: none; }
.vw-iframe {
  width: 92vw; height: 92vh; background: #fff; border: 0; border-radius: 8px;
  pointer-events: auto; /* iframe needs interaction for PDF scroll */
}

/* Side navigation arrows (mobile-friendly large hit area) */
.vw-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 56px; height: 96px; border-radius: 8px;
  background: rgba(15,23,42,0.4);
  color: #fff; border: 0; cursor: pointer;
  font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.vw-nav:hover { background: rgba(15,23,42,0.7); }
.vw-nav:disabled { opacity: 0.25; cursor: not-allowed; }
.vw-nav.prev { left: 10px; }
.vw-nav.next { right: 10px; }
@media (max-width: 700px) {
  .vw-nav { width: 40px; height: 70px; font-size: 24px; }
}

/* Footer hint */
.vw-hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.55); font-size: 11px;
  background: rgba(0,0,0,0.4); padding: 6px 12px; border-radius: 99px;
  pointer-events: none;
}
@media (max-width: 700px) { .vw-hint { display: none; } }

/* Toolbar collapse di mobile */
@media (max-width: 640px) {
  .vw-toolbar { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  .vw-toolbar .vw-title { order: -1; width: 100%; font-size: 12px; }
  .vw-btn { min-width: 32px; height: 32px; padding: 0 8px; }
  .vw-btn .lbl { display: none; }
}
